drizzle-databend 0.1.10 → 0.1.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/dist/session.d.ts CHANGED
@@ -2,13 +2,13 @@ import { entityKind } from 'drizzle-orm/entity';
2
2
  import type { Logger } from 'drizzle-orm/logger';
3
3
  import { PgTransaction } from 'drizzle-orm/pg-core';
4
4
  import type { SelectedFieldsOrdered } from 'drizzle-orm/pg-core/query-builders/select.types';
5
- import type { PgTransactionConfig, PreparedQueryConfig, PgQueryResultHKT } from 'drizzle-orm/pg-core/session';
5
+ import type { PgQueryResultHKT, PgTransactionConfig, PreparedQueryConfig } from 'drizzle-orm/pg-core/session';
6
6
  import { PgPreparedQuery, PgSession } from 'drizzle-orm/pg-core/session';
7
7
  import type { RelationalSchemaConfig, TablesRelationalConfig } from 'drizzle-orm/relations';
8
- import { type Query, type QueryTypingsValue, SQL } from 'drizzle-orm/sql/sql';
8
+ import { type Query, type QueryTypingsValue, type SQL } from 'drizzle-orm/sql/sql';
9
9
  import type { Assume } from 'drizzle-orm/utils';
10
- import type { DatabendDialect } from './dialect.ts';
11
10
  import type { DatabendClientLike, RowData } from './client.ts';
11
+ import type { DatabendDialect } from './dialect.ts';
12
12
  export type { DatabendClientLike, RowData } from './client.ts';
13
13
  export declare class DatabendPreparedQuery<T extends PreparedQueryConfig> extends PgPreparedQuery<T> {
14
14
  private client;
package/package.json CHANGED
@@ -3,16 +3,18 @@
3
3
  "module": "./dist/index.mjs",
4
4
  "main": "./dist/index.mjs",
5
5
  "types": "./dist/index.d.ts",
6
- "version": "0.1.10",
6
+ "version": "0.1.11",
7
7
  "description": "A drizzle ORM driver for use with Databend. Based on drizzle's Postgres driver surface.",
8
8
  "type": "module",
9
9
  "scripts": {
10
- "build": "bun build --target=node ./src/index.ts --outfile=./dist/index.mjs --packages=external && bun run build:declarations",
10
+ "build": "esbuild src/index.ts --bundle --format=esm --platform=node --packages=external --outfile=dist/index.mjs && npm run build:declarations",
11
11
  "build:declarations": "tsc --emitDeclarationOnly --project tsconfig.types.json",
12
- "test": "vitest",
12
+ "test": "vitest run",
13
13
  "db:start": "docker start databend 2>/dev/null || docker run -d --name databend -p 8000:8000 datafuselabs/databend",
14
14
  "db:stop": "docker stop databend",
15
- "db:restart": "docker restart databend"
15
+ "db:restart": "docker restart databend",
16
+ "lint": "biome check src/ test/",
17
+ "typecheck": "tsc --noEmit"
16
18
  },
17
19
  "peerDependencies": {
18
20
  "databend-driver": ">=0.33.0",
@@ -24,9 +26,11 @@
24
26
  }
25
27
  },
26
28
  "devDependencies": {
29
+ "@biomejs/biome": "^2.4.7",
30
+ "@types/node": "^25.5.0",
27
31
  "databend-driver": "^0.33.6",
28
- "@types/bun": "^1.2.5",
29
32
  "drizzle-orm": "0.40.0",
33
+ "esbuild": "^0.25.0",
30
34
  "typescript": "^5.8.2",
31
35
  "vitest": "^1.6.0"
32
36
  },
@@ -42,7 +46,6 @@
42
46
  "engines": {
43
47
  "node": ">=18.17"
44
48
  },
45
- "packageManager": "bun@1.3.6",
46
49
  "keywords": [
47
50
  "drizzle",
48
51
  "databend"
package/src/client.ts CHANGED
@@ -59,7 +59,7 @@ async function withRetry<T>(fn: () => Promise<T>, maxRetries = 2): Promise<T> {
59
59
  catch (error) {
60
60
  lastError = error;
61
61
  if (!isTransientError(error) || attempt === maxRetries) throw error;
62
- await new Promise(r => setTimeout(r, 100 * Math.pow(2, attempt)));
62
+ await new Promise(r => setTimeout(r, 100 * 2 ** attempt));
63
63
  }
64
64
  }
65
65
  throw lastError;
package/src/columns.ts CHANGED
@@ -1,5 +1,5 @@
1
+
1
2
  import { customType } from 'drizzle-orm/pg-core';
2
- import type { SQL } from 'drizzle-orm';
3
3
 
4
4
  /**
5
5
  * Databend VARIANT column type.
package/src/dialect.ts CHANGED
@@ -1,3 +1,8 @@
1
+ import {
2
+ type DriverValueEncoder,
3
+ type QueryTypingsValue,
4
+ sql,
5
+ } from 'drizzle-orm';
1
6
  import { entityKind, is } from 'drizzle-orm/entity';
2
7
  import type { MigrationConfig, MigrationMeta } from 'drizzle-orm/migrator';
3
8
  import {
@@ -10,18 +15,13 @@ import {
10
15
  PgInteger,
11
16
  PgNumeric,
12
17
  PgReal,
13
- PgSession,
18
+ type PgSession,
14
19
  PgSmallInt,
15
20
  PgTime,
16
21
  PgTimestamp,
17
22
  PgTimestampString,
18
23
  PgUUID,
19
24
  } from 'drizzle-orm/pg-core';
20
- import {
21
- sql,
22
- type DriverValueEncoder,
23
- type QueryTypingsValue,
24
- } from 'drizzle-orm';
25
25
 
26
26
  export class DatabendDialect extends PgDialect {
27
27
  static readonly [entityKind]: string = 'DatabendPgDialect';
package/src/driver.ts CHANGED
@@ -1,3 +1,4 @@
1
+ import type { Connection } from 'databend-driver';
1
2
  import { Client } from 'databend-driver';
2
3
  import { entityKind } from 'drizzle-orm/entity';
3
4
  import type { Logger } from 'drizzle-orm/logger';
@@ -5,25 +6,24 @@ import { DefaultLogger } from 'drizzle-orm/logger';
5
6
  import { PgDatabase } from 'drizzle-orm/pg-core/db';
6
7
  import {
7
8
  createTableRelationsHelpers,
8
- extractTablesRelationalConfig,
9
9
  type ExtractTablesWithRelations,
10
+ extractTablesRelationalConfig,
10
11
  type RelationalSchemaConfig,
11
12
  type TablesRelationalConfig,
12
13
  } from 'drizzle-orm/relations';
13
- import { type DrizzleConfig } from 'drizzle-orm/utils';
14
+ import type { DrizzleConfig } from 'drizzle-orm/utils';
15
+ import { closeClientConnection, isPool } from './client.ts';
16
+ import { DatabendDialect } from './dialect.ts';
17
+ import {
18
+ createDatabendConnectionPool,
19
+ type DatabendPoolConfig,
20
+ } from './pool.ts';
14
21
  import type {
15
22
  DatabendClientLike,
16
23
  DatabendQueryResultHKT,
17
24
  DatabendTransaction,
18
25
  } from './session.ts';
19
26
  import { DatabendSession } from './session.ts';
20
- import { DatabendDialect } from './dialect.ts';
21
- import { isPool, closeClientConnection } from './client.ts';
22
- import {
23
- createDatabendConnectionPool,
24
- type DatabendPoolConfig,
25
- } from './pool.ts';
26
- import type { Connection } from 'databend-driver';
27
27
 
28
28
  export interface DatabendDriverOptions {
29
29
  logger?: Logger;
package/src/index.ts CHANGED
@@ -1,6 +1,6 @@
1
- export * from './driver.ts';
2
- export * from './session.ts';
1
+ export * from './client.ts';
3
2
  export * from './columns.ts';
3
+ export * from './driver.ts';
4
4
  export * from './migrator.ts';
5
- export * from './client.ts';
6
5
  export * from './pool.ts';
6
+ export * from './session.ts';
package/src/migrator.ts CHANGED
@@ -1,7 +1,7 @@
1
1
  import type { MigrationConfig } from 'drizzle-orm/migrator';
2
2
  import { readMigrationFiles } from 'drizzle-orm/migrator';
3
- import type { DatabendDatabase } from './driver.ts';
4
3
  import type { PgSession } from 'drizzle-orm/pg-core/session';
4
+ import type { DatabendDatabase } from './driver.ts';
5
5
 
6
6
  export type DatabendMigrationConfig = MigrationConfig | string;
7
7
 
package/src/pool.ts CHANGED
@@ -215,7 +215,9 @@ export function createDatabendConnectionPool(
215
215
  toClose.map((item) => closeClientConnection(item.connection))
216
216
  );
217
217
  total = Math.max(0, total - toClose.length);
218
- toClose.forEach((item) => metadata.delete(item.connection));
218
+ for (const item of toClose) {
219
+ metadata.delete(item.connection);
220
+ }
219
221
 
220
222
  const maxWait = 5000;
221
223
  const start = Date.now();
package/src/session.ts CHANGED
@@ -1,23 +1,22 @@
1
+ import type { Connection } from 'databend-driver';
1
2
  import { entityKind } from 'drizzle-orm/entity';
3
+ import { TransactionRollbackError } from 'drizzle-orm/errors';
2
4
  import type { Logger } from 'drizzle-orm/logger';
3
5
  import { NoopLogger } from 'drizzle-orm/logger';
4
6
  import { PgTransaction } from 'drizzle-orm/pg-core';
5
7
  import type { SelectedFieldsOrdered } from 'drizzle-orm/pg-core/query-builders/select.types';
6
8
  import type {
9
+ PgQueryResultHKT,
7
10
  PgTransactionConfig,
8
11
  PreparedQueryConfig,
9
- PgQueryResultHKT,
10
12
  } from 'drizzle-orm/pg-core/session';
11
13
  import { PgPreparedQuery, PgSession } from 'drizzle-orm/pg-core/session';
12
14
  import type {
13
15
  RelationalSchemaConfig,
14
16
  TablesRelationalConfig,
15
17
  } from 'drizzle-orm/relations';
16
- import { fillPlaceholders, type Query, type QueryTypingsValue, SQL, sql } from 'drizzle-orm/sql/sql';
18
+ import { fillPlaceholders, type Query, type QueryTypingsValue, type SQL, sql } from 'drizzle-orm/sql/sql';
17
19
  import type { Assume } from 'drizzle-orm/utils';
18
- import { mapResultRow } from './sql/result-mapper.ts';
19
- import { TransactionRollbackError } from 'drizzle-orm/errors';
20
- import type { DatabendDialect } from './dialect.ts';
21
20
  import type {
22
21
  DatabendClientLike,
23
22
  DatabendConnectionPool,
@@ -28,7 +27,8 @@ import {
28
27
  executeOnClient,
29
28
  isPool,
30
29
  } from './client.ts';
31
- import type { Connection } from 'databend-driver';
30
+ import type { DatabendDialect } from './dialect.ts';
31
+ import { mapResultRow } from './sql/result-mapper.ts';
32
32
 
33
33
  export type { DatabendClientLike, RowData } from './client.ts';
34
34
 
@@ -1,11 +1,11 @@
1
1
  import {
2
+ type AnyColumn,
2
3
  Column,
3
- SQL,
4
+ type DriverValueDecoder,
4
5
  getTableName,
5
6
  is,
6
- type AnyColumn,
7
- type DriverValueDecoder,
8
7
  type SelectedFieldsOrdered,
8
+ SQL,
9
9
  } from 'drizzle-orm';
10
10
  import {
11
11
  PgCustomColumn,
@@ -214,7 +214,6 @@ export function mapResultRow<TResult>(
214
214
  if (nullifyMap[objectName] && nullifyMap[objectName] !== tableName) {
215
215
  nullifyMap[objectName] = false;
216
216
  }
217
- continue;
218
217
  }
219
218
  }
220
219
  return acc;
@@ -1,4 +1,4 @@
1
- import { Column, SQL, getTableName, is, sql } from 'drizzle-orm';
1
+ import { Column, getTableName, is, SQL, sql } from 'drizzle-orm';
2
2
  import type { SelectedFields } from 'drizzle-orm/pg-core';
3
3
 
4
4
  function mapEntries(