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

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

Issue 774213002: Bugfix in ListProperty(), correctly handle list values of length 1 (Closed) Base URL: git@github.com:dart-lang/gcloud.git@master
Patch Set: Added entry in CHANGELOG.md Created 6 years 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 | « CHANGELOG.md ('k') | test/db/properties_test.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 b1f0f6b5a8bf9684a53feb5cf1cd3de0b2e56da1..e158ad531947da7135c55a163d03e5824a2ce22f 100644
--- a/lib/src/db/annotations.dart
+++ b/lib/src/db/annotations.dart
@@ -258,14 +258,14 @@ class ListProperty extends Property {
if (value == null) return null;
List list = value;
if (list.length == 0) return null;
- if (list.length == 1) return list[0];
+ if (list.length == 1) return subProperty.encodeValue(db, list[0]);
return list.map(
(value) => subProperty.encodeValue(db, value)).toList();
}
Object decodePrimitiveValue(ModelDB db, Object value) {
if (value == null) return [];
- if (value is! List) return [value];
+ if (value is! List) return [subProperty.decodePrimitiveValue(db, value)];
return (value as List)
.map((entry) => subProperty.decodePrimitiveValue(db, entry))
.toList();
« no previous file with comments | « CHANGELOG.md ('k') | test/db/properties_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698