@travetto/model-sqlite 5.0.0-rc.8 → 5.0.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
@@ -42,11 +42,12 @@ export class Init {
42
42
  }
43
43
  ```
44
44
 
45
- where the [SQLModelConfig](https://github.com/travetto/travetto/tree/main/module/model-sql/src/config.ts#L7) is defined by:
45
+ where the [SQLModelConfig](https://github.com/travetto/travetto/tree/main/module/model-sql/src/config.ts#L8) is defined by:
46
46
 
47
47
  **Code: Structure of SQLModelConfig**
48
48
  ```typescript
49
49
  import { Config } from '@travetto/config';
50
+ import { asFull } from '@travetto/runtime';
50
51
 
51
52
  /**
52
53
  * SQL Model Config
@@ -88,8 +89,7 @@ export class SQLModelConfig<T extends {} = {}> {
88
89
  /**
89
90
  * Raw client options
90
91
  */
91
-
92
- options: T = {} as T;
92
+ options: T = asFull({});
93
93
  }
94
94
  ```
95
95
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@travetto/model-sqlite",
3
- "version": "5.0.0-rc.8",
3
+ "version": "5.0.0",
4
4
  "description": "SQLite backing for the travetto model module, with real-time modeling support for SQL schemas.",
5
5
  "keywords": [
6
6
  "sql",
@@ -26,11 +26,11 @@
26
26
  "directory": "module/model-sqlite"
27
27
  },
28
28
  "dependencies": {
29
- "@travetto/config": "^5.0.0-rc.8",
30
- "@travetto/context": "^5.0.0-rc.8",
31
- "@travetto/model": "^5.0.0-rc.8",
32
- "@travetto/model-query": "^5.0.0-rc.8",
33
- "@travetto/model-sql": "^5.0.0-rc.8",
29
+ "@travetto/config": "^5.0.0",
30
+ "@travetto/context": "^5.0.0",
31
+ "@travetto/model": "^5.0.0",
32
+ "@travetto/model-query": "^5.0.0",
33
+ "@travetto/model-sql": "^5.0.0",
34
34
  "@types/better-sqlite3": "^7.6.11",
35
35
  "better-sqlite3": "^11.1.2"
36
36
  },
package/src/connection.ts CHANGED
@@ -76,10 +76,9 @@ export class SqliteConnection extends Connection<Database> {
76
76
  return this.#withRetries(async () => {
77
77
  console.debug('Executing query', { query });
78
78
  try {
79
- const out = await conn.prepare(query)[query.trim().startsWith('SELECT') ? 'all' : 'run']();
79
+ const out = await conn.prepare<unknown[], T>(query)[query.trim().startsWith('SELECT') ? 'all' : 'run']();
80
80
  if (Array.isArray(out)) {
81
- // eslint-disable-next-line @typescript-eslint/consistent-type-assertions
82
- const records: T[] = [...out as T[]].map(v => ({ ...v }));
81
+ const records: T[] = out.map(v => ({ ...v }));
83
82
  return { count: out.length, records };
84
83
  } else {
85
84
  return { count: out.changes, records: [] };
package/src/dialect.ts CHANGED
@@ -7,6 +7,7 @@ import { SQLModelConfig, SQLDialect } from '@travetto/model-sql';
7
7
  import { VisitStack } from '@travetto/model-sql/src/internal/util';
8
8
 
9
9
  import { SqliteConnection } from './connection';
10
+ import { castTo } from '@travetto/runtime';
10
11
 
11
12
  /**
12
13
  * Sqlite Dialect for the SQL Model Source
@@ -55,8 +56,7 @@ export class SqliteDialect extends SQLDialect {
55
56
  * Define column modification
56
57
  */
57
58
  getModifyColumnSQL(stack: VisitStack[]): string {
58
- // eslint-disable-next-line @typescript-eslint/consistent-type-assertions
59
- const field = stack[stack.length - 1] as FieldConfig;
59
+ const field: FieldConfig = castTo(stack[stack.length - 1]);
60
60
  const type = this.getColumnType(field);
61
61
  const ident = this.ident(field.name);
62
62
  return `ALTER TABLE ${this.parentTable(stack)} ALTER COLUMN ${ident} TYPE ${type} USING (${ident}::${type});`;