Skip to content

Transaction set fails #77

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

Open
ConschiB opened this issue Mar 22, 2025 · 2 comments
Open

Transaction set fails #77

ConschiB opened this issue Mar 22, 2025 · 2 comments
Assignees
Labels
bug Something isn't working question Further information is requested

Comments

@ConschiB
Copy link

ConschiB commented Mar 22, 2025

First of all, really happy that transactions are now available in this package! Thanks a lot.

Describe the bug
When executing transaction.set(), the transaction crashes with following message:

'({(QueryDocumentSnapshot<Map<String, Object?>>) => Map<String, Object?> fromFirestore, (Map<String, Object?>) => Map<String, Object?> toFirestore})' is not a subtype of type '({(QueryDocumentSnapshot<Map<String, Object?>>) => dynamic fromFirestore, (dynamic) => Map<String, Object?> toFirestore})'

To Reproduce

await firestore.runTransaction((transaction) async {
    var otherIdDoc= await transaction.get(otherIdReference);
    transaction.update(otherIdReference, {'count': FieldValue.increment(1)});
    transaction.set(docRef, {'testkey': 'testvalue'});
    }

Expected behavior
Expected, that the transaction works.

@ConschiB ConschiB added the bug Something isn't working label Mar 22, 2025
@rrousselGit
Copy link
Collaborator

Do you have the stacktrace and a bit more context around the issue? I can't reproduce it with what you gave us.

@rrousselGit rrousselGit added the question Further information is requested label Mar 24, 2025
@rrousselGit
Copy link
Collaborator

rrousselGit commented Mar 24, 2025

Tried both with withConverter and without, yet it's working fine for me.

I don't think I'll be able to move things forward without a more complete example and a stacktrace.

Passing test:

test('regression #77', () async {
  final otherIdReference = await initializeTest('otherId');
  await otherIdReference.set({'count': 0});

  final docRef = await initializeTest('simpleDocument');

  await firestore.runTransaction((transaction) async {
    await transaction.get(otherIdReference);
    transaction.update(otherIdReference, {
      'count': const FieldValue.increment(1),
    });
    transaction.set(docRef, {'testKey': 'testvalue'});
  });

  expect(
    await otherIdReference.get().then((s) => s.data()),
    {'count': 1},
  );

  expect(
    await docRef.get().then((s) => s.data()),
    {'testKey': 'testvalue'},
  );
});

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working question Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants