flutterfire icon indicating copy to clipboard operation
flutterfire copied to clipboard

🐛 [cloud_firestore_odm] Allow passing startAt only on the first orderBy query

Open rrousselGit opened this issue 2 years ago • 0 comments

Consider:

@Collection<Foo>('firestore-example-app/test/private-advanced')
@JsonSerializable()
class Foo {
  Foo({
    this.firstName,
    this.lastName,

  });

  final String? firstName;
  final String? lastName;
}

Currently, it is "allowed" to write:

void main() {
  FooCollectionReference().orderByFirstName().orderByLastName(startAt: 'John');
}

But such a query does not make sense, as due to how Firestore works, the startAt will be applied on firstName not lastName.

Currently, this throws an assertion error, but this could be made a compilation error if calling orderByX returned a special type of Query that doesn't have startAt operators.

rrousselGit avatar Jul 08 '22 15:07 rrousselGit