@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 +2 -1
- package/dist/bin/duckdb-introspect-args.d.ts +6 -0
- package/dist/client.d.ts +5 -0
- package/dist/columns.d.ts +19 -1
- package/dist/dialect.d.ts +9 -0
- package/dist/duckdb-introspect.mjs +2594 -1993
- package/dist/helpers.d.ts +1 -1
- package/dist/helpers.mjs +71 -14
- package/dist/index.mjs +3938 -3259
- package/dist/jev.d.ts +27 -5
- package/dist/motherduck.d.ts +75 -2
- package/dist/olap.d.ts +6 -0
- package/dist/pool.d.ts +15 -4
- package/dist/session.d.ts +24 -2
- package/dist/sql/array-bounds-text.d.ts +9 -0
- package/dist/sql/ast-transformer.d.ts +5 -3
- package/dist/sql/result-mapper.d.ts +22 -0
- package/dist/sql/visitors/column-qualifier.d.ts +6 -0
- package/dist/time.d.ts +11 -0
- package/package.json +1 -1
package/dist/jev.d.ts
CHANGED
|
@@ -4,7 +4,11 @@ export interface MotherDuckJevLabel {
|
|
|
4
4
|
label: string;
|
|
5
5
|
description?: string | null;
|
|
6
6
|
}
|
|
7
|
-
|
|
7
|
+
/**
|
|
8
|
+
* Plain strings and `{ label, description }` objects. When a list mixes both,
|
|
9
|
+
* strings become labels without a description, since a SQL list holds one type.
|
|
10
|
+
*/
|
|
11
|
+
export type MotherDuckJevCriteria = readonly (string | MotherDuckJevLabel)[];
|
|
8
12
|
export type MotherDuckJevImageFormat = 'png' | 'jpg' | 'jpeg';
|
|
9
13
|
export interface MotherDuckJevImage {
|
|
10
14
|
/** Name the instructions use to refer to the image, in backticks. */
|
|
@@ -14,8 +18,25 @@ export interface MotherDuckJevImage {
|
|
|
14
18
|
/** Still image encoding. MotherDuck assumes `jpg` when omitted. */
|
|
15
19
|
format?: MotherDuckJevImageFormat;
|
|
16
20
|
}
|
|
17
|
-
/**
|
|
18
|
-
|
|
21
|
+
/**
|
|
22
|
+
* One image. Without `name` or `format` it is sent as a bare BLOB that the
|
|
23
|
+
* instructions call `image`. With either, it is sent as a single named image
|
|
24
|
+
* whose name defaults to `image`.
|
|
25
|
+
*/
|
|
26
|
+
export interface MotherDuckJevSingleImage {
|
|
27
|
+
/** Image bytes, or a SQL expression that yields a BLOB. */
|
|
28
|
+
image: Uint8Array | SQLWrapper;
|
|
29
|
+
/** Name the instructions use to refer to the image. Defaults to `image`. */
|
|
30
|
+
name?: string;
|
|
31
|
+
/** Still image encoding. MotherDuck assumes `jpg` when omitted. */
|
|
32
|
+
format?: MotherDuckJevImageFormat;
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* A text value or expression, image bytes, one image, or a list of named
|
|
36
|
+
* images. A SQL expression is sent as text. Wrap it as `{ image: expr }` to
|
|
37
|
+
* send it as an image.
|
|
38
|
+
*/
|
|
39
|
+
export type MotherDuckJevInput = string | SQLWrapper | Uint8Array | MotherDuckJevSingleImage | readonly MotherDuckJevImage[];
|
|
19
40
|
export type MotherDuckJevQuestion = {
|
|
20
41
|
type: 'noul';
|
|
21
42
|
instructions: string;
|
|
@@ -126,8 +147,9 @@ export type MotherDuckPromptJevResult<O extends MotherDuckPromptJevOptions> = O
|
|
|
126
147
|
} ? MotherDuckJevMultipleChoiceResult : number;
|
|
127
148
|
/**
|
|
128
149
|
* Build prompt_jev with literal question metadata required by MotherDuck's
|
|
129
|
-
* binder. The input remains a bound value or SQL expression. Pass
|
|
130
|
-
* named images to classify images or to locate
|
|
150
|
+
* binder. The input remains a bound value or SQL expression. Pass image
|
|
151
|
+
* bytes, one image or a list of named images to classify images or to locate
|
|
152
|
+
* a region with `box`.
|
|
131
153
|
*/
|
|
132
154
|
export declare function mdPromptJev<O extends MotherDuckPromptJevOptions>(input: MotherDuckJevInput, options: O): SQL<MotherDuckPromptJevResult<O> | null>;
|
|
133
155
|
export {};
|
package/dist/motherduck.d.ts
CHANGED
|
@@ -94,6 +94,17 @@ export type MotherDuckFlightVersionRow = {
|
|
|
94
94
|
max_runtime_sec?: number;
|
|
95
95
|
/** Returned by MotherDuck clients from 1.5.5 on. */
|
|
96
96
|
instance_type?: MotherDuckFlightInstanceType | (string & {}) | null;
|
|
97
|
+
/**
|
|
98
|
+
* The version's metadata, currently only a `chart` key when the Flight has
|
|
99
|
+
* a chart. Returned by `md_get_flight_version` on current MotherDuck
|
|
100
|
+
* clients. `md_list_flight_versions` leaves it out. `db.execute` returns
|
|
101
|
+
* MAP values as key and value entries, so select `metadata['chart']` to read
|
|
102
|
+
* the chart as a string.
|
|
103
|
+
*/
|
|
104
|
+
metadata?: {
|
|
105
|
+
key: string;
|
|
106
|
+
value: string;
|
|
107
|
+
}[] | Record<string, string> | Map<string, string> | null;
|
|
97
108
|
};
|
|
98
109
|
export type MotherDuckFlightRunRow = {
|
|
99
110
|
run_id: string;
|
|
@@ -136,6 +147,47 @@ export type MotherDuckFlightDeleteRow = {
|
|
|
136
147
|
export type MotherDuckFlightCancelRunRow = {
|
|
137
148
|
canceled_count: number | bigint;
|
|
138
149
|
};
|
|
150
|
+
export type MotherDuckFlightGranteeRow = {
|
|
151
|
+
/** NULL when the caller may read the Flight but not manage its grants. */
|
|
152
|
+
grantee_name: string | null;
|
|
153
|
+
grantee_type: 'user' | 'role' | 'organization' | (string & {});
|
|
154
|
+
privilege: 'run' | (string & {});
|
|
155
|
+
};
|
|
156
|
+
/** Flight metadata that `md_create_flight` and `md_update_flight` accept. */
|
|
157
|
+
export type MotherDuckFlightMetadata = {
|
|
158
|
+
/**
|
|
159
|
+
* A chart of the Flight, such as Mermaid flowchart source. On update, an
|
|
160
|
+
* empty string clears the chart and NULL leaves it unchanged.
|
|
161
|
+
*/
|
|
162
|
+
chart?: string | null;
|
|
163
|
+
};
|
|
164
|
+
export type MotherDuckRoleType = 'preset' | 'custom';
|
|
165
|
+
export type MotherDuckRoleRow = {
|
|
166
|
+
role_name: string;
|
|
167
|
+
role_type: MotherDuckRoleType | (string & {});
|
|
168
|
+
included_roles: string[] | null;
|
|
169
|
+
created_at: Date | string | null;
|
|
170
|
+
};
|
|
171
|
+
/**
|
|
172
|
+
* A direct member of a role. `email` and `is_service_account` are NULL for a
|
|
173
|
+
* role member and `role_type` is NULL for a user member.
|
|
174
|
+
*/
|
|
175
|
+
export type MotherDuckRoleMemberRow = {
|
|
176
|
+
member_type: 'user' | 'role' | (string & {});
|
|
177
|
+
member_name: string;
|
|
178
|
+
email: string | null;
|
|
179
|
+
is_service_account: boolean | null;
|
|
180
|
+
role_type: MotherDuckRoleType | (string & {}) | null;
|
|
181
|
+
granted_at: Date | string | null;
|
|
182
|
+
};
|
|
183
|
+
/** A role held directly or through the role hierarchy. */
|
|
184
|
+
export type MotherDuckGrantedRoleRow = {
|
|
185
|
+
role_name: string;
|
|
186
|
+
role_type: MotherDuckRoleType | (string & {});
|
|
187
|
+
is_direct: boolean;
|
|
188
|
+
/** When the direct grant was made. NULL for an inherited role. */
|
|
189
|
+
granted_at: Date | string | null;
|
|
190
|
+
};
|
|
139
191
|
/** @deprecated Use MotherDuckFlightSummaryRow. */
|
|
140
192
|
export type MotherDuckJobSummaryRow = {
|
|
141
193
|
job_id: string;
|
|
@@ -241,6 +293,7 @@ export interface MotherDuckCreateFlightOptions {
|
|
|
241
293
|
requirementsTxt?: string | SQLWrapper | null;
|
|
242
294
|
maxRuntimeSec?: number | SQLWrapper;
|
|
243
295
|
instanceType?: MotherDuckFlightInstanceType | SQLWrapper;
|
|
296
|
+
metadata?: MotherDuckFlightMetadata | SQLWrapper | null;
|
|
244
297
|
}
|
|
245
298
|
export interface MotherDuckUpdateFlightOptions {
|
|
246
299
|
flightId: string | SQLWrapper;
|
|
@@ -254,6 +307,8 @@ export interface MotherDuckUpdateFlightOptions {
|
|
|
254
307
|
maxRuntimeSec?: number | SQLWrapper;
|
|
255
308
|
/** A different size creates a new Flight version. */
|
|
256
309
|
instanceType?: MotherDuckFlightInstanceType | SQLWrapper;
|
|
310
|
+
/** Keys left out or set to NULL keep their current value. */
|
|
311
|
+
metadata?: MotherDuckFlightMetadata | SQLWrapper | null;
|
|
257
312
|
}
|
|
258
313
|
export interface MotherDuckRunFlightOptions {
|
|
259
314
|
config?: Record<string, string | null> | SQLWrapper | null;
|
|
@@ -303,6 +358,17 @@ export declare function mdSessionRoles(): SQL<string[]>;
|
|
|
303
358
|
* case-insensitive and follows the role hierarchy.
|
|
304
359
|
*/
|
|
305
360
|
export declare function mdIsRoleInSession(role: string | readonly string[] | SQLWrapper): SQL<boolean | null>;
|
|
361
|
+
/** The organization's roles, as `SHOW ALL ROLES` lists them. */
|
|
362
|
+
export declare function mdListRoles(): SQL;
|
|
363
|
+
/**
|
|
364
|
+
* A role's direct members, users then roles, as `SHOW USERS OF ROLE` and
|
|
365
|
+
* `SHOW ROLES OF ROLE` list them. Filter on `email` to find a username.
|
|
366
|
+
*/
|
|
367
|
+
export declare function mdListRoleMembers(role: string | SQLWrapper): SQL;
|
|
368
|
+
/** Roles a user holds, transitively, as `SHOW ROLES TO USER` lists them. */
|
|
369
|
+
export declare function mdListRolesGrantedToUser(user: string | SQLWrapper): SQL;
|
|
370
|
+
/** Roles a role inherits, transitively, as `SHOW ROLES TO ROLE` lists them. */
|
|
371
|
+
export declare function mdListRolesGrantedToRole(role: string | SQLWrapper): SQL;
|
|
306
372
|
export declare function mdListDives(options?: MotherDuckListDivesOptions): SQL;
|
|
307
373
|
export declare function mdGetDive(id: string | SQLWrapper): SQL;
|
|
308
374
|
export declare function mdCreateDive(options: MotherDuckCreateDiveOptions): SQL;
|
|
@@ -328,8 +394,9 @@ export declare function mdDeleteFlight(flightId: string | SQLWrapper): SQL;
|
|
|
328
394
|
/**
|
|
329
395
|
* Start a run of a Flight you own or hold `run` access on. The run uses the
|
|
330
396
|
* owner's settings, secrets and token. `config` can only override keys the
|
|
331
|
-
* Flight already defines.
|
|
332
|
-
* runs
|
|
397
|
+
* Flight already defines. With run access alone, `mdGetFlightRun` reads the
|
|
398
|
+
* runs you started, while listing runs and reading logs stay limited to the
|
|
399
|
+
* owner and organization admins.
|
|
333
400
|
*/
|
|
334
401
|
export declare function mdRunFlight(flightId: string | SQLWrapper, options?: MotherDuckRunFlightOptions): SQL;
|
|
335
402
|
export declare function mdCancelFlightRun(flightId: string | SQLWrapper, runNumber: number | bigint | SQLWrapper): SQL;
|
|
@@ -348,6 +415,12 @@ export declare function mdListFlightVersions(flightId: string | SQLWrapper, opti
|
|
|
348
415
|
/** @deprecated Use mdListFlightVersions. */
|
|
349
416
|
export declare function mdFlightVersions(flightId: string | SQLWrapper, options?: MotherDuckPaginationOptions): SQL;
|
|
350
417
|
export declare function mdGetFlightVersion(flightId: string | SQLWrapper, versionNumber: number | SQLWrapper): SQL;
|
|
418
|
+
/**
|
|
419
|
+
* Who holds which privilege on a Flight, as `SHOW GRANTS ON FLIGHT` lists it.
|
|
420
|
+
* Grant and revoke access with `GRANT RUN ON FLIGHT` and `REVOKE RUN ON
|
|
421
|
+
* FLIGHT`.
|
|
422
|
+
*/
|
|
423
|
+
export declare function mdListFlightGrantees(flightId: string | SQLWrapper): SQL;
|
|
351
424
|
/** @deprecated Use mdListFlights. */
|
|
352
425
|
export declare function mdJobs(options?: MotherDuckPaginationOptions): SQL;
|
|
353
426
|
/** @deprecated Use mdCreateFlight. */
|
package/dist/olap.d.ts
CHANGED
|
@@ -7,6 +7,12 @@ export declare const countN: (expr?: SQLWrapper) => SQL<number>;
|
|
|
7
7
|
export declare const sumN: (expr: SQLWrapper) => SQL<number>;
|
|
8
8
|
export declare const avgN: (expr: SQLWrapper) => SQL<number>;
|
|
9
9
|
export declare const sumDistinctN: (expr: SQLWrapper) => SQL<number>;
|
|
10
|
+
/**
|
|
11
|
+
* DuckDB keeps a DECIMAL column's scale in PERCENTILE_CONT, so the median of
|
|
12
|
+
* 1.10 and 2.25 is 1.67. DECIMAL columns are read as DOUBLE to interpolate
|
|
13
|
+
* like Postgres. Other expressions pass through, because DuckDB cannot cast
|
|
14
|
+
* TIMESTAMP or DATE to DOUBLE. Cast a DECIMAL SQL expression yourself.
|
|
15
|
+
*/
|
|
10
16
|
export declare const percentileCont: (p: number, expr: SQLWrapper) => SQL<number>;
|
|
11
17
|
export declare const median: (expr: SQLWrapper) => SQL<number>;
|
|
12
18
|
export declare const anyValue: <T = unknown>(expr: SQLWrapper) => SQL<T>;
|
package/dist/pool.d.ts
CHANGED
|
@@ -1,19 +1,25 @@
|
|
|
1
1
|
import { DuckDBConnection, DuckDBInstance } from '@duckdb/node-api';
|
|
2
|
-
import { type DuckDBConnectionPool } from './client.ts';
|
|
2
|
+
import { type DuckDBConnectionPool, type DuckDBExecutionClient } from './client.ts';
|
|
3
3
|
/** Pool size presets for different MotherDuck instance types */
|
|
4
4
|
export type PoolPreset = 'pulse' | 'standard' | 'jumbo' | 'mega' | 'giga' | 'local' | 'memory';
|
|
5
5
|
/** Pool sizes optimized for each MotherDuck instance type */
|
|
6
6
|
export declare const POOL_PRESETS: Record<PoolPreset, number>;
|
|
7
7
|
export interface DuckDBPoolConfig {
|
|
8
|
-
/** Maximum concurrent connections. Defaults to 4. */
|
|
8
|
+
/** Maximum concurrent connections, at least 1. Defaults to 4. */
|
|
9
9
|
size?: number;
|
|
10
10
|
/** Queue wait timeout in ms, excluding connection creation/setup. Defaults to 30000. */
|
|
11
11
|
acquireTimeout?: number;
|
|
12
12
|
/** Maximum number of requests waiting for a connection. Defaults to 100. */
|
|
13
13
|
maxWaitingRequests?: number;
|
|
14
|
-
/**
|
|
14
|
+
/**
|
|
15
|
+
* Max time (ms) a connection may live before being recycled. `0` recycles a
|
|
16
|
+
* connection after every use. Checked on acquire and release.
|
|
17
|
+
*/
|
|
15
18
|
maxLifetimeMs?: number;
|
|
16
|
-
/**
|
|
19
|
+
/**
|
|
20
|
+
* Max idle time (ms) before an idle connection is discarded. `0` discards
|
|
21
|
+
* every idle connection. Checked on acquire and release, not by a timer.
|
|
22
|
+
*/
|
|
17
23
|
idleTimeoutMs?: number;
|
|
18
24
|
}
|
|
19
25
|
/**
|
|
@@ -28,6 +34,7 @@ export interface DuckDBConnectionPoolOptions extends DuckDBPoolConfig {
|
|
|
28
34
|
export declare function createDuckDBConnectionPool(instance: DuckDBInstance, options?: DuckDBConnectionPoolOptions): DuckDBConnectionPool & {
|
|
29
35
|
size: number;
|
|
30
36
|
close(): Promise<void>;
|
|
37
|
+
discard(connection: DuckDBExecutionClient): Promise<void>;
|
|
31
38
|
stats(): DuckDBPoolStats;
|
|
32
39
|
};
|
|
33
40
|
export interface DuckDBPoolStats {
|
|
@@ -39,6 +46,10 @@ export interface DuckDBPoolStats {
|
|
|
39
46
|
pending: number;
|
|
40
47
|
created: number;
|
|
41
48
|
recycled: number;
|
|
49
|
+
/** Connections closed through discard(). */
|
|
50
|
+
discarded: number;
|
|
51
|
+
/** Failures while closing recycled or discarded connections. */
|
|
52
|
+
closeErrors: number;
|
|
42
53
|
queued: number;
|
|
43
54
|
queueWaitMs: number;
|
|
44
55
|
timedOut: number;
|
package/dist/session.d.ts
CHANGED
|
@@ -10,6 +10,7 @@ import type { RelationalSchemaConfig, TablesRelationalConfig } from 'drizzle-orm
|
|
|
10
10
|
import { type Query, SQL, type SQLWrapper } from 'drizzle-orm/sql/sql';
|
|
11
11
|
import type { WithSubquery } from 'drizzle-orm/subquery';
|
|
12
12
|
import type { Assume } from 'drizzle-orm/utils';
|
|
13
|
+
import { type RelationalSelectionItem } from './sql/result-mapper.ts';
|
|
13
14
|
import type { DuckDBDialect } from './dialect.ts';
|
|
14
15
|
import type { DuckDBClientLike, RowData } from './client.ts';
|
|
15
16
|
import { type ExecuteBatchesRawChunk, type ExecuteInBatchesOptions } from './client.ts';
|
|
@@ -41,9 +42,12 @@ export declare class DuckDBPreparedQuery<T extends PreparedQueryConfig> extends
|
|
|
41
42
|
private scalarParamIndexes?;
|
|
42
43
|
private onStatementError?;
|
|
43
44
|
private decimalMode;
|
|
45
|
+
private waitForTransactions;
|
|
46
|
+
private relationalSelection?;
|
|
44
47
|
static readonly [entityKind]: string;
|
|
45
48
|
private resultMapper?;
|
|
46
|
-
|
|
49
|
+
private relationalRowNormalizer?;
|
|
50
|
+
constructor(client: DuckDBClientLike, dialect: DuckDBDialect, queryString: string, params: unknown[], logger: Logger, fields: SelectedFieldsOrdered | undefined, _isResponseInArrayMode: boolean, customResultMapper: ((rows: unknown[][]) => T['execute']) | undefined, rejectStringArrayLiterals: boolean, prepareCache: PreparedStatementCacheConfig | undefined, queryMetadata?: QueryMetadata, cacheConfig?: CacheConfig, warnOnStringArrayLiteral?: ((sql: string) => void) | undefined, scalarParamIndexes?: ReadonlySet<number> | undefined, onStatementError?: ((error: unknown) => void) | undefined, decimalMode?: 'number' | 'string', waitForTransactions?: boolean, relationalSelection?: readonly RelationalSelectionItem[] | undefined);
|
|
47
51
|
execute(placeholderValues?: Record<string, unknown> | undefined): Promise<T['execute']>;
|
|
48
52
|
private executeQuery;
|
|
49
53
|
all(placeholderValues?: Record<string, unknown> | undefined): Promise<T['all']>;
|
|
@@ -67,10 +71,15 @@ export declare class DuckDBSession<TFullSchema extends Record<string, unknown> =
|
|
|
67
71
|
private prepareCache;
|
|
68
72
|
private hasWarnedArrayLiteral;
|
|
69
73
|
private rollbackOnly;
|
|
74
|
+
private rollbackOnlyCause;
|
|
75
|
+
private openStreams;
|
|
70
76
|
private statementFailures;
|
|
71
77
|
constructor(client: DuckDBClientLike, dialect: DuckDBDialect, schema: RelationalSchemaConfig<TSchema> | undefined, options?: DuckDBSessionOptions);
|
|
72
78
|
prepareQuery<T extends PreparedQueryConfig = PreparedQueryConfig>(query: Query, fields: SelectedFieldsOrdered | undefined, name: string | undefined, isResponseInArrayMode: boolean, customResultMapper?: (rows: unknown[][]) => T['execute'], queryMetadata?: QueryMetadata, cacheConfig?: CacheConfig): PgPreparedQuery<T>;
|
|
79
|
+
/** Root sessions on one shared connection queue behind its transaction. */
|
|
80
|
+
private waitsForTransactions;
|
|
73
81
|
transaction<T>(transaction: (tx: DuckDBTransaction<TFullSchema, TSchema>) => Promise<T>, config?: PgTransactionConfig): Promise<T>;
|
|
82
|
+
private runTransaction;
|
|
74
83
|
private warnOnStringArrayLiteral;
|
|
75
84
|
private recordStatementFailure;
|
|
76
85
|
/**
|
|
@@ -79,13 +88,26 @@ export declare class DuckDBSession<TFullSchema extends Record<string, unknown> =
|
|
|
79
88
|
* anything, so probe the transaction before committing.
|
|
80
89
|
*/
|
|
81
90
|
private assertTransactionNotAborted;
|
|
91
|
+
/**
|
|
92
|
+
* Roll back and report whether the connection is out of the transaction.
|
|
93
|
+
* DuckDB reports "no transaction is active" when a failed statement or
|
|
94
|
+
* COMMIT already ended it. Any other failure keeps the original error.
|
|
95
|
+
*/
|
|
82
96
|
private rollbackQuietly;
|
|
97
|
+
/**
|
|
98
|
+
* A stream left open by the callback keeps the connection busy, so COMMIT
|
|
99
|
+
* and ROLLBACK would fail. Close it, and make further reads throw instead
|
|
100
|
+
* of ending early.
|
|
101
|
+
*/
|
|
102
|
+
private closeOpenStreams;
|
|
103
|
+
private rollbackOnlyError;
|
|
83
104
|
private prepareQueryExecution;
|
|
84
105
|
private trackStreamFailures;
|
|
106
|
+
private afterOpenTransaction;
|
|
85
107
|
executeBatches<T extends RowData = RowData>(query: SQL, options?: ExecuteInBatchesOptions): AsyncGenerator<GenericRowData<T>[], void, void>;
|
|
86
108
|
executeBatchesRaw(query: SQL, options?: ExecuteInBatchesOptions): AsyncGenerator<ExecuteBatchesRawChunk, void, void>;
|
|
87
109
|
executeArrow(query: SQL): Promise<unknown>;
|
|
88
|
-
markRollbackOnly(): void;
|
|
110
|
+
markRollbackOnly(cause?: unknown): void;
|
|
89
111
|
isRollbackOnly(): boolean;
|
|
90
112
|
}
|
|
91
113
|
export declare class DuckDBTransaction<TFullSchema extends Record<string, unknown>, TSchema extends TablesRelationalConfig> extends PgTransaction<DuckDBQueryResultHKT, TFullSchema, TSchema> {
|
|
@@ -8,6 +8,15 @@
|
|
|
8
8
|
* array_upper. This pass rewrites only the call itself and copies every other
|
|
9
9
|
* character, so literals, parameters and identifiers cannot change.
|
|
10
10
|
*/
|
|
11
|
+
/** The dollar-quote tag at `index`, such as `$$` or `$a1$`. */
|
|
12
|
+
export declare function dollarTagAt(query: string, index: number): string | undefined;
|
|
13
|
+
/**
|
|
14
|
+
* True when the quote at `index` opens an E'...' string, where a backslash
|
|
15
|
+
* escapes the next character (E'it\'s').
|
|
16
|
+
*/
|
|
17
|
+
export declare function isEscapeStringAt(query: string, index: number): boolean;
|
|
18
|
+
/** Index just past a string, quoted identifier or comment at `index`. */
|
|
19
|
+
export declare function skipQuotedOrComment(query: string, index: number): number;
|
|
11
20
|
/**
|
|
12
21
|
* Rewrite first-dimension array_lower and array_upper calls. Returns the
|
|
13
22
|
* query unchanged when there is nothing to rewrite.
|
|
@@ -9,9 +9,11 @@
|
|
|
9
9
|
* Postgres array operators (@>, <@, &&) are native in DuckDB and pass through.
|
|
10
10
|
*
|
|
11
11
|
* Re-printing the AST is lossy (node-sql-parser applies backslash escapes to
|
|
12
|
-
* string literals
|
|
13
|
-
*
|
|
14
|
-
*
|
|
12
|
+
* string literals, misreads IS DISTINCT FROM $1, rounds large negative
|
|
13
|
+
* numbers, prints `- -x` as the comment `--x` and reads ANTI or ASOF as a
|
|
14
|
+
* table alias), so the rewritten SQL is only used when its literals,
|
|
15
|
+
* parameters, numbers and quoted identifiers match the original query and it
|
|
16
|
+
* has no comments.
|
|
15
17
|
*
|
|
16
18
|
* Performance optimizations:
|
|
17
19
|
* - LRU cache for transformed queries (avoids re-parsing identical queries)
|
|
@@ -1,12 +1,34 @@
|
|
|
1
1
|
import { type AnyColumn, type DriverValueDecoder, type SelectedFieldsOrdered } from 'drizzle-orm';
|
|
2
2
|
export declare function resolveFieldDecoder(field: unknown): DriverValueDecoder<unknown, unknown>;
|
|
3
3
|
export declare function normalizeInet(value: unknown): unknown;
|
|
4
|
+
/**
|
|
5
|
+
* The driver reads DuckDB's infinite timestamps as these strings, since a
|
|
6
|
+
* Date cannot hold them. Decoders keep them instead of an invalid Date.
|
|
7
|
+
*/
|
|
8
|
+
export declare function isInfiniteTimestamp(value: unknown): value is string;
|
|
4
9
|
export declare function normalizeTimestampString(value: unknown, withTimezone: boolean): string | unknown;
|
|
5
10
|
export declare function normalizeTimestamp(value: unknown, withTimezone: boolean): Date | unknown;
|
|
6
11
|
export declare function normalizeDateString(value: unknown): string | unknown;
|
|
7
12
|
export declare function normalizeDateValue(value: unknown): Date | unknown;
|
|
8
13
|
export declare function normalizeTime(value: unknown): string | unknown;
|
|
14
|
+
/**
|
|
15
|
+
* DuckDB returns INTERVAL values as `{ months, days, micros }`. Format them
|
|
16
|
+
* the way DuckDB casts an INTERVAL to VARCHAR, for example
|
|
17
|
+
* `1 year 2 months 3 days 04:05:06`, which DuckDB and Postgres parse back.
|
|
18
|
+
*/
|
|
9
19
|
export declare function normalizeInterval(value: unknown): string | unknown;
|
|
20
|
+
/**
|
|
21
|
+
* Normalize the top-level values of relational query rows (`db.query`) in
|
|
22
|
+
* place. Drizzle decodes them afterwards with each field's decoder, so they
|
|
23
|
+
* must arrive the way flat selects see them. JSON relation fields are left
|
|
24
|
+
* alone.
|
|
25
|
+
*/
|
|
26
|
+
export declare function compileRelationalRowNormalizer(selection: readonly RelationalSelectionItem[]): (row: unknown[]) => void;
|
|
27
|
+
/** The part of Drizzle's relational query selection the driver reads. */
|
|
28
|
+
export interface RelationalSelectionItem {
|
|
29
|
+
isJson: boolean;
|
|
30
|
+
field: unknown;
|
|
31
|
+
}
|
|
10
32
|
export declare function mapResultRow<TResult>(columns: SelectedFieldsOrdered<AnyColumn>, row: unknown[], joinsNotNullableMap: Record<string, boolean> | undefined): TResult;
|
|
11
33
|
/** Resolve stable field metadata once, before mapping any result rows. */
|
|
12
34
|
export declare function compileResultMapper<TResult>(columns: SelectedFieldsOrdered<AnyColumn>, joinsNotNullableMap?: Record<string, boolean>): (row: unknown[]) => TResult;
|
|
@@ -8,6 +8,12 @@
|
|
|
8
8
|
* source unless the qualified side already is that source. When that cannot
|
|
9
9
|
* be decided, the reference is left as it is.
|
|
10
10
|
*
|
|
11
|
+
* This is a guess made without the catalog. When the unqualified column
|
|
12
|
+
* actually belongs to the other source, as in `ON u.id = tid` with `tid` a
|
|
13
|
+
* column of `u`, the rewrite names a column that does not exist and a query
|
|
14
|
+
* DuckDB would have accepted fails to bind. That is why it only runs when
|
|
15
|
+
* qualifyRawJoinColumns is enabled.
|
|
16
|
+
*
|
|
11
17
|
* Other unqualified references to the same name in SELECT, WHERE, GROUP BY,
|
|
12
18
|
* HAVING and ORDER BY get the qualifier chosen in the ON clause. Names that
|
|
13
19
|
* were given different qualifiers, and USING columns, are left unqualified.
|
package/dist/time.d.ts
CHANGED
|
@@ -1,3 +1,8 @@
|
|
|
1
|
+
export declare function rememberDroppedMicros(date: Date, micros: number): void;
|
|
2
|
+
/** Microseconds below the Date's millisecond, as read from DuckDB. */
|
|
3
|
+
export declare function dateSubMillisecondMicros(date: Date): number;
|
|
4
|
+
/** Microseconds since the Unix epoch, including digits a Date drops. */
|
|
5
|
+
export declare function dateToMicros(date: Date): bigint;
|
|
1
6
|
/**
|
|
2
7
|
* Format bigint TIME microseconds as HH:MM:SS.mmm, adding the microsecond
|
|
3
8
|
* digits only when the value has sub-millisecond precision.
|
|
@@ -32,6 +37,12 @@ export declare function utcTimestampString(parts: TimestampStringParts): string
|
|
|
32
37
|
* `+00` because the value is rendered in UTC.
|
|
33
38
|
*/
|
|
34
39
|
export declare function timestampStringFromMicros(micros: bigint, withTimezone: boolean): string;
|
|
40
|
+
/**
|
|
41
|
+
* Format a Date's UTC day the way DuckDB prints a DATE. Years past 9999 keep
|
|
42
|
+
* all their digits and years before 1 AD use the `(BC)` suffix, where
|
|
43
|
+
* `toISOString()` would print `+010000` or `-000001`.
|
|
44
|
+
*/
|
|
45
|
+
export declare function dateStringFromDate(value: Date): string;
|
|
35
46
|
/**
|
|
36
47
|
* Format INTERVAL parts the way DuckDB casts an INTERVAL to VARCHAR, for
|
|
37
48
|
* example `1 year 2 months 3 days 04:05:06.5`. DuckDB parses this text back.
|
package/package.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"name": "@leonardovida-md/drizzle-neo-duckdb",
|
|
3
3
|
"main": "./dist/index.mjs",
|
|
4
4
|
"types": "./dist/index.d.ts",
|
|
5
|
-
"version": "2.
|
|
5
|
+
"version": "2.3.0",
|
|
6
6
|
"description": "A drizzle ORM client for use with DuckDB. Based on drizzle's Postgres client.",
|
|
7
7
|
"type": "module",
|
|
8
8
|
"scripts": {
|