Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[cloud_firestore] Not possible to merge set calls with Firestore transactions #1212

Closed
kroikie opened this issue Oct 13, 2019 · 11 comments
Closed
Labels
impact: crowd (P2) Affects many people, though not necessarily a specific customer with an assigned label. (P2) plugin: cloud_firestore type: missing-feature A feature that is support on the underlying Firebase SDK but has not been exposed to Dart API.

Comments

@kroikie
Copy link
Collaborator

kroikie commented Oct 13, 2019

Merging set calls using transactions is currently not possible in Flutter because we don't have a SetOptions class and parameter for the set() method.

However, the docs stay otherwise:

    /// Writes to the document referred to by the provided [DocumentReference].
    /// If the document does not exist yet, it will be created. If you pass
    /// SetOptions, the provided data can be merged into the existing document.
      Future<void> set(
      ///.....

Issue was also posted on StackOverflow: https://stackoverflow.com/questions/57202980/unable-to-merge-a-transaction-set-with-setoptions

Doctor

[√] Flutter (Channel stable, v1.7.8+hotfix.3, on Microsoft Windows [Version 10.0.17134.885], locale en-US)
    • Flutter version 1.7.8+hotfix.3 at C:\flutter
    • Framework revision b712a172f9 (2 weeks ago), 2019-07-09 13:14:38 -0700
    • Engine revision 54ad777fd2
    • Dart version 2.4.0


[√] Android toolchain - develop for Android devices (Android SDK version 28.0.3)
    • Android SDK at C:\Users\milen\AppData\Local\Android\sdk
    • Android NDK location not configured (optional; useful for native profiling support)
    • Platform android-28, build-tools 28.0.3
    • Java binary at: C:\Program Files\Android\Android Studio\jre\bin\java
    • Java version OpenJDK Runtime Environment (build 1.8.0_152-release-1248-b01)
    • All Android licenses accepted.

[√] Android Studio (version 3.3)
    • Android Studio at C:\Program Files\Android\Android Studio
    • Flutter plugin version 32.0.1
    • Dart plugin version 182.5124
    • Java version OpenJDK Runtime Environment (build 1.8.0_152-release-1248-b01)

[√] VS Code (version 1.36.1)
    • VS Code at C:\Users\milen\AppData\Local\Programs\Microsoft VS Code
    • Flutter extension version 3.2.0

[√] VS Code, 64-bit edition (version 1.23.0)
    • VS Code at C:\Program Files\Microsoft VS Code
    • Flutter extension version 3.2.0

[√] Connected device (1 available)
    • INE LX1 • 5MG7N18829009925 • android-arm64 • Android 9 (API 28)

• No issues found!

@kroikie
Copy link
Collaborator Author

kroikie commented Oct 13, 2019

@mpivchev

The issue at flutter/flutter#36950 has been closed and moved here. Future collaboration on this issue will be done here.

@janmoppel janmoppel changed the title Not possible to merge set calls with Firestore transactions [cloud_firestore] Not possible to merge set calls with Firestore transactions Oct 18, 2019
@janmoppel janmoppel added type: documentation Improvements or additions to documentation type: enhancement New feature or request labels Oct 18, 2019
@willvlad
Copy link

willvlad commented Dec 15, 2019

Same issue here! Any ETA?

@GRpro
Copy link

GRpro commented Jan 19, 2020

Any updates on this? Also faced an issue.

@andrsdev
Copy link

andrsdev commented Mar 10, 2020

Same problem here!!!

@willhaslett
Copy link

willhaslett commented Mar 31, 2020

I'm sure that the Flutter team has an abundance of important issues to address, but supporting all basic CRUD operations for the SDK's supported backend seems fundamental. Is there a plan for this?

@Ehesp Ehesp added plugin: cloud_firestore type: missing-feature A feature that is support on the underlying Firebase SDK but has not been exposed to Dart API. labels Apr 22, 2020
@Ehesp
Copy link
Member

Ehesp commented Apr 22, 2020

Looks like support is available in the document reference but not the set of the transaction. Tracking it as high-priority.

@Ehesp Ehesp added impact: crowd (P2) Affects many people, though not necessarily a specific customer with an assigned label. (P2) and removed type: documentation Improvements or additions to documentation type: enhancement New feature or request labels Apr 22, 2020
@Ehesp
Copy link
Member

Ehesp commented Apr 22, 2020

A dirty workaround for now would be to read the document contents and merge the data together inside of the set until this gets fixed - not ideal but until this gets fixed it's the only solution.

@willhaslett
Copy link

willhaslett commented May 4, 2020

@Ehesp Could that merging workaround be implemented on the backend using the .onWrite() hook in a Cloud Function, since that function has both the pre and post versions of the document available to it?

@Bobthebuilder24
Copy link

Bobthebuilder24 commented May 25, 2020

Can the update operation be changed to support this case? Making it merge if existing, and creating if not present?

@Ehesp
Copy link
Member

Ehesp commented May 25, 2020

This is being sorted as part of #2582

It'll also include merge and mergeFields.

@Salakar
Copy link
Member

Salakar commented Jul 8, 2020

Hey, as part of our on-going work for #2582, support for SetOptions on Transaction.set has been added in our Firebase Firestore rework (#2913) - which has now been merged into master. We'll look at publishing some prereleases in the next few days. Thank you

@Salakar Salakar closed this as completed Jul 8, 2020
@firebase firebase locked and limited conversation to collaborators Aug 9, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
impact: crowd (P2) Affects many people, though not necessarily a specific customer with an assigned label. (P2) plugin: cloud_firestore type: missing-feature A feature that is support on the underlying Firebase SDK but has not been exposed to Dart API.
Projects
None yet
Development

No branches or pull requests

9 participants