Skip to content

Commit 83faf79

Browse files
committed
Merge pull request #366 from mmbsoftware-it:main
PiperOrigin-RevId: 754997846 Change-Id: I1c9929176740815b03bea6afef3cc8ac7b074ae7
2 parents 63b28af + f220f12 commit 83faf79

File tree

3 files changed

+17
-37
lines changed

3 files changed

+17
-37
lines changed

api/src/main/java/com/google/appengine/api/datastore/PreparedQueryImpl.java

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -36,11 +36,6 @@ public PreparedQueryImpl(Query query, Transaction txn, QueryRunner queryRunner)
3636
this.txn = txn;
3737
this.queryRunner = queryRunner;
3838

39-
// TODO Move this check and the one that follows into the
40-
// LocalDatastoreService (it may already be there).
41-
checkArgument(
42-
txn == null || query.getAncestor() != null,
43-
"Only ancestor queries are allowed inside transactions.");
4439
TransactionImpl.ensureTxnActive(txn);
4540
}
4641

api/src/main/java/com/google/appengine/api/datastore/ValidatedQuery.java

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -93,13 +93,6 @@ private void validateQuery() {
9393
}
9494
}
9595

96-
// Transaction requires ancestor
97-
if (query.hasTransaction() && !query.hasAncestor()) {
98-
throw new IllegalQueryException(
99-
"Only ancestor queries are allowed inside transactions.",
100-
IllegalQueryType.TRANSACTION_REQUIRES_ANCESTOR);
101-
}
102-
10396
// Filters and sort orders require kind.
10497
if (!query.hasKind()) {
10598
for (Filter filter : query.filters()) {

api_dev/src/main/java/com/google/appengine/api/datastore/dev/LocalDatastoreService.java

Lines changed: 17 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1207,29 +1207,23 @@ public QueryResult runQuery(Status status, Query query) {
12071207
String app = query.getApp();
12081208
Profile profile = getOrCreateProfile(app);
12091209

1210-
// The real datastore supports executing ancestor queries in transactions.
1211-
// For now we're just going to make sure the entity group of the ancestor
1212-
// is the same entity group with which the transaction is associated and
1213-
// skip providing a transactionally consistent result set.
1214-
12151210
synchronized (profile) {
1216-
// Having a transaction implies we have an ancestor, but having an
1217-
// ancestor does not imply we have a transaction.
1218-
if (query.hasTransaction() || query.hasAncestor()) {
1219-
// Query can only have a txn if it is an ancestor query. Either way we
1220-
// know we've got an ancestor.
1211+
1212+
if (query.hasTransaction()) {
1213+
if (!app.equals(query.getTransaction().getApp())) {
1214+
throw newError(
1215+
ErrorCode.INTERNAL_ERROR,
1216+
"Can't query app "
1217+
+ app
1218+
+ "in a transaction on app "
1219+
+ query.getTransaction().getApp());
1220+
}
1221+
}
1222+
1223+
if (query.hasAncestor()) {
12211224
Path groupPath = getGroup(query.getAncestor());
12221225
Profile.EntityGroup eg = profile.getGroup(groupPath);
12231226
if (query.hasTransaction()) {
1224-
if (!app.equals(query.getTransaction().getApp())) {
1225-
throw newError(
1226-
ErrorCode.INTERNAL_ERROR,
1227-
"Can't query app "
1228-
+ app
1229-
+ "in a transaction on app "
1230-
+ query.getTransaction().getApp());
1231-
}
1232-
12331227
LiveTxn liveTxn = profile.getTxn(query.getTransaction().getHandle());
12341228
// this will throw an exception if we attempt to read from
12351229
// the wrong entity group
@@ -1238,12 +1232,10 @@ public QueryResult runQuery(Status status, Query query) {
12381232
profile = eg.getSnapshot(liveTxn);
12391233
}
12401234

1241-
if (query.hasAncestor()) {
1242-
if (query.hasTransaction() || !query.hasFailoverMs()) {
1243-
// Either we have a transaction or the user has requested strongly
1244-
// consistent results. Either way, we need to apply jobs.
1245-
eg.rollForwardUnappliedJobs();
1246-
}
1235+
if (query.hasTransaction() || !query.hasFailoverMs()) {
1236+
// Either we have a transaction or the user has requested strongly
1237+
// consistent results. Either way, we need to apply jobs.
1238+
eg.rollForwardUnappliedJobs();
12471239
}
12481240
}
12491241

0 commit comments

Comments
 (0)