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

Side by Side Diff: lib/src/db/db.dart

Issue 943663002: Bugfix in sanity check: Prevent null-dereference (Closed) Base URL: git@github.com:dart-lang/gcloud.git@master
Patch Set: Created 5 years, 10 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 unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 part of gcloud.db; 5 part of gcloud.db;
6 6
7 /** 7 /**
8 * A function definition for transactional functions. 8 * A function definition for transactional functions.
9 * 9 *
10 * The function will be given a [Transaction] object which can be used to make 10 * The function will be given a [Transaction] object which can be used to make
(...skipping 297 matching lines...) Expand 10 before | Expand all | Expand 10 after
308 // TODO(#26): There is only one case where `partition` is not redundant 308 // TODO(#26): There is only one case where `partition` is not redundant
309 // Namely if `ancestorKey == null` and `partition != null`. We could 309 // Namely if `ancestorKey == null` and `partition != null`. We could
310 // say we get rid of `partition` and enforce `ancestorKey` to 310 // say we get rid of `partition` and enforce `ancestorKey` to
311 // be `Partition.emptyKey`? 311 // be `Partition.emptyKey`?
312 if (partition == null) { 312 if (partition == null) {
313 if (ancestorKey != null) { 313 if (ancestorKey != null) {
314 partition = ancestorKey.partition; 314 partition = ancestorKey.partition;
315 } else { 315 } else {
316 partition = defaultPartition; 316 partition = defaultPartition;
317 } 317 }
318 } else if (partition != ancestorKey.partition) { 318 } else if (ancestorKey != null && partition != ancestorKey.partition) {
319 throw new ArgumentError( 319 throw new ArgumentError(
320 'Ancestor queries must have the same partition in the ancestor key ' 320 'Ancestor queries must have the same partition in the ancestor key '
321 'as the partition where the query executes in.'); 321 'as the partition where the query executes in.');
322 } 322 }
323 return new Query(this, 323 return new Query(this,
324 kind, 324 kind,
325 partition: partition, 325 partition: partition,
326 ancestorKey: ancestorKey); 326 ancestorKey: ancestorKey);
327 } 327 }
328 328
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
397 397
398 Future<List<Model>> _lookupHelper( 398 Future<List<Model>> _lookupHelper(
399 DatastoreDB db, List<Key> keys, 399 DatastoreDB db, List<Key> keys,
400 {datastore.Transaction datastoreTransaction}) { 400 {datastore.Transaction datastoreTransaction}) {
401 var entityKeys = keys.map(db.modelDB.toDatastoreKey).toList(); 401 var entityKeys = keys.map(db.modelDB.toDatastoreKey).toList();
402 return db.datastore.lookup(entityKeys, transaction: datastoreTransaction) 402 return db.datastore.lookup(entityKeys, transaction: datastoreTransaction)
403 .then((List<datastore.Entity> entities) { 403 .then((List<datastore.Entity> entities) {
404 return entities.map(db.modelDB.fromDatastoreEntity).toList(); 404 return entities.map(db.modelDB.fromDatastoreEntity).toList();
405 }); 405 });
406 } 406 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698