fix(transaction): Trigger changes only after COMMIT has been executed

- Fixes #1327
- This caused the dataase query inside QuerySubscription to, on occassion,
  return stale results from the database because the database hadn't
  finished writing. This consequently caused the QuerySubscription to
  build and incorrect result set.
This commit is contained in:
Juan Tejada 2016-02-19 13:24:04 -08:00
parent fe7a894e51
commit 0f2249ffa7

View file

@ -27,11 +27,11 @@ class DatabaseTransaction
fn(@)
.finally =>
if @_opened
@_query("COMMIT")
@_opened = false
global.setImmediate =>
for record in @_changeRecords
@database.accumulateAndTrigger(record)
@_query("COMMIT")
.then =>
for record in @_changeRecords
@database.accumulateAndTrigger(record)
# Mutating the Database