@dockstat/sqlite-wrapper 1.2.3 → 1.2.4

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/index.ts CHANGED
@@ -211,7 +211,7 @@ class DB {
211
211
  tableName: string,
212
212
  columns: string | Record<string, string> | TableSchema,
213
213
  options?: TableOptions
214
- ): void {
214
+ ): QueryBuilder<_T> {
215
215
  const temp = options?.temporary ? 'TEMPORARY ' : ''
216
216
  const ifNot = options?.ifNotExists ? 'IF NOT EXISTS ' : ''
217
217
  const withoutRowId = options?.withoutRowId ? ' WITHOUT ROWID' : ''
@@ -276,6 +276,8 @@ class DB {
276
276
  if (options?.comment) {
277
277
  this.setTableComment(tableName, options.comment)
278
278
  }
279
+
280
+ return this.table<_T>(tableName)
279
281
  }
280
282
 
281
283
  /**
package/package.json CHANGED
@@ -1,11 +1,16 @@
1
1
  {
2
2
  "name": "@dockstat/sqlite-wrapper",
3
- "version": "1.2.3",
3
+ "version": "1.2.4",
4
4
  "description": "A TypeScript wrapper around bun:sqlite with type-safe query building",
5
5
  "type": "module",
6
6
  "main": "./index.ts",
7
7
  "types": "./index.ts",
8
- "files": ["index.ts", "query-builder/**/*", "README.md", "types.ts"],
8
+ "files": [
9
+ "index.ts",
10
+ "query-builder/**/*",
11
+ "README.md",
12
+ "types.ts"
13
+ ],
9
14
  "scripts": {
10
15
  "dev": "bun build index.ts",
11
16
  "lint": "biome lint .",
@@ -36,7 +36,6 @@ export abstract class BaseQueryBuilder<T extends Record<string, unknown>> {
36
36
  regexConditions: [],
37
37
  jsonColumns: jsonConfig?.jsonColumns,
38
38
  }
39
- this.logger.debug(`Created QueryBuilder for table: ${tableName}`)
40
39
  }
41
40
 
42
41
  /**
@@ -183,7 +183,7 @@ export class SelectQueryBuilder<
183
183
  `Executing SELECT query - query: ${query}, params: ${JSON.stringify(params)}, hasJsonColumns: ${!!this.state.jsonColumns}`
184
184
  )
185
185
  const rows = this.getDb()
186
- .prepare(query)
186
+ .prepare(query, params)
187
187
  .all() as T[]
188
188
  this.getLogger().debug(`Retrieved ${rows.length} rows from database`)
189
189
  const transformed = this.transformRowsFromDb(rows)
@@ -206,9 +206,6 @@ export class WhereQueryBuilder<
206
206
  throw new Error(`whereOp: operator "${op}" not supported`);
207
207
  }
208
208
 
209
- // Remove any existing conditions for this column
210
- this.removeExistingCondition(String(column));
211
-
212
209
  // Handle null special-casing for IS / IS NOT and equality operators
213
210
  if (
214
211
  (value === null || value === undefined) &&
package/types.ts CHANGED
@@ -496,6 +496,7 @@ export const column = {
496
496
  constraints?: ColumnConstraints,
497
497
  ): ColumnDefinition => ({
498
498
  type: SQLiteTypes.TEXT,
499
+ notNull: true,
499
500
  check: `{{COLUMN}} IN (${values.map((v) => `'${v}'`).join(", ")})`,
500
501
  ...constraints,
501
502
  }),