@sungen/driver-db 3.2.10 → 3.2.11

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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sungen/driver-db",
3
- "version": "3.2.10",
3
+ "version": "3.2.11",
4
4
  "description": "Sungen DB capability (Data Driver) — the @query annotation, query catalog, declarative DB steps, and the specs/db.ts runtime template. Plugs into @sun-asterisk/sungen via the capability SPI.",
5
5
  "main": "src/index.ts",
6
6
  "types": "src/index.ts",
@@ -10,7 +10,11 @@
10
10
  "pg": "^8",
11
11
  "mysql2": "^3",
12
12
  "better-sqlite3": "^11",
13
- "ssh2": "^1"
13
+ "ssh2": "^1",
14
+ "@azure/cosmos": "^4",
15
+ "mongodb": "^7",
16
+ "@aws-sdk/client-dynamodb": "^3",
17
+ "@aws-sdk/lib-dynamodb": "^3"
14
18
  }
15
19
  },
16
20
  "scripts": {
@@ -19,7 +23,7 @@
19
23
  "author": "eqe team (engineer & quality) — Sun Asterisk",
20
24
  "license": "MIT",
21
25
  "dependencies": {
22
- "@sun-asterisk/sungen": "3.2.10"
26
+ "@sun-asterisk/sungen": "3.2.11"
23
27
  },
24
28
  "files": [
25
29
  "dist",
package/src/index.ts CHANGED
@@ -16,7 +16,7 @@
16
16
  * core-resident catalog), so this driver registers no gate sensor.
17
17
  */
18
18
  import type { CapabilityRegistry } from '@sun-asterisk/sungen';
19
- import { parseQueryOverrides, resolveQuery, compileQuery } from '@sun-asterisk/sungen';
19
+ import { parseQueryOverrides, resolveQuery, compileQuery, compileShape, isShapeEntry } from '@sun-asterisk/sungen';
20
20
  import { databasePatterns, isDbStep } from './patterns/database-patterns';
21
21
 
22
22
  /**
@@ -32,13 +32,27 @@ function dbPreconditionCodegen(input: { tags: string[]; screenName: string; cwd:
32
32
  const name = m[1];
33
33
  const overrides = parseQueryOverrides(m[2]);
34
34
  const entry = resolveQuery(name, input.screenName, input.cwd); // throws (fail-fast) if missing/ambiguous
35
- const { sql, paramNames } = compileQuery(entry);
36
- const paramExprs = paramNames.map((p) => (p in overrides ? overrides[p] : `testData.get(${JSON.stringify(p)})`));
37
35
  const label = JSON.stringify(entry.description ? `query "${name}" — ${entry.description}` : `query "${name}"`);
38
36
  const ds = entry.datasource ? JSON.stringify(entry.datasource) : 'undefined';
37
+ // Bind params with raw() (uncoerced native type), not get() (Gherkin-text stringify) — numeric
38
+ // filters must reach the DB as numbers (MySQL `LIMIT '30'` is a syntax error; a type-strict store
39
+ // never matches a stringified number).
40
+ const bind = (p: string): string => (p in overrides ? overrides[p] : `testData.raw(${JSON.stringify(p)})`);
41
+ let code: string;
42
+ if (isShapeEntry(entry)) {
43
+ // MongoDB find/pipeline: emit the shape as-authored + a named param map; the engine substitutes
44
+ // `:param` placeholders at runtime (type-preserving) and runs the operator blocklist.
45
+ const { shape, paramNames } = compileShape(entry);
46
+ const paramMap = paramNames.map((p) => `${JSON.stringify(p)}: ${bind(p)}`);
47
+ code = `testData.bind(${JSON.stringify(name)}, await db.fetchQueryShape(${label}, ${JSON.stringify(shape)}, { ${paramMap.join(', ')} }, ${ds}));`;
48
+ } else {
49
+ const { sql, paramNames } = compileQuery(entry);
50
+ const paramExprs = paramNames.map(bind);
51
+ code = `testData.bind(${JSON.stringify(name)}, await db.fetchQuery(${label}, ${JSON.stringify(sql)}, [${paramExprs.join(', ')}], ${ds}));`;
52
+ }
39
53
  out.push({
40
54
  comment: `@query:${name} → bind {{${name}}} from ${entry.datasource || 'default datasource'}`,
41
- code: `testData.bind(${JSON.stringify(name)}, await db.fetchQuery(${label}, ${JSON.stringify(sql)}, [${paramExprs.join(', ')}], ${ds}));`,
55
+ code,
42
56
  boundVars: [name],
43
57
  });
44
58
  }
@@ -31,7 +31,9 @@ export function isDbStep(text: string): boolean {
31
31
  function valueExpr(token: string): string {
32
32
  const t = token.trim();
33
33
  const v = t.match(/^\{\{\s*([^}]+?)\s*\}\}$/);
34
- if (v) return `testData.get(${JSON.stringify(v[1])})`;
34
+ // raw() keeps the native type so numeric filters bind as numbers (a type-strict store won't
35
+ // match a stringified number); the expected-column compare stringifies both sides anyway.
36
+ if (v) return `testData.raw(${JSON.stringify(v[1])})`;
35
37
  const q = t.match(/^["'](.*)["']$/);
36
38
  if (q) return JSON.stringify(q[1]);
37
39
  if (/^-?\d+(?:\.\d+)?$/.test(t)) return t;