orange-orm 4.5.0 → 4.5.1-beta.1

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.
Files changed (53) hide show
  1. package/README.md +10 -10
  2. package/{src/client/index.mjs → dist/index.browser.mjs} +30 -9
  3. package/dist/index.mjs +20001 -0
  4. package/package.json +14 -4
  5. package/src/bunPg/newDatabase.js +137 -0
  6. package/src/bunPg/newPool.js +19 -0
  7. package/src/bunPg/pool/end.js +13 -0
  8. package/src/bunPg/pool/newPgPool.js +98 -0
  9. package/src/bunPg/wrapQuery.js +33 -0
  10. package/src/bunSqlite/newPool.js +19 -0
  11. package/src/bunSqlite/newTransaction.js +83 -0
  12. package/src/bunSqlite/pool/newGenericPool.js +55 -0
  13. package/src/bunSqlite/wrapQuery.js +23 -0
  14. package/src/index.js +16 -3
  15. package/src/merge-browser.js +9 -0
  16. package/src/merge-server.js +9 -0
  17. package/src/mssql/pool/newGenericPool.js +9 -2
  18. package/src/mySql/pool/newGenericPool.js +11 -2
  19. package/src/nodeSqlite/decodeBinary.js +9 -0
  20. package/src/nodeSqlite/encodeBinary.js +20 -0
  21. package/src/nodeSqlite/newDatabase.js +116 -0
  22. package/src/nodeSqlite/newPool.js +19 -0
  23. package/src/nodeSqlite/newTransaction.js +87 -0
  24. package/src/nodeSqlite/pool/newGenericPool.js +50 -0
  25. package/src/nodeSqlite/wrapQuery.js +23 -0
  26. package/src/oracle/pool/newGenericPool.js +13 -5
  27. package/src/pg/newDatabase.js +0 -5
  28. package/src/pg/pool/newPgPool.js +15 -3
  29. package/src/{client/rollup.config.js → rollup.config.browser.js} +1 -1
  30. package/src/rollup.config.server.js +32 -0
  31. package/src/runtimes.js +24 -0
  32. package/src/sqlite3/deleteFromSql.js +10 -0
  33. package/src/sqlite3/encodeBoolean.js +7 -0
  34. package/src/sqlite3/encodeBuffer.js +7 -0
  35. package/src/sqlite3/insert.js +21 -0
  36. package/src/sqlite3/insertSql.js +67 -0
  37. package/src/sqlite3/lastInsertedSql.js +12 -0
  38. package/src/sqlite3/limitAndOffset.js +18 -0
  39. package/src/sqlite3/newDatabase.js +116 -0
  40. package/src/sqlite3/newTransaction.js +83 -0
  41. package/src/sqlite3/pool/end.js +13 -0
  42. package/src/{sqlite → sqlite3}/pool/newGenericPool.js +10 -2
  43. package/src/sqlite3/quote.js +1 -0
  44. package/src/sqlite3/selectForUpdateSql.js +5 -0
  45. package/src/table/column/binary/newDecode.js +13 -2
  46. package/src/table/column/binary/newEncode.js +16 -6
  47. package/src/table/resultToRows/newDecodeDbRow.js +1 -1
  48. package/src/tedious/pool/newGenericPool.js +8 -2
  49. package/src/tedious/wrapQuery.js +40 -17
  50. package/src/client/merge.js +0 -9
  51. /package/src/{sqlite → bunSqlite}/newDatabase.js +0 -0
  52. /package/src/{sqlite → sqlite3}/newPool.js +0 -0
  53. /package/src/{sqlite → sqlite3}/wrapQuery.js +0 -0
@@ -0,0 +1,116 @@
1
+ let createDomain = require('../createDomain');
2
+ let newTransaction = require('./newTransaction');
3
+ let _begin = require('../table/begin');
4
+ let commit = require('../table/commit');
5
+ let rollback = require('../table/rollback');
6
+ let newPool = require('./newPool');
7
+ let express = require('../hostExpress');
8
+ let hostLocal = require('../hostLocal');
9
+ let doQuery = require('../query');
10
+ let releaseDbClient = require('../table/releaseDbClient');
11
+ let setSessionSingleton = require('../table/setSessionSingleton');
12
+
13
+ function newDatabase(connectionString, poolOptions) {
14
+ if (!connectionString)
15
+ throw new Error('Connection string cannot be empty');
16
+ var pool;
17
+ if (!poolOptions)
18
+ pool = newPool.bind(null,connectionString, poolOptions);
19
+ else
20
+ pool = newPool(connectionString, poolOptions);
21
+
22
+ let c = {poolFactory: pool, hostLocal, express};
23
+
24
+ c.transaction = function(options, fn) {
25
+ if ((arguments.length === 1) && (typeof options === 'function')) {
26
+ fn = options;
27
+ options = undefined;
28
+ }
29
+ let domain = createDomain();
30
+
31
+ if (fn)
32
+ return domain.run(runInTransaction);
33
+ else
34
+ return domain.run(run);
35
+
36
+ function begin() {
37
+ return _begin(domain, options);
38
+ }
39
+
40
+ async function runInTransaction() {
41
+ let result;
42
+ let transaction = newTransaction(domain, pool, options);
43
+ await new Promise(transaction)
44
+ .then(begin)
45
+ .then(() => fn(domain))
46
+ .then((res) => result = res)
47
+ .then(() => commit(domain))
48
+ .then(null, (e) => rollback(domain, e));
49
+ return result;
50
+ }
51
+
52
+ function run() {
53
+ let p;
54
+ let transaction = newTransaction(domain, pool, options);
55
+ p = new Promise(transaction);
56
+
57
+ return p.then(begin);
58
+ }
59
+
60
+ };
61
+
62
+ c.createTransaction = function(options) {
63
+ let domain = createDomain();
64
+ let transaction = newTransaction(domain, pool);
65
+ let p = domain.run(() => new Promise(transaction).then(begin));
66
+
67
+ function run(fn) {
68
+ return p.then(() => fn(domain));
69
+ }
70
+ run.rollback = rollback.bind(null, domain);
71
+ run.commit = commit.bind(null, domain);
72
+ return run;
73
+
74
+ function begin() {
75
+ return _begin(domain, options);
76
+ }
77
+ };
78
+
79
+ c.query = function(query) {
80
+ let domain = createDomain();
81
+ let transaction = newTransaction(domain, pool);
82
+ let p = domain.run(() => new Promise(transaction)
83
+ .then(() => setSessionSingleton(domain, 'changes', []))
84
+ .then(() => doQuery(domain, query).then(onResult, onError)));
85
+ return p;
86
+
87
+ function onResult(result) {
88
+ releaseDbClient(domain);
89
+ return result;
90
+ }
91
+
92
+ function onError(e) {
93
+ releaseDbClient(domain);
94
+ throw e;
95
+ }
96
+ };
97
+
98
+
99
+ c.rollback = rollback;
100
+ c.commit = commit;
101
+
102
+ c.end = function() {
103
+ if (poolOptions)
104
+ return pool.end();
105
+ else
106
+ return Promise.resolve();
107
+ };
108
+
109
+ c.accept = function(caller) {
110
+ caller.visitSqlite();
111
+ };
112
+
113
+ return c;
114
+ }
115
+
116
+ module.exports = newDatabase;
@@ -0,0 +1,19 @@
1
+ const promisify = require('../promisify');
2
+ const pools = require('../pools');
3
+ const end = require('../sqlite/pool/end');
4
+ const newGenericPool = require('./pool/newGenericPool');
5
+ const newId = require('../newId');
6
+
7
+ function newPool(connectionString, poolOptions) {
8
+ let pool = newGenericPool(connectionString, poolOptions);
9
+ let id = newId();
10
+ let boundEnd = end.bind(null, pool, id);
11
+ let c = {};
12
+
13
+ c.connect = pool.connect;
14
+ c.end = promisify(boundEnd);
15
+ pools[id] = c;
16
+ return c;
17
+ }
18
+
19
+ module.exports = newPool;
@@ -0,0 +1,87 @@
1
+ const wrapQuery = require('./wrapQuery');
2
+ const encodeBoolean = require('../sqlite/encodeBoolean');
3
+ const encodeBinary = require('./encodeBinary');
4
+ const decodeBinary = require('./decodeBinary');
5
+ const deleteFromSql = require('../sqlite/deleteFromSql');
6
+ const selectForUpdateSql = require('../sqlite/selectForUpdateSql');
7
+ const lastInsertedSql = require('../sqlite/lastInsertedSql');
8
+ const limitAndOffset = require('../sqlite/limitAndOffset');
9
+ const insertSql = require('../sqlite/insertSql');
10
+ const insert = require('../sqlite/insert');
11
+ const quote = require('../sqlite/quote');
12
+
13
+ function newResolveTransaction(domain, pool, { readonly = false } = {}) {
14
+ var rdb = {poolFactory: pool};
15
+ if (!pool.connect) {
16
+ pool = pool();
17
+ rdb.pool = pool;
18
+ }
19
+ rdb.engine = 'sqlite';
20
+ rdb.encodeBoolean = encodeBoolean;
21
+ rdb.encodeBinary = encodeBinary;
22
+ rdb.decodeBinary = decodeBinary;
23
+ rdb.decodeJSON = decodeJSON;
24
+ rdb.encodeJSON = JSON.stringify;
25
+ rdb.deleteFromSql = deleteFromSql;
26
+ rdb.selectForUpdateSql = selectForUpdateSql;
27
+ rdb.lastInsertedSql = lastInsertedSql;
28
+ rdb.insertSql = insertSql;
29
+ rdb.insert = insert;
30
+ rdb.lastInsertedIsSeparate = true;
31
+ rdb.multipleStatements = false;
32
+ rdb.limitAndOffset = limitAndOffset;
33
+ rdb.accept = function(caller) {
34
+ caller.visitSqlite();
35
+ };
36
+ rdb.aggregateCount = 0;
37
+ rdb.quote = quote;
38
+
39
+ if (readonly) {
40
+ rdb.dbClient = {
41
+ executeQuery: function(query, callback) {
42
+ pool.connect((err, client, done) => {
43
+ if (err) {
44
+ return callback(err);
45
+ }
46
+ try {
47
+ wrapQuery(client)(query, (err, res) => {
48
+ done();
49
+ callback(err, res);
50
+ });
51
+ } catch (e) {
52
+ done();
53
+ callback(e);
54
+ }
55
+ });
56
+ }
57
+ };
58
+ domain.rdb = rdb;
59
+ return (onSuccess) => onSuccess();
60
+ }
61
+
62
+ return function(onSuccess, onError) {
63
+ pool.connect(onConnected);
64
+
65
+ function onConnected(err, client, done) {
66
+ try {
67
+ if (err) {
68
+ onError(err);
69
+ return;
70
+ }
71
+ client.executeQuery = wrapQuery(client);
72
+ rdb.dbClient = client;
73
+ rdb.dbClientDone = done;
74
+ domain.rdb = rdb;
75
+ onSuccess();
76
+ } catch (e) {
77
+ onError(e);
78
+ }
79
+ }
80
+ };
81
+ }
82
+
83
+ function decodeJSON(value) {
84
+ return JSON.parse(value);
85
+ }
86
+
87
+ module.exports = newResolveTransaction;
@@ -0,0 +1,50 @@
1
+ /* eslint-disable no-prototype-builtins */
2
+ var defaults = require('../../poolDefaults');
3
+
4
+ var genericPool = require('../../generic-pool');
5
+ var sqlite;
6
+
7
+ function newGenericPool(connectionString, poolOptions) {
8
+
9
+ poolOptions = poolOptions || {};
10
+ var pool = genericPool.Pool({
11
+ max: poolOptions.size || poolOptions.poolSize || defaults.poolSize,
12
+ idleTimeoutMillis: poolOptions.idleTimeout || defaults.poolIdleTimeout,
13
+ reapIntervalMillis: poolOptions.reapIntervalMillis || defaults.reapIntervalMillis,
14
+ log: poolOptions.log || defaults.poolLog,
15
+ create: async function(cb) {
16
+ try {
17
+ if (!sqlite)
18
+ sqlite = await import('node:sqlite');
19
+ var client = new sqlite.DatabaseSync(connectionString);
20
+ client.poolCount = 0;
21
+ cb(null, client);
22
+ }
23
+ catch(err) {
24
+ return cb(err, null);
25
+ }
26
+ },
27
+
28
+ destroy: function(client) {
29
+ client.poolCount = undefined;
30
+ client.close();
31
+ }
32
+ });
33
+ //monkey-patch with connect method
34
+ pool.connect = function(cb) {
35
+ pool.acquire(function(err, client) {
36
+ if(err) return cb(err, null, function() {/*NOOP*/});
37
+ client.poolCount++;
38
+ cb(null, client, function(err) {
39
+ if(err) {
40
+ pool.destroy(client);
41
+ } else {
42
+ pool.release(client);
43
+ }
44
+ });
45
+ });
46
+ };
47
+ return pool;
48
+ }
49
+
50
+ module.exports = newGenericPool;
@@ -0,0 +1,23 @@
1
+ var log = require('../table/log');
2
+
3
+ function wrapQuery(connection) {
4
+ return runQuery;
5
+
6
+ function runQuery(query, onCompleted) {
7
+ try {
8
+ var params = query.parameters;
9
+ var sql = query.sql();
10
+ log.emitQuery({ sql, parameters: params });
11
+
12
+ var statement = connection.prepare(sql);
13
+ const rows = statement.all.apply(statement, params);
14
+ onCompleted(null, rows);
15
+ }
16
+ catch (e) {
17
+ onCompleted(e);
18
+ }
19
+ }
20
+
21
+ }
22
+
23
+ module.exports = wrapQuery;
@@ -3,10 +3,7 @@
3
3
 
4
4
  var defaults = require('../../poolDefaults');
5
5
  var genericPool = require('../../generic-pool');
6
- var oracle = require('oracledb');
7
-
8
- oracle.outFormat = oracle.OUT_FORMAT_OBJECT;
9
- oracle.fetchAsBuffer = [ oracle.BLOB ];
6
+ var oracle;
10
7
 
11
8
  function newGenericPool(connectionString, poolOptions) {
12
9
  poolOptions = poolOptions || {};
@@ -15,8 +12,19 @@ function newGenericPool(connectionString, poolOptions) {
15
12
  idleTimeoutMillis: poolOptions.idleTimeout || defaults.poolIdleTimeout,
16
13
  reapIntervalMillis: poolOptions.reapIntervalMillis || defaults.reapIntervalMillis,
17
14
  log: poolOptions.log,
18
- create: function(cb) {
15
+ create: async function(cb) {
19
16
  var client;
17
+ try {
18
+ if (!oracle) {
19
+ oracle = await import('oracledb');
20
+ oracle = oracle.default || oracle;
21
+ oracle.outFormat = oracle.OUT_FORMAT_OBJECT;
22
+ oracle.fetchAsBuffer = [ oracle.BLOB ];
23
+ }
24
+ }
25
+ catch (err) {
26
+ return cb(err, null);
27
+ }
20
28
  oracle.getConnection(connectionString, onConnected);
21
29
  function onConnected(err, _client) {
22
30
  client = _client;
@@ -11,11 +11,6 @@ let hostLocal = require('../hostLocal');
11
11
  let doQuery = require('../query');
12
12
  let releaseDbClient = require('../table/releaseDbClient');
13
13
  let setSessionSingleton = require('../table/setSessionSingleton');
14
- let types = require('pg').types;
15
-
16
- types.setTypeParser(1700, function(val) {
17
- return parseFloat(val);
18
- });
19
14
 
20
15
  function newDatabase(connectionString, poolOptions) {
21
16
  if (!connectionString)
@@ -4,12 +4,11 @@ var log = require('../../table/log');
4
4
 
5
5
  var defaults = require('../../poolDefaults');
6
6
  var genericPool = require('../../generic-pool');
7
- var _pg = require('pg');
7
+ var pg;
8
8
  var parseSearchPathParam = require('./parseSearchPathParam');
9
9
 
10
10
  function newPgPool(connectionString, poolOptions) {
11
11
  poolOptions = poolOptions || {};
12
- let pg = poolOptions.native ? _pg.native : _pg;
13
12
 
14
13
  // @ts-ignore
15
14
  var pool = genericPool.Pool({
@@ -17,7 +16,20 @@ function newPgPool(connectionString, poolOptions) {
17
16
  idleTimeoutMillis: poolOptions.idleTimeout || defaults.poolIdleTimeout,
18
17
  reapIntervalMillis: poolOptions.reapIntervalMillis || defaults.reapIntervalMillis,
19
18
  log: poolOptions.log,
20
- create: function(cb) {
19
+ create: async function(cb) {
20
+ try {
21
+ if (!pg) {
22
+ pg = await import('pg');
23
+ pg = pg.default || pg;
24
+ let types = pg.types || pg.types;
25
+ types.setTypeParser(1700, function(val) {
26
+ return parseFloat(val);
27
+ });
28
+ }
29
+ }
30
+ catch(e) {
31
+ return cb(e, null);
32
+ }
21
33
  var client = new pg.Client(connectionString);
22
34
  client.connect(function(err) {
23
35
  if (err) return cb(err, null);
@@ -5,7 +5,7 @@ import nodeResolve from '@rollup/plugin-node-resolve';
5
5
  export default {
6
6
  input: './src/indexBrowser.js',
7
7
  output: {
8
- file: './src/client/index.mjs',
8
+ file: './dist/index.browser.mjs',
9
9
  format: 'esm',
10
10
  interop: 'auto'
11
11
  },
@@ -0,0 +1,32 @@
1
+ import json from '@rollup/plugin-json';
2
+ import commonjs from '@rollup/plugin-commonjs';
3
+ import nodeResolve from '@rollup/plugin-node-resolve';
4
+
5
+ export default {
6
+ input: './src/index.js',
7
+ output: {
8
+ file: './dist/index.mjs',
9
+ format: 'esm',
10
+ interop: 'auto'
11
+ },
12
+
13
+ // plugins: [json(), commonjs()],
14
+ plugins: [json(), nodeResolve({ preferBuiltins: false }), commonjs({
15
+ transformMixedEsModules: true,
16
+ esmExternals: true, // Add this
17
+ requireReturnsDefault: 'preferred' // Change this
18
+ })],
19
+ external(id) {
20
+ // If it's in node_modules, mark as external
21
+ return id.includes('node_modules');
22
+ },
23
+ onwarn: (warning, warn) => {
24
+ if (warning.code === 'CIRCULAR_DEPENDENCY') {
25
+ // Log the full circular dependency warning message
26
+ console.warn(`[CIRCULAR DEPENDENCY] ${warning.message}`);
27
+ } else {
28
+ // For all other warnings, use Rollup's default handler.
29
+ warn(warning);
30
+ }
31
+ },
32
+ };
@@ -0,0 +1,24 @@
1
+ // @ts-ignore
2
+ // eslint-disable-next-line no-undef
3
+ const deno = typeof Deno !== 'undefined' && Deno.version?.deno;
4
+ // @ts-ignore
5
+ // eslint-disable-next-line no-undef
6
+ const bun = typeof Bun !== 'undefined' && Bun.version;
7
+ const node = (typeof process !== 'undefined' && process.versions?.node && !deno && !bun) ? process.versions.node : false;
8
+
9
+ function parseVersion(version) {
10
+ if (version) {
11
+ const versionArray = version.split('.');
12
+ return {
13
+ version,
14
+ major: parseInt(versionArray[0]),
15
+ minor: parseInt(versionArray[1]),
16
+ patch: parseInt(versionArray[2])
17
+ };
18
+ }
19
+ else
20
+ return false;
21
+ }
22
+
23
+
24
+ module.exports = { deno: parseVersion(deno), bun: parseVersion(bun), node: parseVersion(node) };
@@ -0,0 +1,10 @@
1
+ const format = 'delete from %s where %s.rowId in (SELECT %s.rowId FROM %s %s%s)';
2
+ const formatString = require('../format');
3
+ const quote = require('./quote');
4
+
5
+ function deleteFromSql(table, alias, whereSql) {
6
+ const name = quote(table._dbName);
7
+ alias = quote(alias);
8
+ return formatString(format, name, name, alias, name, alias, whereSql);
9
+ }
10
+ module.exports = deleteFromSql;
@@ -0,0 +1,7 @@
1
+ function encodeBoolean(bool) {
2
+ if (bool)
3
+ return 1;
4
+ return 0;
5
+ }
6
+
7
+ module.exports = encodeBoolean;
@@ -0,0 +1,7 @@
1
+ //unused because using sql parameters instead
2
+ //Remove ?
3
+ function encodeBuffer(buffer) {
4
+ return 'E\'\\\\x' + buffer.toString('hex') + '\'';
5
+ }
6
+
7
+ module.exports = encodeBuffer;
@@ -0,0 +1,21 @@
1
+ let newInsertCommand = require('../table/commands/newInsertCommand');
2
+ let newInsertCommandCore = require('../table/commands/newInsertCommandCore');
3
+ let newGetLastInsertedCommand = require('../table/commands/newGetLastInsertedCommand');
4
+ let executeQueries = require('../table/executeQueries');
5
+ let pushCommand = require('../table/commands/pushCommand');
6
+
7
+
8
+ function insertDefault(context, table, row, options) {
9
+ let commands = [];
10
+ let insertCmd = newInsertCommand(newInsertCommandCore.bind(null, context), table, row, options);
11
+ insertCmd.disallowCompress = true;
12
+ pushCommand(context, insertCmd);
13
+
14
+ let selectCmd = newGetLastInsertedCommand(context, table, row, insertCmd);
15
+ commands.push(selectCmd);
16
+
17
+ return executeQueries(context, commands).then((result) => result[result.length - 1]);
18
+
19
+ }
20
+
21
+ module.exports = insertDefault;
@@ -0,0 +1,67 @@
1
+ const quote = require('./quote');
2
+
3
+ function insertSql(_context, table, row, options) {
4
+ let columnNames = [];
5
+ let conflictColumnUpdateSql = '';
6
+ let values = [];
7
+
8
+ let sql = 'INSERT INTO ' + quote(table._dbName) + ' ';
9
+ addDiscriminators();
10
+ addColumns();
11
+
12
+ if (columnNames.length === 0) {
13
+ sql += 'DEFAULT VALUES';
14
+ } else {
15
+ sql = sql + '(' + columnNames.join(',') + ') ' + 'VALUES (' + values.join(',') + ')' + onConflict();
16
+ }
17
+
18
+ return sql;
19
+
20
+ function onConflict() {
21
+ if (options.concurrency === 'skipOnConflict' || options.concurrency === 'overwrite') {
22
+ const primaryKeys = table._primaryColumns.map(x => quote(x._dbName)).join(',');
23
+ return ` ON CONFLICT(${primaryKeys}) ${conflictColumnUpdateSql}`;
24
+ } else {
25
+ return '';
26
+ }
27
+ }
28
+
29
+ function addDiscriminators() {
30
+ let discriminators = table._columnDiscriminators;
31
+ for (let i = 0; i < discriminators.length; i++) {
32
+ let parts = discriminators[i].split('=');
33
+ columnNames.push(quote(parts[0]));
34
+ values.push(parts[1]);
35
+ }
36
+ }
37
+
38
+ function addColumns() {
39
+ let conflictColumnUpdates = [];
40
+ let columns = table._columns;
41
+ for (let i = 0; i < columns.length; i++) {
42
+ let column = columns[i];
43
+ const columnName = quote(column._dbName);
44
+ if (row['__' + column.alias] !== undefined) {
45
+ columnNames.push(columnName);
46
+ values.push('%s');
47
+ addConflictUpdate(column);
48
+ }
49
+ }
50
+ if (conflictColumnUpdates.length === 0)
51
+ conflictColumnUpdateSql = 'DO NOTHING';
52
+ else
53
+ conflictColumnUpdateSql = 'DO UPDATE SET ' + conflictColumnUpdates.join(',');
54
+
55
+ function addConflictUpdate(column) {
56
+ let concurrency = options[column.alias]?.concurrency || options.concurrency;
57
+ const tableName = table._dbName;
58
+ const columnName = quote(column._dbName);
59
+ if (concurrency === 'overwrite') {
60
+ conflictColumnUpdates.push(`${columnName}=excluded.${columnName}`);
61
+ } else if (concurrency === 'optimistic')
62
+ conflictColumnUpdates.push(`${columnName} = CASE WHEN ${tableName}.${columnName} <> excluded.${columnName} THEN '12345678-1234-1234-1234-123456789012Conflict when updating ${columnName}12345678-1234-1234-1234-123456789012' ELSE ${tableName}.${columnName} END`);
63
+ }
64
+ }
65
+ }
66
+
67
+ module.exports = insertSql;
@@ -0,0 +1,12 @@
1
+ function lastInsertedSql(context, table, keyValues) {
2
+ return keyValues.map((value,i) => {
3
+ let column = table._primaryColumns[i];
4
+ if (value === undefined && column.tsType === 'NumberColumn')
5
+ return 'rowid IN (select last_insert_rowid())';
6
+ else
7
+ return column.eq(context, value);
8
+ });
9
+
10
+ }
11
+
12
+ module.exports = lastInsertedSql;
@@ -0,0 +1,18 @@
1
+ function limitAndOffset(span) {
2
+ if (span.offset)
3
+ return ` limit ${limit()} offset ${span.offset}`;
4
+ else if (span.limit || span.limit === 0)
5
+ return ` limit ${span.limit}`;
6
+ else
7
+ return '';
8
+
9
+ function limit() {
10
+ if (span.limit || span.limit === 0)
11
+ return span.limit;
12
+ else
13
+ return '-1';
14
+ }
15
+
16
+ }
17
+
18
+ module.exports = limitAndOffset;