orange-orm 4.7.14 → 4.7.15-beta.0

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/README.md CHANGED
@@ -222,7 +222,12 @@ Because of a peculiarity in SQLite, which only allows one statement execution at
222
222
  import map from './map';
223
223
  const db = map.sqlite('demo.db');
224
224
 
225
- const sql = `DROP TABLE IF EXISTS deliveryAddress; DROP TABLE IF EXISTS package; DROP TABLE IF EXISTS orderLine; DROP TABLE IF EXISTS _order; DROP TABLE IF EXISTS customer;
225
+ const sql = `DROP TABLE IF EXISTS deliveryAddress;
226
+ DROP TABLE IF EXISTS package;
227
+ DROP TABLE IF EXISTS orderLine;
228
+ DROP TABLE IF EXISTS _order;
229
+ DROP TABLE IF EXISTS customer;
230
+
226
231
  CREATE TABLE customer (
227
232
  id INTEGER PRIMARY KEY,
228
233
  name TEXT,
package/SECURITY.md CHANGED
@@ -3,7 +3,8 @@
3
3
  ## Supported versions
4
4
 
5
5
  The following table describes the versions of this project that are currently supported with security updates:
6
- - [x] 3.x
6
+ - [x] 4.x
7
+ - [ ] 3.x
7
8
  - [ ] 2.x
8
9
  - [ ] 1.x
9
10
 
@@ -11085,6 +11085,10 @@ function requireGetManyDto$1 () {
11085
11085
  const extractKey = createExtractKey(leg);
11086
11086
  const extractFromMap = createExtractFromMap(rowsMap, table._primaryColumns);
11087
11087
 
11088
+ if (span._ids.length === 0) {
11089
+ return;
11090
+ }
11091
+
11088
11092
  // If maxRows is defined, chunk the IDs before calling getManyDto
11089
11093
  if (maxRows) {
11090
11094
  const chunkedIds = chunk(span._ids, maxRows);
package/dist/index.mjs CHANGED
@@ -11086,6 +11086,10 @@ function requireGetManyDto$1 () {
11086
11086
  const extractKey = createExtractKey(leg);
11087
11087
  const extractFromMap = createExtractFromMap(rowsMap, table._primaryColumns);
11088
11088
 
11089
+ if (span._ids.length === 0) {
11090
+ return;
11091
+ }
11092
+
11089
11093
  // If maxRows is defined, chunk the IDs before calling getManyDto
11090
11094
  if (maxRows) {
11091
11095
  const chunkedIds = chunk(span._ids, maxRows);
@@ -16034,9 +16038,16 @@ var hasRequiredWrapQuery$6;
16034
16038
  function requireWrapQuery$6 () {
16035
16039
  if (hasRequiredWrapQuery$6) return wrapQuery_1$6;
16036
16040
  hasRequiredWrapQuery$6 = 1;
16037
- var log = requireLog();
16041
+ const log = requireLog();
16042
+ const connectionCache = new WeakMap();
16038
16043
 
16039
16044
  function wrapQuery(_context, connection) {
16045
+ let statementCache = connectionCache.get(connection);
16046
+ if (!statementCache) {
16047
+ statementCache = new Map();
16048
+ connectionCache.set(connection, statementCache);
16049
+ }
16050
+
16040
16051
  return runQuery;
16041
16052
 
16042
16053
  function runQuery(query, onCompleted) {
@@ -16045,7 +16056,11 @@ function requireWrapQuery$6 () {
16045
16056
  var sql = query.sql();
16046
16057
  log.emitQuery({ sql, parameters: params });
16047
16058
 
16048
- var statement = connection.prepare(sql);
16059
+ let statement = statementCache.get(sql);
16060
+ if (!statement) {
16061
+ statement = connection.prepare(sql);
16062
+ statementCache.set(sql, statement);
16063
+ }
16049
16064
  const rows = statement.all.apply(statement, params);
16050
16065
  onCompleted(null, rows);
16051
16066
  }
@@ -20719,7 +20734,7 @@ function requireSrc () {
20719
20734
  Object.defineProperty(connectViaPool, 'sqlite', {
20720
20735
  get: function() {
20721
20736
  if (!_sqlite) {
20722
- if (runtimes.deno || (runtimes.node && runtimes.node.major >= 22))
20737
+ if (runtimes.deno || (runtimes.node && (runtimes.node.major > 22 || (runtimes.node.major === 22 && runtimes.node.minor >= 5))))
20723
20738
  _sqlite = requireNewDatabase$7();
20724
20739
  else if (runtimes.bun)
20725
20740
  _sqlite = requireNewDatabase$6();
package/docs/changelog.md CHANGED
@@ -1,4 +1,6 @@
1
1
  ## Changelog
2
+ __4.7.15__
3
+ Minor performance improvements and node minor version check for node:sqlite.
2
4
  __4.7.14__
3
5
  Improved performance for SQL Server.
4
6
  __4.7.13__
package/package.json CHANGED
@@ -1,165 +1,166 @@
1
1
  {
2
- "name": "orange-orm",
3
- "version": "4.7.14",
4
- "main": "./src/index.js",
5
- "module": "./dist/index.mjs",
6
- "browser": "./dist/index.browser.mjs",
7
- "exports": {
8
- ".": {
9
- "require": "./src/index.js",
10
- "import": "./dist/index.mjs",
11
- "browser": "./dist/index.browser.mjs",
12
- "types": "./src/index.d.ts"
13
- }
14
- },
15
- "bin": {
16
- "orange-orm": "bin/rdb.js"
17
- },
18
- "title": "Orange ORM",
19
- "description": "Object Relational Mapper",
20
- "keywords": [
21
- "typescript orm",
22
- "orm",
23
- "sql",
24
- "mySql",
25
- "SQLite",
26
- "MySQL",
27
- "mssql",
28
- "Microsoft Sql Server",
29
- "PGlite",
30
- "Cloudflare D1",
31
- "PostgreSql",
32
- "Postgres",
33
- "pg",
34
- "sap",
35
- "sapase",
36
- "Oracle",
37
- "rdb",
38
- "Orange ORM",
39
- "active record"
40
- ],
41
- "authors": [
42
- "Lars-Erik Roald <lars.roald@gmail.com>"
43
- ],
44
- "license": "ISC",
45
- "codeOfConduct": "https://github.com/alfateam/orange-orm/blob/master/docs/CODE_OF_CONDUCT.md",
46
- "contributing": "https://github.com/alfateam/orange-orm/blob/master/CONTRIBUTING.md",
47
- "funding": {
48
- "type": "github",
49
- "url": "https://github.com/sponsors/lroal"
50
- },
51
- "scripts": {
52
- "test": "vitest run --threads=false",
53
- "test:bun": "bun test --timeout=30000 ./tests/*.bun.test.js",
54
- "test:deno": "deno test --allow-all --unstable-detect-cjs ./tests/*.deno.test.js",
55
- "test:all": "echo 'Running Node.js tests...' && npm run test:node && echo 'Running Bun tests...' && npm run test:bun && echo 'Running Deno tests...' && npm run test:deno && echo 'All tests completed!'",
56
- "test:all:parallel": "concurrently \"npm:test:node\" \"npm:test:bun\" \"npm:test:deno\"",
57
- "coverage": "vitest run --coverage.enabled --coverage.reporter='text-summary' --threads=false",
58
- "testw": "vitest --threads=false update",
59
- "tscheck": "tsc ./src/index.d.ts --module commonjs --target es2022 --noEmit true --strict true --esModuleInterop true",
60
- "concat-server": "node ./src/merge-server.js",
61
- "concat-browser": "node ./src/merge-browser.js",
62
- "build": "npm run build-server && npm run build-browser",
63
- "build-server": "rollup -c ./src/rollup.config.server.js && npm run concat-server",
64
- "build-browser": "rollup -c ./src/rollup.config.browser.js && npm run concat-browser",
65
- "lint": "eslint ./",
66
- "fix": "eslint ./ --fix",
67
- "owasp": "owasp-dependency-check --project \"MY_PROJECT\" --scan \"package-lock.json\" --exclude \"dependency-check-bin\" --out \"owasp\" --format HTML",
68
- "beta": "npm publish --tag beta"
69
- },
70
- "dependencies": {
71
- "@cloudflare/workers-types": "^4.20241106.0",
72
- "@lroal/on-change": "^4.0.2",
73
- "@tediousjs/connection-string": "^0.4.1",
74
- "@types/express": "^4.17.13",
75
- "@types/oracledb": "^6.0.4",
76
- "@types/tedious": "^4.0.14",
77
- "ajv": "^8.17.1",
78
- "axios": "^1.6.2",
79
- "fast-json-patch": "^3.1.1",
80
- "findup-sync": "^5.0.0",
81
- "glob": "^10.3.4 || ^11.0.2",
82
- "module-definition": "^4.0.0 || ^5.0.0 || || ^6.0.0",
83
- "rfdc": "^1.2.0",
84
- "uuid": "^8.3.2 || ^9.0.0 || ^10.0.0 || ^11.1.0"
85
- },
86
- "peerDependencies": {
87
- "@electric-sql/pglite": "^0.3.0",
88
- "msnodesqlv8": "^4.1.0",
89
- "mysql2": "^2.2.5 || ^3.9.4",
90
- "oracledb": "^6.3.0",
91
- "pg": "^8.5.1",
92
- "pg-query-stream": "^3.3.2",
93
- "sqlite3": "^5.0.2",
94
- "tedious": "^15.1.2 || ^16.0.0 || ^18.1.0 || || ^19.0.0"
95
- },
96
- "peerDependenciesMeta": {
97
- "pg": {
98
- "optional": true
2
+ "name": "orange-orm",
3
+ "version": "4.7.15-beta.0",
4
+ "publishConfig": {
5
+ "access": "public"
6
+ },
7
+ "main": "./src/index.js",
8
+ "module": "./dist/index.mjs",
9
+ "browser": "./dist/index.browser.mjs",
10
+ "exports": {
11
+ ".": {
12
+ "types": "./src/index.d.ts",
13
+ "browser": "./dist/index.browser.mjs",
14
+ "import": "./dist/index.mjs",
15
+ "require": "./src/index.js"
16
+ }
17
+ },
18
+ "bin": {
19
+ "orange-orm": "bin/rdb.js"
20
+ },
21
+ "title": "Orange ORM",
22
+ "description": "Object Relational Mapper",
23
+ "keywords": [
24
+ "typescript orm",
25
+ "orm",
26
+ "sql",
27
+ "mySql",
28
+ "SQLite",
29
+ "MySQL",
30
+ "mssql",
31
+ "Microsoft Sql Server",
32
+ "PGlite",
33
+ "Cloudflare D1",
34
+ "PostgreSql",
35
+ "Postgres",
36
+ "pg",
37
+ "sap",
38
+ "sapase",
39
+ "Oracle",
40
+ "rdb",
41
+ "Orange ORM",
42
+ "active record"
43
+ ],
44
+ "authors": [
45
+ "Lars-Erik Roald <lars.roald@gmail.com>"
46
+ ],
47
+ "license": "ISC",
48
+ "codeOfConduct": "https://github.com/alfateam/orange-orm/blob/master/docs/CODE_OF_CONDUCT.md",
49
+ "contributing": "https://github.com/alfateam/orange-orm/blob/master/CONTRIBUTING.md",
50
+ "funding": {
51
+ "type": "github",
52
+ "url": "https://github.com/sponsors/lroal"
99
53
  },
100
- "pg-query-stream": {
101
- "optional": true
54
+ "scripts": {
55
+ "test": "vitest run --pool=forks --poolOptions.forks.singleFork",
56
+ "test:bun": "bun test --timeout=30000 ./tests/*.bun.test.js",
57
+ "test:deno": "deno test --allow-all --unstable-detect-cjs ./tests/*.deno.test.js",
58
+ "test:all": "echo 'Running Node.js tests...' && npm run test:node && echo 'Running Bun tests...' && npm run test:bun && echo 'Running Deno tests...' && npm run test:deno && echo 'All tests completed!'",
59
+ "test:all:parallel": "concurrently \"npm:test:node\" \"npm:test:bun\" \"npm:test:deno\"",
60
+ "coverage": "vitest run --coverage.enabled --coverage.reporter='text-summary' --pool=forks --poolOptions.forks.singleFork",
61
+ "testw": "vitest --pool=forks --poolOptions.forks.singleFork update",
62
+ "tscheck": "tsc ./src/index.d.ts --module commonjs --target es2022 --noEmit true --strict true --esModuleInterop true",
63
+ "concat-server": "node ./src/merge-server.js",
64
+ "concat-browser": "node ./src/merge-browser.js",
65
+ "build": "npm run build-server && npm run build-browser",
66
+ "build-server": "rollup -c ./src/rollup.config.server.js && npm run concat-server",
67
+ "build-browser": "rollup -c ./src/rollup.config.browser.js && npm run concat-browser",
68
+ "lint": "eslint ./",
69
+ "fix": "eslint ./ --fix",
70
+ "owasp": "owasp-dependency-check --project \"MY_PROJECT\" --scan \"package-lock.json\" --exclude \"dependency-check-bin\" --out \"owasp\" --format HTML",
71
+ "beta": "npm publish --tag beta"
102
72
  },
103
- "mysql2": {
104
- "optional": true
73
+ "dependencies": {
74
+ "@cloudflare/workers-types": "^4.20241106.0",
75
+ "@lroal/on-change": "^4.0.2",
76
+ "@tediousjs/connection-string": "^0.4.1",
77
+ "@types/express": "^4.17.13",
78
+ "@types/oracledb": "^6.0.4",
79
+ "@types/tedious": "^4.0.14",
80
+ "ajv": "^8.17.1",
81
+ "axios": "^1.6.2",
82
+ "fast-json-patch": "^3.1.1",
83
+ "findup-sync": "^5.0.0",
84
+ "glob": "^10.3.4 || ^11.0.2",
85
+ "module-definition": "^4.0.0 || ^5.0.0 || || ^6.0.0",
86
+ "rfdc": "^1.2.0",
87
+ "uuid": "^8.3.2 || ^9.0.0 || ^10.0.0 || ^11.1.0"
105
88
  },
106
- "sqlite3": {
107
- "optional": true
89
+ "peerDependencies": {
90
+ "@electric-sql/pglite": "^0.3.0",
91
+ "msnodesqlv8": "^4.1.0",
92
+ "mysql2": "^2.2.5 || ^3.9.4",
93
+ "oracledb": "^6.3.0",
94
+ "pg": "^8.5.1",
95
+ "pg-query-stream": "^3.3.2",
96
+ "sqlite3": "^5.0.2",
97
+ "tedious": "^15.1.2 || ^16.0.0 || ^18.1.0 || || ^19.0.0"
108
98
  },
109
- "pg-native": {
110
- "optional": true
99
+ "peerDependenciesMeta": {
100
+ "pg": {
101
+ "optional": true
102
+ },
103
+ "pg-query-stream": {
104
+ "optional": true
105
+ },
106
+ "mysql2": {
107
+ "optional": true
108
+ },
109
+ "sqlite3": {
110
+ "optional": true
111
+ },
112
+ "pg-native": {
113
+ "optional": true
114
+ },
115
+ "msnodesqlv8": {
116
+ "optional": true
117
+ },
118
+ "tedious": {
119
+ "optional": true
120
+ },
121
+ "oracledb": {
122
+ "optional": true
123
+ },
124
+ "@electric-sql/pglite": {
125
+ "optional": true
126
+ }
111
127
  },
112
- "msnodesqlv8": {
113
- "optional": true
128
+ "devDependencies": {
129
+ "@electric-sql/pglite": "^0.3.0",
130
+ "@rollup/plugin-commonjs": "^28.0.2",
131
+ "@rollup/plugin-json": "^6.1.0",
132
+ "@rollup/plugin-node-resolve": "^13.0.0",
133
+ "@typescript-eslint/eslint-plugin": "^6.x",
134
+ "@typescript-eslint/parser": "^6.x",
135
+ "@vitest/coverage-v8": "^3.2.4",
136
+ "cors": "^2.8.5",
137
+ "eslint": "^8.57.0",
138
+ "eslint-plugin-jest": "^27.1.7",
139
+ "express": "^4.18.2",
140
+ "msnodesqlv8": "^4.1.0",
141
+ "mysql2": "^3.9.4",
142
+ "oracledb": "^6.3.0",
143
+ "owasp-dependency-check": "^0.0.21",
144
+ "pg": "^8.5.1",
145
+ "pg-query-stream": "^3.3.2",
146
+ "rollup": "^2.52.7",
147
+ "sqlite3": "^5.0.2",
148
+ "tedious": "^19.0.0",
149
+ "typescript": "^5.4.5",
150
+ "vitest": "^3.2.4"
114
151
  },
115
- "tedious": {
116
- "optional": true
152
+ "engines": {
153
+ "node": ">= 8.0.0"
117
154
  },
118
- "oracledb": {
119
- "optional": true
155
+ "repository": {
156
+ "type": "git",
157
+ "url": "git@github.com:alfateam/orange-orm.git"
120
158
  },
121
- "@electric-sql/pglite": {
122
- "optional": true
159
+ "homepage": "https://orange-orm.io",
160
+ "jshintConfig": {
161
+ "asi": true,
162
+ "eqnull": true,
163
+ "undef": true,
164
+ "node": true
123
165
  }
124
- },
125
- "devDependencies": {
126
- "@electric-sql/pglite": "^0.3.0",
127
- "@miniflare/d1": "^2.14.4",
128
- "@rollup/plugin-commonjs": "^28.0.2",
129
- "@rollup/plugin-json": "^6.1.0",
130
- "@rollup/plugin-node-resolve": "^13.0.0",
131
- "@typescript-eslint/eslint-plugin": "^6.x",
132
- "@typescript-eslint/parser": "^6.x",
133
- "@vitest/coverage-v8": "^0.34.1",
134
- "cors": "^2.8.5",
135
- "eslint": "^8.57.0",
136
- "eslint-plugin-jest": "^27.1.7",
137
- "express": "^4.18.2",
138
- "miniflare": "^3.20250129.0",
139
- "msnodesqlv8": "^4.1.0",
140
- "mysql2": "^3.9.4",
141
- "oracledb": "^6.3.0",
142
- "owasp-dependency-check": "^0.0.21",
143
- "pg": "^8.5.1",
144
- "pg-query-stream": "^3.3.2",
145
- "rollup": "^2.52.7",
146
- "sqlite3": "^5.0.2",
147
- "tedious": "^19.0.0",
148
- "typescript": "^5.4.5",
149
- "vitest": "^0.34.6"
150
- },
151
- "engines": {
152
- "node": ">= 8.0.0"
153
- },
154
- "repository": {
155
- "type": "git",
156
- "url": "git@github.com:alfateam/orange-orm.git"
157
- },
158
- "homepage": "https://orange-orm.io",
159
- "jshintConfig": {
160
- "asi": true,
161
- "eqnull": true,
162
- "undef": true,
163
- "node": true
164
- }
165
- }
166
+ }
package/src/getManyDto.js CHANGED
@@ -209,6 +209,10 @@ async function decodeManyRelations(context, strategy, span) {
209
209
  const extractKey = createExtractKey(leg);
210
210
  const extractFromMap = createExtractFromMap(rowsMap, table._primaryColumns);
211
211
 
212
+ if (span._ids.length === 0) {
213
+ return;
214
+ }
215
+
212
216
  // If maxRows is defined, chunk the IDs before calling getManyDto
213
217
  if (maxRows) {
214
218
  const chunkedIds = chunk(span._ids, maxRows);
package/src/index.js CHANGED
@@ -88,7 +88,7 @@ Object.defineProperty(connectViaPool, 'pg', {
88
88
  Object.defineProperty(connectViaPool, 'sqlite', {
89
89
  get: function() {
90
90
  if (!_sqlite) {
91
- if (runtimes.deno || (runtimes.node && runtimes.node.major >= 22))
91
+ if (runtimes.deno || (runtimes.node && (runtimes.node.major > 22 || (runtimes.node.major === 22 && runtimes.node.minor >= 5))))
92
92
  _sqlite = require('./nodeSqlite/newDatabase');
93
93
  else if (runtimes.bun)
94
94
  _sqlite = require('./bunSqlite/newDatabase');
@@ -1,6 +1,13 @@
1
- var log = require('../table/log');
1
+ const log = require('../table/log');
2
+ const connectionCache = new WeakMap();
2
3
 
3
4
  function wrapQuery(_context, connection) {
5
+ let statementCache = connectionCache.get(connection);
6
+ if (!statementCache) {
7
+ statementCache = new Map();
8
+ connectionCache.set(connection, statementCache);
9
+ }
10
+
4
11
  return runQuery;
5
12
 
6
13
  function runQuery(query, onCompleted) {
@@ -9,7 +16,11 @@ function wrapQuery(_context, connection) {
9
16
  var sql = query.sql();
10
17
  log.emitQuery({ sql, parameters: params });
11
18
 
12
- var statement = connection.prepare(sql);
19
+ let statement = statementCache.get(sql);
20
+ if (!statement) {
21
+ statement = connection.prepare(sql);
22
+ statementCache.set(sql, statement);
23
+ }
13
24
  const rows = statement.all.apply(statement, params);
14
25
  onCompleted(null, rows);
15
26
  }
package/.dockerignore DELETED
@@ -1 +0,0 @@
1
- node_modules
package/.eslintignore DELETED
@@ -1,2 +0,0 @@
1
- node_modules
2
- *Spec
package/.eslintrc.js DELETED
@@ -1,45 +0,0 @@
1
- module.exports = {
2
- 'env': {
3
- 'node': true,
4
- 'es6': true
5
- },
6
- 'extends': [
7
- 'eslint:recommended',
8
- 'plugin:@typescript-eslint/eslint-recommended',
9
- 'plugin:@typescript-eslint/recommended',
10
- // 'plugin:jest/recommended'
11
- ],
12
- 'parserOptions': {
13
- 'sourceType': 'module',
14
- 'ecmaVersion': 2018
15
- },
16
- 'ignorePatterns': ['*esm.js', '*.ts'],
17
- 'rules': {
18
- '@typescript-eslint/no-empty-function': 0,
19
- '@typescript-eslint/no-var-requires': 0,
20
- '@typescript-eslint/ban-ts-comment': 0,
21
- 'no-unused-vars': 'off',
22
- '@typescript-eslint/no-unused-vars': [2, { 'args': 'after-used', 'ignoreRestSiblings': true, 'argsIgnorePattern': '^_' }],
23
- 'indent': ['error', 'tab'],
24
- // 'linebreak-style': ['error', 'unix'],
25
- 'quotes': ['error', 'single'],
26
- 'semi': ['error', 'always'],
27
- 'no-console': 'off',
28
- 'no-debugger': 'off',
29
- 'no-trailing-spaces': 'error',
30
- 'no-underscore-dangle': 0,
31
- 'space-before-function-paren': ['error', {
32
- 'anonymous': 'never',
33
- 'named': 'never',
34
- 'asyncArrow': 'always'
35
- }],
36
- // 'jest/no-disabled-tests': 'warn',
37
- // 'jest/no-focused-tests': 'error',
38
- // 'jest/no-identical-title': 'error',
39
- // 'jest/prefer-to-have-length': 'warn',
40
- // 'jest/valid-expect': 'error'
41
- },
42
- 'plugins': [ '@typescript-eslint']
43
- // 'plugins': ['jest', '@typescript-eslint']
44
- };
45
-
package/.gitattributes DELETED
@@ -1,3 +0,0 @@
1
- * text=auto eol=lf
2
- *.{cmd,[cC][mM][dD]} text eol=crlf
3
- *.{bat,[bB][aA][tT]} text eol=crlf
package/CNAME DELETED
@@ -1 +0,0 @@
1
- orange-orm.io
package/src/package.json DELETED
@@ -1,5 +0,0 @@
1
- {
2
- "dependencies": {
3
- "uuid": "^11.0.5"
4
- }
5
- }
package/vitest.config.js DELETED
@@ -1,17 +0,0 @@
1
- // vitest.config.js
2
- /** @type {import('vitest').UserConfig} */
3
- module.exports = {
4
- test: {
5
- // Copied baseline excludes (since configDefaults is ESM-only)
6
- exclude: [
7
- '**/node_modules/**',
8
- '**/dist/**',
9
- '**/cypress/**',
10
- '**/.{idea,git,cache}/**',
11
- '**/coverage/**',
12
- '**/*.deno.test.js',
13
- '**/*.bun.test.js',
14
- ],
15
- threads: false,
16
- },
17
- };