velocious 1.0.68 → 1.0.70

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.
package/package.json CHANGED
@@ -3,7 +3,7 @@
3
3
  "velocious": "bin/velocious.js"
4
4
  },
5
5
  "name": "velocious",
6
- "version": "1.0.68",
6
+ "version": "1.0.70",
7
7
  "main": "index.js",
8
8
  "scripts": {
9
9
  "test": "VELOCIOUS_TEST_DIR=../ cd spec/dummy && npx velocious test",
@@ -115,10 +115,7 @@ export default class VelociousDatabaseDriversMssql extends Base{
115
115
  return result.recordsets[0]
116
116
  }
117
117
 
118
- queryToSql(query) {
119
- return new QueryParser({query}).toSql()
120
- }
121
-
118
+ queryToSql(query) { return new QueryParser({query}).toSql() }
122
119
  shouldSetAutoIncrementWhenPrimaryKey() { return true }
123
120
 
124
121
  escape(value) {
@@ -103,10 +103,7 @@ export default class VelociousDatabaseDriversMysql extends Base{
103
103
  }
104
104
  }
105
105
 
106
- queryToSql(query) {
107
- return new QueryParser({query}).toSql()
108
- }
109
-
106
+ queryToSql(query) { return new QueryParser({query}).toSql() }
110
107
  shouldSetAutoIncrementWhenPrimaryKey() { return true }
111
108
 
112
109
  escape(value) {
@@ -114,10 +114,7 @@ export default class VelociousDatabaseDriversPgsql extends Base{
114
114
  return response.rows
115
115
  }
116
116
 
117
- queryToSql(query) {
118
- return new QueryParser({query}).toSql()
119
- }
120
-
117
+ queryToSql(query) { return new QueryParser({query}).toSql() }
121
118
  shouldSetAutoIncrementWhenPrimaryKey() { return true }
122
119
 
123
120
  escape(value) {
@@ -192,7 +192,7 @@ export default class VelociousDatabaseDriversSqliteBase extends Base {
192
192
  try {
193
193
  return await this._queryActual(sql)
194
194
  } catch (error) {
195
- if (tries < 5 && error.message.includes("attempt to write a readonly database")) {
195
+ if (tries < 5 && this._retryableDatabaseError(error)) {
196
196
  await wait(100)
197
197
  this.logger.warn(`Retrying query because failed with: ${error.stack}`)
198
198
  // Retry
@@ -203,6 +203,13 @@ export default class VelociousDatabaseDriversSqliteBase extends Base {
203
203
  }
204
204
  }
205
205
 
206
+ _retryableDatabaseError(error) {
207
+ if (error.message?.includes("attempt to write a readonly database")) return true
208
+ if (this.getType() == "sqlite" && error.message?.startsWith("SQLITE_BUSY: database is locked")) return true
209
+
210
+ return false
211
+ }
212
+
206
213
  quote(value) {
207
214
  value = this._convertValue(value)
208
215
 
@@ -13,7 +13,7 @@ export default class VelociousDatabaseDriversSqliteConnectionSqlJs {
13
13
  this.connection = undefined
14
14
  }
15
15
 
16
- disconnect = async () => await this.saveDatabase()
16
+ async disconnect() { await this.saveDatabase() }
17
17
 
18
18
  async query(sql) {
19
19
  const result = await query(this.connection, sql)
@@ -569,7 +569,13 @@ class VelociousDatabaseRecord {
569
569
  }
570
570
 
571
571
  static async transaction(callback) {
572
- return await this.connection().transaction(callback)
572
+ const useTransactions = this.connection().getConfiguration().record?.transactions
573
+
574
+ if (useTransactions !== false) {
575
+ await this.connection().transaction(callback)
576
+ } else {
577
+ return await callback()
578
+ }
573
579
  }
574
580
 
575
581
  static translates(...names) {