velocious 1.0.615 → 1.0.617

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1307,26 +1307,33 @@ export default class TestRunner {
1307
1307
  })
1308
1308
  } finally {
1309
1309
  try {
1310
- if (testSharedConnectionsActive) {
1311
- this.clearTestSharedConnections(testSharedConnectionRegistrations)
1312
- testSharedConnectionRegistrations = []
1313
- testSharedConnectionsActive = false
1314
- }
1310
+ // Framework-owned post-commit broadcasts are intentionally
1311
+ // detached; drain them before test cleanup so their DB
1312
+ // checkouts cannot leak into the next test's lifecycle.
1313
+ await this.getConfiguration().awaitPendingBroadcasts()
1315
1314
  } finally {
1316
1315
  try {
1317
- await this.stopSharedTransactionBroker(sharedTransactionBrokerRegistration || sharedTransactionBrokerPreparation)
1318
- sharedTransactionBrokerRegistration = undefined
1319
- sharedTransactionBrokerPreparation = undefined
1316
+ if (testSharedConnectionsActive) {
1317
+ this.clearTestSharedConnections(testSharedConnectionRegistrations)
1318
+ testSharedConnectionRegistrations = []
1319
+ testSharedConnectionsActive = false
1320
+ }
1320
1321
  } finally {
1321
- for (const afterEachData of newAfterEaches) {
1322
- await this.runProfileSpan({
1323
- phase: "afterEach",
1324
- declarationIndex: afterEachData.declarationIndex,
1325
- declarationScopeId: afterEachData.declarationScopeId,
1326
- filePath: afterEachData.ownerFilePath
1327
- }, async () => {
1328
- await afterEachData.callback({configuration: this.getConfiguration(), testArgs, testData})
1329
- })
1322
+ try {
1323
+ await this.stopSharedTransactionBroker(sharedTransactionBrokerRegistration || sharedTransactionBrokerPreparation)
1324
+ sharedTransactionBrokerRegistration = undefined
1325
+ sharedTransactionBrokerPreparation = undefined
1326
+ } finally {
1327
+ for (const afterEachData of newAfterEaches) {
1328
+ await this.runProfileSpan({
1329
+ phase: "afterEach",
1330
+ declarationIndex: afterEachData.declarationIndex,
1331
+ declarationScopeId: afterEachData.declarationScopeId,
1332
+ filePath: afterEachData.ownerFilePath
1333
+ }, async () => {
1334
+ await afterEachData.callback({configuration: this.getConfiguration(), testArgs, testData})
1335
+ })
1336
+ }
1330
1337
  }
1331
1338
  }
1332
1339
  }
package/package.json CHANGED
@@ -3,7 +3,7 @@
3
3
  "velocious": "build/bin/velocious.js"
4
4
  },
5
5
  "name": "velocious",
6
- "version": "1.0.615",
6
+ "version": "1.0.617",
7
7
  "main": "build/index.js",
8
8
  "types": "build/index.d.ts",
9
9
  "files": [
@@ -3992,6 +3992,20 @@ class VelociousDatabaseRecord {
3992
3992
  } else {
3993
3993
  throw new Error(`Unexpected loaded type: ${typeof loadedModels}`)
3994
3994
  }
3995
+ } else if (instanceRelationship.getType() == "hasOne") {
3996
+ if (!instanceRelationship.isLoaded()) {
3997
+ await instanceRelationship.load()
3998
+ }
3999
+
4000
+ const loadedModel = instanceRelationship.loaded()
4001
+
4002
+ if (loadedModel instanceof VelociousDatabaseRecord) {
4003
+ models = [loadedModel]
4004
+ } else if (loadedModel === undefined) {
4005
+ models = []
4006
+ } else {
4007
+ throw new Error(`Unexpected loaded type: ${typeof loadedModel}`)
4008
+ }
3995
4009
  } else {
3996
4010
  throw new Error(`Unhandled relationship type: ${instanceRelationship.getType()}`)
3997
4011
  }
@@ -66,6 +66,12 @@ export default class VelociousDatabaseRecordHasOneInstanceRelationship extends B
66
66
 
67
67
  whereArgs[foreignKey] = primaryModelID
68
68
 
69
+ if (this.getRelationship().getPolymorphic()) {
70
+ const typeColumn = this.getRelationship().getPolymorphicTypeColumn()
71
+
72
+ whereArgs[typeColumn] = this.getModel().getModelClass().getModelName()
73
+ }
74
+
69
75
  let query = this.getModel().queryForModel(TargetModelClass).where(whereArgs)
70
76
 
71
77
  query = this.applyScope(query)
@@ -1307,26 +1307,33 @@ export default class TestRunner {
1307
1307
  })
1308
1308
  } finally {
1309
1309
  try {
1310
- if (testSharedConnectionsActive) {
1311
- this.clearTestSharedConnections(testSharedConnectionRegistrations)
1312
- testSharedConnectionRegistrations = []
1313
- testSharedConnectionsActive = false
1314
- }
1310
+ // Framework-owned post-commit broadcasts are intentionally
1311
+ // detached; drain them before test cleanup so their DB
1312
+ // checkouts cannot leak into the next test's lifecycle.
1313
+ await this.getConfiguration().awaitPendingBroadcasts()
1315
1314
  } finally {
1316
1315
  try {
1317
- await this.stopSharedTransactionBroker(sharedTransactionBrokerRegistration || sharedTransactionBrokerPreparation)
1318
- sharedTransactionBrokerRegistration = undefined
1319
- sharedTransactionBrokerPreparation = undefined
1316
+ if (testSharedConnectionsActive) {
1317
+ this.clearTestSharedConnections(testSharedConnectionRegistrations)
1318
+ testSharedConnectionRegistrations = []
1319
+ testSharedConnectionsActive = false
1320
+ }
1320
1321
  } finally {
1321
- for (const afterEachData of newAfterEaches) {
1322
- await this.runProfileSpan({
1323
- phase: "afterEach",
1324
- declarationIndex: afterEachData.declarationIndex,
1325
- declarationScopeId: afterEachData.declarationScopeId,
1326
- filePath: afterEachData.ownerFilePath
1327
- }, async () => {
1328
- await afterEachData.callback({configuration: this.getConfiguration(), testArgs, testData})
1329
- })
1322
+ try {
1323
+ await this.stopSharedTransactionBroker(sharedTransactionBrokerRegistration || sharedTransactionBrokerPreparation)
1324
+ sharedTransactionBrokerRegistration = undefined
1325
+ sharedTransactionBrokerPreparation = undefined
1326
+ } finally {
1327
+ for (const afterEachData of newAfterEaches) {
1328
+ await this.runProfileSpan({
1329
+ phase: "afterEach",
1330
+ declarationIndex: afterEachData.declarationIndex,
1331
+ declarationScopeId: afterEachData.declarationScopeId,
1332
+ filePath: afterEachData.ownerFilePath
1333
+ }, async () => {
1334
+ await afterEachData.callback({configuration: this.getConfiguration(), testArgs, testData})
1335
+ })
1336
+ }
1330
1337
  }
1331
1338
  }
1332
1339
  }