Skip to content

Firestore Query filtering issue: Loop updates all documents instead of filtered ones. #6878

@VicSim001

Description

@VicSim001

Can we access your project?

  • I give permission for members of the FlutterFlow team to access and test my project for the sole purpose of investigating this issue.

Current Behavior

I have a collection photos where each document has an album_id (Doc Reference to albums). When deleting an album, I use a Firestore Query to find all photos with that album_id, followed by a Loop to update them (setting show_on_home to true).

The Problem: The query doesn't seem to filter correctly, and the Loop updates EVERY photo in the database, including profile pictures and photos from other albums. Additionally, I cannot find the 'Reference' option when setting up the filter in the Action Flow, even though the field is a Doc Reference.

Expected Behavior

The query should only return photos where album_id matches the current album's reference, and the Loop should only update those specific photos.

Steps to Reproduce

Trigger an Action Flow on a button.

Add "Firestore Query" on the photos collection with a filter album_id == Page Parameter (Album Ref).

Add a Loop to update the documents returned by the query.

Observe that all documents in the collection are being updated regardless of the filter.

Reproducible from Blank

  • The steps to reproduce above start from a blank project.

Bug Report Code (Required)

Align( alignment: AlignmentDirectional(0.94, 0.95), child: FFButtonWidget( onPressed: () async { _model.photosToMove = await queryPhotosRecordOnce( queryBuilder: (photosRecord) => photosRecord.where( 'album_id', isEqualTo: _model.selectedAlbum, ), ); for (int loop1Index = 0; loop1Index < _model.photosToMove!.length; loop1Index++) { final currentLoop1Item = _model.photosToMove![loop1Index]; await currentLoop1Item.reference.update({ ...createPhotosRecordData( showOnHome: true, ), ...mapToFirestore( { 'album_id': FieldValue.delete(), }, ), }); } await _model.selectedAlbumforsomething.firstOrNull!.delete(); _model.isSelectModeALBUM = false; _model.selectedAlbumforsomething = []; safeSetState(() {}); safeSetState(() {}); context.pushNamed(HomePageWidget.routeName); safeSetState(() {}); }, text: 'delete', options: FFButtonOptions( width: 87, height: 40, padding: EdgeInsetsDirectional.fromSTEB(16, 0, 16, 0), iconPadding: EdgeInsetsDirectional.fromSTEB(0, 0, 0, 0), color: FlutterFlowTheme.of(context).primary, textStyle: FlutterFlowTheme.of(context).titleSmall.override( font: GoogleFonts.interTight( fontWeight: FlutterFlowTheme.of(context).titleSmall.fontWeight, fontStyle: FlutterFlowTheme.of(context).titleSmall.fontStyle, ), color: Colors.white, letterSpacing: 0.0, fontWeight: FlutterFlowTheme.of(context).titleSmall.fontWeight, fontStyle: FlutterFlowTheme.of(context).titleSmall.fontStyle, ), elevation: 0, borderRadius: BorderRadius.circular(24), ), ), )

Visual documentation

Image Image Image Image Image Image Image Image Image Image Image Image Image Image Image Image Image Image Image Image Image Image

Environment

Platform: Web

Browser: Chrome 

Operating system: Windows 10/11 или macOS.

Additional Information

This issue is critical for my app's logic. It prevents users from managing albums because deleting one album affects the visibility of all other private and profile photos. I am trying to achieve a simple 'move to home' logic for specific photos, but the filter failure makes the app unusable for photo organization.

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions