@primate/oracledb 0.2.1 → 0.4.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.
@@ -10,7 +10,7 @@ const VALID_IDENTIFIER = /^[a-zA-Z_][a-zA-Z0-9_]*$/;
10
10
  function quote(name) {
11
11
  if (!VALID_IDENTIFIER.test(name))
12
12
  throw E.identifier_invalid(name);
13
- return `"${name}"`;
13
+ return `"${name.toUpperCase()}"`;
14
14
  }
15
15
  function get_column(key) {
16
16
  return typemap[key].column;
@@ -397,7 +397,7 @@ export default class OracleDB {
397
397
  SELECT COUNT(*) AS n
398
398
  FROM USER_TABLES
399
399
  WHERE TABLE_NAME = :1
400
- `, [table]);
400
+ `, [table.toUpperCase()]);
401
401
  if (Number(exists[0]?.n ?? 0) === 0)
402
402
  return null;
403
403
  const rows = await this.#sql(`
@@ -411,12 +411,12 @@ export default class OracleDB {
411
411
  FROM USER_TAB_COLUMNS
412
412
  WHERE TABLE_NAME = :1
413
413
  ORDER BY COLUMN_ID
414
- `, [table]);
414
+ `, [table.toUpperCase()]);
415
415
  const result = {};
416
416
  for (const row of rows) {
417
417
  const candidates = columns_to_types(row);
418
418
  if (candidates.length > 0) {
419
- result[row.column_name] = candidates;
419
+ result[row.column_name.toLowerCase()] = candidates;
420
420
  }
421
421
  }
422
422
  return result;
@@ -552,15 +552,20 @@ export default class OracleDB {
552
552
  : undefined;
553
553
  const params = [];
554
554
  const name_to_index = new Map();
555
- const query = options.query.replace(/:(\w+)/g, (_, name) => {
556
- if (!name_to_index.has(name)) {
557
- name_to_index.set(name, params.length + 1);
558
- const types = Object.fromEntries(Object.entries(options.input.properties)
559
- .map(([k, v]) => [k, v.datatype]));
560
- params.push(bind_value(types[name], input[name]));
555
+ let query = options.query;
556
+ if (is.defined(options.input)) {
557
+ const types = Object.fromEntries(Object.entries(options.input.properties)
558
+ .map(([k, v]) => [k, v.datatype]));
559
+ for (const [, name] of options.query.matchAll(/:(\w+)/g)) {
560
+ if (!name_to_index.has(name)) {
561
+ name_to_index.set(name, params.length + 1);
562
+ params.push(await bind_value(types[name], input[name]));
563
+ }
561
564
  }
562
- return `:${name_to_index.get(name)}`;
563
- });
565
+ query = options.query.replace(/:(\w+)/g, (_, name) => {
566
+ return `:${name_to_index.get(name)}`;
567
+ });
568
+ }
564
569
  const rows = await this.#sql(query, params);
565
570
  return (is.defined(options.output)
566
571
  ? options.output.parse(rows)
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@primate/oracledb",
3
- "version": "0.2.1",
4
- "description": "OracleDB databases for Primate",
3
+ "version": "0.4.0",
4
+ "description": "Oracle database for Primate",
5
5
  "homepage": "https://primate.run/docs/database/oracledb",
6
6
  "bugs": "https://github.com/primate-run/primate/issues",
7
7
  "type": "module",
@@ -17,18 +17,18 @@
17
17
  "!/**/*.spec.*"
18
18
  ],
19
19
  "devDependencies": {
20
- "@rcompat/type": "^0.17.0",
21
- "@types/oracledb": "^6.10.4"
20
+ "@rcompat/type": "^0.18.0",
21
+ "@types/oracledb": "^7.0.3"
22
22
  },
23
23
  "dependencies": {
24
- "@rcompat/assert": "^0.13.0",
25
- "@rcompat/is": "^0.11.0",
26
- "oracledb": "^6.10.0",
27
- "@primate/core": "^0.8.8",
28
- "pema": "^0.8.3"
24
+ "@primate/core": "^0.10.0",
25
+ "@rcompat/assert": "^0.14.0",
26
+ "@rcompat/is": "^0.12.1",
27
+ "oracledb": "^7.0.1",
28
+ "pema": "^0.10.0"
29
29
  },
30
30
  "peerDependencies": {
31
- "primate": "^0.39.1"
31
+ "primate": "^0.41.0"
32
32
  },
33
33
  "imports": {
34
34
  "#*": {
@@ -43,10 +43,10 @@
43
43
  }
44
44
  },
45
45
  "scripts": {
46
- "build": "npm run clean && tsgo",
46
+ "build": "pnpm run clean && tsc",
47
47
  "clean": "rm -rf ./lib",
48
48
  "lint": "eslint .",
49
- "test": "npm run db && npx proby",
49
+ "test": "pnpm run db && npx proby",
50
50
  "db": "scripts/db.sh"
51
51
  }
52
52
  }