You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When having a field with a type enum, the ODM generator automagically produces code to store or retrieve the values (technically as a String), however it does not create the .whereEnumField and .orderEnumField code. It is my assumption this is supposed to work because it will store/retrieve the enums.
Steps to reproduce
Steps to reproduce the behavior:
Create a Model with an (userRef) enum
Create a document using the model to store the enum (usersRef.add(myEnum: testEnum.red))
Attempt to search the model with usersRef.whereMyEnum(isEqualTo: testEnum.red)
Expected behavior
A method .whereMyEnum should be created for each enum field.
Sample project
enum ContentType {
text,
image,
video,
audio,
}
@JsonSerializable()
class TestUser {
TestUser({
required this.name,
required this.age,
required this.email,
this.timestamp = 0,
this.contentType = ContentType.text,
}) {
this.timestamp = Timestamp.now().microsecondsSinceEpoch; //Timestamp.now() nanoseconds.toString();
}
String name;
final String email;
int timestamp;
final contentType;
@Min(0)
final int age;
}
@Collection<TestUser>('test_users')
final testUsersRef = TestUserCollectionReference();
[...]
testUsersRef.whereContentType(isEqualTo: ContentType.text); // Doesn't work
Additional context
As a quick effort, I attempted to add f.isEnumConstant to collection_generator.dart just to see if it would attempt to produce some code, but didn't:
queryableFields: collectionTargetElement.fields
.where((f) => f.isPublic)
.where(
(f) =>
f.type.isDartCoreString ||
f.type.isDartCoreNum ||
f.type.isDartCoreInt ||
f.type.isDartCoreDouble ||
f.type.isDartCoreBool ||
f.type.isDartCoreList ||
f.isEnumConstant, // ADDED to Test Enums
// TODO filter list other than LIst<string|bool|num>
)
.toList(),
Flutter doctor
Run flutter doctor and paste the output below:
Click To Expand
flutter doctor
Doctor summary (to see all details, run flutter doctor -v):
[√] Flutter (Channel stable, 2.10.3, on Microsoft Windows [Version 10.0.19044.1586], locale en-US)
[√] Android toolchain - develop for Android devices (Android SDK version 32.0.0-rc1)
[√] Chrome - develop for the web
[√] Visual Studio - develop for Windows (Visual Studio Community 2022 17.1.1)
[√] Android Studio (version 2021.1)
[!] Android Studio
X android-studio-dir = C:\Users\mark\AppData\Local\JetBrains\Toolbox\apps\AndroidStudio
X Unable to find bundled Java version.
[√] IntelliJ IDEA Ultimate Edition (version 2021.3)
[√] Connected device (4 available)
[√] HTTP Host Availability
Flutter dependencies
Run flutter pub deps -- --style=compact and paste the output below:
Bug report
When having a field with a type enum, the ODM generator automagically produces code to store or retrieve the values (technically as a String), however it does not create the .whereEnumField and .orderEnumField code. It is my assumption this is supposed to work because it will store/retrieve the enums.
Steps to reproduce
Steps to reproduce the behavior:
Expected behavior
A method .whereMyEnum should be created for each enum field.
Sample project
[...]
testUsersRef.whereContentType(isEqualTo: ContentType.text); // Doesn't work
Additional context
As a quick effort, I attempted to add f.isEnumConstant to collection_generator.dart just to see if it would attempt to produce some code, but didn't:
Flutter doctor
Run
flutter doctor
and paste the output below:Click To Expand
Flutter dependencies
Run
flutter pub deps -- --style=compact
and paste the output below:Click To Expand
The text was updated successfully, but these errors were encountered: