@leonardovida-md/drizzle-neo-duckdb 2.1.2 → 2.3.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
@@ -186,7 +186,7 @@ const db = await drizzle(':memory:', {
186
186
 
187
187
  ## DuckDB Types
188
188
 
189
- DuckDB-specific column helpers: `duckDbList`, `duckDbArray`, `duckDbStruct`, `duckDbMap`, `duckDbJson`, `duckDbBlob`, `duckDbInet`, `duckDbInterval`, `duckDbTimestamp`, `duckDbDate` and `duckDbTime`.
189
+ DuckDB-specific column helpers: `duckDbList`, `duckDbArray`, `duckDbStruct`, `duckDbUnion`, `duckDbMap`, `duckDbJson`, `duckDbBlob`, `duckDbInet`, `duckDbInterval`, `duckDbTimestamp`, `duckDbDate` and `duckDbTime`.
190
190
 
191
191
  - `duckDbTimestamp` and `duckDbTime` can keep storage variants such as `TIMESTAMP_NS`, `TIMESTAMP_MS`, `TIMESTAMP_S`, `TIME_NS` and `TIME WITH TIME ZONE` through the `duckDbType` and `withTimezone` options.
192
192
  - Postgres `json` and `jsonb` columns are rejected. Use `duckDbJson()`.
@@ -229,6 +229,7 @@ await db.transaction(async (tx) => {
229
229
  DuckDB differs from Postgres here:
230
230
 
231
231
  - There is no `SAVEPOINT`. Nested transactions reuse the outer one, so an inner rollback aborts everything.
232
+ - Without a pool, other `db` queries wait while a transaction is open on the shared connection, instead of joining it.
232
233
  - Any failed statement aborts the whole transaction. Catching the error inside the callback does not keep earlier writes. `db.transaction()` rolls back and rejects.
233
234
  - The `config` argument (`isolationLevel`, `accessMode`, `deferrable`) is deprecated and ignored with a one-time warning, because DuckDB has no `SET TRANSACTION`.
234
235
 
@@ -18,3 +18,9 @@ export declare class CliUsageError extends Error {
18
18
  constructor(message: string);
19
19
  }
20
20
  export declare function parseArgs(argv: string[]): CliOptions;
21
+ /**
22
+ * Whether `--url` names a local database file. `:memory:` and URLs with a
23
+ * scheme (md:, motherduck:, s3://, https://) are not local files. A Windows
24
+ * drive letter such as C:\ is.
25
+ */
26
+ export declare function isLocalDatabasePath(url: string): boolean;
package/dist/client.d.ts CHANGED
@@ -7,6 +7,11 @@ export type RowData = Record<string, unknown>;
7
7
  export interface DuckDBConnectionPool {
8
8
  acquire(): Promise<DuckDBExecutionClient>;
9
9
  release(connection: DuckDBExecutionClient): void | Promise<void>;
10
+ /**
11
+ * Close a leased connection instead of returning it, for example when it
12
+ * may still be inside a transaction. Pools without it get `release()`.
13
+ */
14
+ discard?(connection: DuckDBExecutionClient): Promise<void> | void;
10
15
  close?(): Promise<void> | void;
11
16
  }
12
17
  export declare function isPool(client: DuckDBClientLike): client is DuckDBConnectionPool;
package/dist/columns.d.ts CHANGED
@@ -29,7 +29,7 @@ export declare function formatLiteral(value: unknown, typeHint?: string): string
29
29
  export declare function buildListLiteral(values: unknown[], elementType?: string): SQL;
30
30
  export declare function normalizeArrayPredicateValue<T>(values: ArrayPredicateValue<T>, elementType?: string): SQL | SQLWrapper;
31
31
  export declare function buildStructLiteral(value: Record<string, unknown>, schema?: Record<string, DuckDbTypeName<Primitive>>): SQL;
32
- export declare function buildMapLiteral(value: Record<string, unknown>, valueType?: string): SQL;
32
+ export declare function buildMapLiteral(value: Record<string, unknown>, valueType?: string, keyType?: string): SQL;
33
33
  export declare const duckDbList: <TData = unknown>(name: string, elementType: DuckDbTypeName<AnyColType>) => import("drizzle-orm/pg-core").PgCustomColumnBuilder<{
34
34
  name: string;
35
35
  dataType: "custom";
@@ -62,6 +62,24 @@ export declare const duckDbStruct: <TData extends Record<string, any>>(name: str
62
62
  driverParam: TData;
63
63
  enumValues: undefined;
64
64
  }>;
65
+ /** A UNION value as DuckDB returns it: the member name and its value. */
66
+ export interface DuckDbUnionValue<TTag extends string = string> {
67
+ tag: TTag;
68
+ value: unknown;
69
+ }
70
+ /**
71
+ * UNION column. Values are `{ tag, value }` objects, the shape DuckDB reads
72
+ * back, and are written with `union_value(tag := value)` cast to the member
73
+ * type.
74
+ */
75
+ export declare const duckDbUnion: <TData extends DuckDbUnionValue = DuckDbUnionValue>(name: string, members: Record<string, DuckDbTypeName<Primitive>>) => import("drizzle-orm/pg-core").PgCustomColumnBuilder<{
76
+ name: string;
77
+ dataType: "custom";
78
+ columnType: "PgCustomColumn";
79
+ data: TData;
80
+ driverParam: TData;
81
+ enumValues: undefined;
82
+ }>;
65
83
  /**
66
84
  * JSON column type that wraps values and delays JSON.stringify() to binding time.
67
85
  * This ensures consistent handling with other wrapped types.
package/dist/dialect.d.ts CHANGED
@@ -4,12 +4,21 @@ import { PgDialect, type PgColumn, type PgTable } from 'drizzle-orm/pg-core';
4
4
  import { SQL, type DriverValueEncoder, type QueryTypingsValue } from 'drizzle-orm';
5
5
  import type { BuildRelationalQueryResult } from 'drizzle-orm/relations';
6
6
  import { type QueryWithTypings } from 'drizzle-orm/sql/sql';
7
+ import type { RelationalSelectionItem } from './sql/result-mapper.ts';
7
8
  /**
8
9
  * Query typing for params bound to a non-array column. DuckDB sessions never
9
10
  * coerce these params from Postgres array literal strings.
10
11
  * @internal
11
12
  */
12
13
  export declare const DUCKDB_SCALAR_COLUMN_TYPING: QueryTypingsValue;
14
+ /** @internal */
15
+ export declare function relationalSelectionOf(query: object): readonly RelationalSelectionItem[] | undefined;
16
+ /**
17
+ * Query typing for params bound to a pg-core array column, so sessions can
18
+ * bind its empty array as an empty list.
19
+ * @internal
20
+ */
21
+ export declare const DUCKDB_ARRAY_COLUMN_TYPING: QueryTypingsValue;
13
22
  /**
14
23
  * DuckLake has no sequences, primary keys or indexes, so a journal in a
15
24
  * DuckLake catalog is a plain table. pg_duckdb and other clients without