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

fix(cloud_firestore_odm): add support for searching Enums #8386

Closed
wants to merge 29 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
ea9513c
PR#8386: Added very simple support for dart enums to cloud_firestore_…
mrorabau Jul 8, 2022
0d02d97
Change enum case
rrousselGit Sep 8, 2022
914b858
Merge branch 'master' of https://github.com/firebase/flutterfire into…
rrousselGit Sep 8, 2022
71ef107
Merge branch 'master' of https://github.com/firebase/flutterfire
mrorabau Oct 11, 2022
76106fd
Updated from upstream/master
mrorabau Oct 12, 2022
6a2705f
Merge branch 'master' of https://github.com/firebase/flutterfire
mrorabau Oct 13, 2022
8c748b5
Changed query_reference.dart to now support the new where style.
mrorabau Oct 13, 2022
a10f505
rebuild simple model used for tests
ryanawhelan Oct 14, 2022
ad09802
reformat code
ryanawhelan Oct 14, 2022
f49c00f
Merge branch 'master' of https://github.com/firebase/flutterfire into…
rrousselGit Nov 7, 2022
f40ccc6
Fix warnings and ugrade analyzer
rrousselGit Nov 7, 2022
cad8409
Fix lints
rrousselGit Nov 7, 2022
3764922
Use unreleased json_serializable
rrousselGit Nov 8, 2022
5388d21
Add missing import
rrousselGit Nov 8, 2022
e96417e
Revert document_reference
rrousselGit Nov 8, 2022
5f734e3
Use perfieldToJson
rrousselGit Nov 8, 2022
71f10d9
Merge branch 'master' of https://github.com/firebase/flutterfire into…
rrousselGit Nov 8, 2022
3abc71d
Use git json_serializable
rrousselGit Nov 8, 2022
933e9df
Revert gitignore
rrousselGit Nov 8, 2022
de6228d
Update where method
rrousselGit Nov 8, 2022
3edf38b
handle orderBy offet operators
rrousselGit Nov 8, 2022
d571dd2
Merge branch 'master' of https://github.com/firebase/flutterfire into…
rrousselGit Nov 28, 2022
3f7165e
Update generated files
rrousselGit Nov 28, 2022
beb2b8a
Use flutter master channel
rrousselGit Nov 28, 2022
be65adb
Fix compilation error
rrousselGit Nov 29, 2022
8591596
Update generated files
rrousselGit Nov 29, 2022
f4f0bdc
fix integration folder
rrousselGit Nov 29, 2022
d8adcb5
Update generated files
rrousselGit Nov 29, 2022
b0ef252
Merge remote-tracking branch 'upstream/master'
ryanawhelan May 18, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions .github/workflows/all_plugins.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ jobs:
- uses: actions/checkout@8f4b7f84864484a7bf31766abe9204da3cbe65b3
- uses: subosito/flutter-action@dbf1fa04f4d2e52c33185153d06cdb5443aa189d
with:
channel: 'stable'
channel: 'master'
cache: true
- uses: bluefireteam/melos-action@dd3c344d731938d2ab2567a261f54a19a68b5f6a
with:
Expand Down Expand Up @@ -61,7 +61,7 @@ jobs:
- uses: actions/checkout@8f4b7f84864484a7bf31766abe9204da3cbe65b3
- uses: subosito/flutter-action@dbf1fa04f4d2e52c33185153d06cdb5443aa189d
with:
channel: 'stable'
channel: 'master'
cache: true
- uses: bluefireteam/melos-action@dd3c344d731938d2ab2567a261f54a19a68b5f6a
with:
Expand All @@ -78,7 +78,7 @@ jobs:
- uses: actions/checkout@8f4b7f84864484a7bf31766abe9204da3cbe65b3
- uses: subosito/flutter-action@dbf1fa04f4d2e52c33185153d06cdb5443aa189d
with:
channel: 'stable'
channel: 'master'
cache: true
- uses: bluefireteam/melos-action@dd3c344d731938d2ab2567a261f54a19a68b5f6a
with:
Expand Down Expand Up @@ -111,7 +111,7 @@ jobs:
- uses: actions/checkout@8f4b7f84864484a7bf31766abe9204da3cbe65b3
- uses: subosito/flutter-action@dbf1fa04f4d2e52c33185153d06cdb5443aa189d
with:
channel: 'stable'
channel: 'master'
cache: true
- uses: bluefireteam/melos-action@dd3c344d731938d2ab2567a261f54a19a68b5f6a
with:
Expand All @@ -128,7 +128,7 @@ jobs:
- uses: actions/checkout@8f4b7f84864484a7bf31766abe9204da3cbe65b3
- uses: subosito/flutter-action@dbf1fa04f4d2e52c33185153d06cdb5443aa189d
with:
channel: 'stable'
channel: 'master'
cache: true
- uses: bluefireteam/melos-action@dd3c344d731938d2ab2567a261f54a19a68b5f6a
with:
Expand Down
8 changes: 4 additions & 4 deletions .github/workflows/e2e_tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ jobs:
restore-keys: firebase-emulators-v2
- uses: subosito/flutter-action@dbf1fa04f4d2e52c33185153d06cdb5443aa189d
with:
channel: 'stable'
channel: 'master'
cache: true
- uses: bluefireteam/melos-action@dd3c344d731938d2ab2567a261f54a19a68b5f6a
with:
Expand Down Expand Up @@ -134,7 +134,7 @@ jobs:
restore-keys: firebase-emulators-v1
- uses: subosito/flutter-action@dbf1fa04f4d2e52c33185153d06cdb5443aa189d
with:
channel: 'stable'
channel: 'master'
cache: true
- uses: bluefireteam/melos-action@dd3c344d731938d2ab2567a261f54a19a68b5f6a
with:
Expand Down Expand Up @@ -212,7 +212,7 @@ jobs:
restore-keys: firebase-emulators-v1
- uses: subosito/flutter-action@dbf1fa04f4d2e52c33185153d06cdb5443aa189d
with:
channel: 'stable'
channel: 'master'
cache: true
- uses: bluefireteam/melos-action@dd3c344d731938d2ab2567a261f54a19a68b5f6a
with:
Expand Down Expand Up @@ -263,7 +263,7 @@ jobs:
java-version: '11'
- uses: subosito/flutter-action@dbf1fa04f4d2e52c33185153d06cdb5443aa189d
with:
channel: 'stable'
channel: 'master'
cache: true
- uses: bluefireteam/melos-action@dd3c344d731938d2ab2567a261f54a19a68b5f6a
with:
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/firebase_firestore_odm.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ jobs:
fetch-depth: 0
- uses: subosito/flutter-action@dbf1fa04f4d2e52c33185153d06cdb5443aa189d
with:
channel: 'stable'
channel: 'master'
cache: true
- uses: bluefireteam/melos-action@dd3c344d731938d2ab2567a261f54a19a68b5f6a
with:
Expand Down Expand Up @@ -64,7 +64,7 @@ jobs:
java-version: '11'
- uses: subosito/flutter-action@dbf1fa04f4d2e52c33185153d06cdb5443aa189d
with:
channel: 'stable'
channel: 'master'
cache: true
- uses: bluefireteam/melos-action@dd3c344d731938d2ab2567a261f54a19a68b5f6a
with:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ targets:
- lib/**
options:
create_field_map: true
create_per_field_to_json: true
source_gen|combining_builder:
options:
ignore_for_file:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,112 @@ void main() {
skip: true,
);

test(
'supports get with enum',
() async {
final collection = await initializeTest(MovieCollectionReference());

await collection.doc('123').set(
createMovie(
title: 'title',
certification: CertificationType.pg,
),
);

await collection.doc('123').get();

expect(
await collection
.whereCertification(isEqualTo: CertificationType.pg)
.get(),
isA<MovieQuerySnapshot>().having((e) => e.docs, 'doc', [
isA<MovieQueryDocumentSnapshot>().having(
(e) => e.data.certification,
'data.certification',
CertificationType.pg,
)
]),
);
},
);

test(
'supports get using list of enum',
() async {
final collection = await initializeTest(MovieCollectionReference());

await collection.doc('123').set(
createMovie(
title: 'title',
language: [LanguageType.english, LanguageType.korean],
cast: [
{CastType.coStar: 'William Shatner'},
{CastType.cameo: 'Harlan Ellison'}
],
),
);
await collection.doc('123').get();

expect(
await collection
.whereLanguage(
arrayContains: LanguageType.english,
// arrayContainsAny: [LanguageType.English],
// isEqualTo: [LanguageType.English, LanguageType.Korean]
)
.get(),
isA<MovieQuerySnapshot>().having((e) => e.docs, 'doc', [
isA<MovieQueryDocumentSnapshot>().having(
(e) => e.data.language,
'data.language',
[LanguageType.english, LanguageType.korean],
)
]),
);
},
);

test(
'supports get using enum (list of) map',
() async {
final collection = await initializeTest(MovieCollectionReference());

await collection.doc('123').set(
createMovie(
title: 'title',
language: [LanguageType.english, LanguageType.korean],
cast: [
{
CastType.coStar: 'William Shatner',
},
{CastType.cameo: 'Harlan Ellison'}
],
majorCast: {
CastType.coStar: 'William Shatner',
CastType.cameo: 'Harlan Ellison'
},
),
);
await collection.doc('123').get();

expect(
await collection.whereCast(
// whereMajorCast
arrayContains: {
CastType.coStar: 'William Shatner',
},
).get(),
isA<MovieQuerySnapshot>().having((e) => e.docs, 'doc', [
isA<MovieQueryDocumentSnapshot>()
.having((e) => e.data.cast, 'data.cast', [
{CastType.coStar: 'William Shatner'},
{CastType.cameo: 'Harlan Ellison'},
])
]),
);
},
);

test('returns a future that fails if decoding throws', () async {
final collection = await initializeTest(MovieCollectionReference());

Expand Down Expand Up @@ -767,6 +873,15 @@ void main() {
title: 'title',
year: 1999,
id: '_',
language: [LanguageType.english],
certification: CertificationType.pg,
cast: [
{CastType.cameo: 'Wil Wheaton', CastType.recurring: 'Jim Parsons'}
],
majorCast: {
CastType.cameo: 'Wil Wheaton',
CastType.recurring: 'Jim Parsons'
},
),
);
final snapshot = StreamQueue(doc.snapshots());
Expand All @@ -791,6 +906,18 @@ void main() {
title: 'title2',
year: 14242,
id: '_',
language: [LanguageType.english],
certification: CertificationType.R,
cast: [
{
CastType.star: 'Michael Jackson',
CastType.guestStar: 'Vincent Price'
}
],
majorCast: {
CastType.star: 'Michael Jackson',
CastType.guestStar: 'Vincent Price'
},
),
);

Expand Down Expand Up @@ -825,6 +952,18 @@ void main() {
title: 'title',
year: 1999,
id: '_',
language: [LanguageType.english],
certification: CertificationType.pg13,
cast: [
{
CastType.coStar: 'William Shatner',
CastType.cameo: 'Harlan Ellison'
}
],
majorCast: {
CastType.coStar: 'William Shatner',
CastType.cameo: 'Harlan Ellison'
},
),
);

Expand All @@ -848,6 +987,18 @@ void main() {
title: 'title2',
year: 14242,
id: '_',
language: [LanguageType.spanish],
certification: CertificationType.tvma,
cast: [
{
CastType.coStar: 'Sandra Bullock',
CastType.cameo: 'George Clooney'
}
],
majorCast: {
CastType.coStar: 'Sandra Bullock',
CastType.cameo: 'George Clooney'
},
),
);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,15 @@ Movie createMovie({
String title = '',
int year = 1990,
String id = '',
List<LanguageType> language = const [],
CertificationType certification = CertificationType.none,
List<Map<CastType, String>> cast = const [
{CastType.cameo: 'Wil Wheaton', CastType.recurring: 'Jim Parsons'}
],
Map<CastType, String> majorCast = const {
CastType.cameo: 'Wil Wheaton',
CastType.recurring: 'Jim Parsons'
},
}) {
return Movie(
genre: genre,
Expand All @@ -41,6 +50,10 @@ Movie createMovie({
title: title,
year: year,
id: id,
language: language,
certification: certification,
cast: cast,
majorCast: majorCast,
);
}

Expand Down
Loading
Loading