Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(516)

Unified Diff: lib/src/db/annotations.dart

Issue 2731933004: Remove FilterRelation.In / "property IN" queries, upgrade googleapis{,_beta} dependencies (Closed)
Patch Set: add pubspec.yaml update Created 3 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « lib/src/datastore_impl.dart ('k') | lib/src/db/db.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: lib/src/db/annotations.dart
diff --git a/lib/src/db/annotations.dart b/lib/src/db/annotations.dart
index e158ad531947da7135c55a163d03e5824a2ce22f..276f87f8cd18b7118a18b505a56b755ffcc62ad9 100644
--- a/lib/src/db/annotations.dart
+++ b/lib/src/db/annotations.dart
@@ -88,7 +88,7 @@ abstract class Property {
return true;
}
- Object encodeValue(ModelDB db, Object value);
+ Object encodeValue(ModelDB db, Object value, {bool forComparison: false});
Object decodePrimitiveValue(ModelDB db, Object value);
}
@@ -100,7 +100,7 @@ abstract class PrimitiveProperty extends Property {
{String propertyName, bool required: false, bool indexed: true})
: super(propertyName: propertyName, required: required, indexed: indexed);
- Object encodeValue(ModelDB db, Object value) => value;
+ Object encodeValue(ModelDB db, Object value, {bool forComparison: false}) => value;
Object decodePrimitiveValue(ModelDB db, Object value) => value;
}
@@ -169,7 +169,7 @@ class ModelKeyProperty extends PrimitiveProperty {
bool validate(ModelDB db, Object value)
=> super.validate(db, value) && (value == null || value is Key);
- Object encodeValue(ModelDB db, Object value) {
+ Object encodeValue(ModelDB db, Object value, {bool forComparison: false}) {
if (value == null) return null;
return db.toDatastoreKey(value);
}
@@ -196,7 +196,7 @@ class BlobProperty extends PrimitiveProperty {
bool validate(ModelDB db, Object value)
=> super.validate(db, value) && (value == null || value is List<int>);
- Object encodeValue(ModelDB db, Object value) {
+ Object encodeValue(ModelDB db, Object value, {bool forComparison: false}) {
if (value == null) return null;
return new datastore.BlobValue(value);
}
@@ -254,7 +254,28 @@ class ListProperty extends Property {
return true;
}
- Object encodeValue(ModelDB db, Object value) {
+ Object encodeValue(ModelDB db, Object value, {bool forComparison: false}) {
+ if (forComparison) {
+ // If we have comparison of list properties (i.e. repeated property names)
+ // the comparison object must not be a list, but the value itself.
+ // i.e.
+ //
+ // class Article {
+ // ...
+ // @ListProperty(StringProperty())
+ // List<String> tags;
+ // ...
+ // }
+ //
+ // should be queried via
+ //
+ // await db.query(Article, 'tags=', "Dart").toList();
+ //
+ // So the [value] for the comparison is of type `String` and not
+ // `List<String>`!
+ return subProperty.encodeValue(db, value, forComparison: true);
+ }
+
if (value == null) return null;
List list = value;
if (list.length == 0) return null;
« no previous file with comments | « lib/src/datastore_impl.dart ('k') | lib/src/db/db.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698