@prisma/adapter-mariadb 7.6.0-dev.14 → 7.6.0-dev.15
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/index.d.mts +13 -4
- package/dist/index.d.ts +13 -4
- package/dist/index.js +34 -18
- package/dist/index.mjs +34 -18
- package/package.json +2 -2
package/dist/index.d.mts
CHANGED
|
@@ -19,10 +19,15 @@ declare type Capabilities = {
|
|
|
19
19
|
};
|
|
20
20
|
|
|
21
21
|
declare class MariaDbQueryable<Connection extends mariadb.Pool | mariadb.Connection> implements SqlQueryable {
|
|
22
|
-
protected client: Connection;
|
|
22
|
+
protected readonly client: Connection;
|
|
23
|
+
protected readonly mariadbOptions?: {
|
|
24
|
+
useTextProtocol?: boolean | undefined;
|
|
25
|
+
} | undefined;
|
|
23
26
|
readonly provider = "mysql";
|
|
24
27
|
readonly adapterName: string;
|
|
25
|
-
constructor(client: Connection
|
|
28
|
+
constructor(client: Connection, mariadbOptions?: {
|
|
29
|
+
useTextProtocol?: boolean | undefined;
|
|
30
|
+
} | undefined);
|
|
26
31
|
queryRaw(query: SqlQuery): Promise<SqlResultSet>;
|
|
27
32
|
executeRaw(query: SqlQuery): Promise<number>;
|
|
28
33
|
protected performIO(query: SqlQuery): Promise<ArrayModeResult>;
|
|
@@ -39,8 +44,8 @@ export declare class PrismaMariaDb implements SqlDriverAdapterFactory {
|
|
|
39
44
|
|
|
40
45
|
declare class PrismaMariaDbAdapter extends MariaDbQueryable<mariadb.Pool> implements SqlDriverAdapter {
|
|
41
46
|
private readonly capabilities;
|
|
42
|
-
|
|
43
|
-
constructor(client: mariadb.Pool, capabilities: Capabilities,
|
|
47
|
+
protected readonly mariadbOptions?: PrismaMariadbOptions | undefined;
|
|
48
|
+
constructor(client: mariadb.Pool, capabilities: Capabilities, mariadbOptions?: PrismaMariadbOptions | undefined);
|
|
44
49
|
executeScript(_script: string): Promise<void>;
|
|
45
50
|
getConnectionInfo(): ConnectionInfo;
|
|
46
51
|
startTransaction(isolationLevel?: IsolationLevel): Promise<Transaction>;
|
|
@@ -49,7 +54,11 @@ declare class PrismaMariaDbAdapter extends MariaDbQueryable<mariadb.Pool> implem
|
|
|
49
54
|
}
|
|
50
55
|
|
|
51
56
|
declare type PrismaMariadbOptions = {
|
|
57
|
+
/** The name of the database to use in generated queries */
|
|
52
58
|
database?: string;
|
|
59
|
+
/** Use the driver's text protocol (`query`) instead of the binary protocol (`execute`). */
|
|
60
|
+
useTextProtocol?: boolean;
|
|
61
|
+
/** Callback attached to transaction connection `error` events. */
|
|
53
62
|
onConnectionError?: (err: mariadb.SqlError) => void;
|
|
54
63
|
};
|
|
55
64
|
|
package/dist/index.d.ts
CHANGED
|
@@ -19,10 +19,15 @@ declare type Capabilities = {
|
|
|
19
19
|
};
|
|
20
20
|
|
|
21
21
|
declare class MariaDbQueryable<Connection extends mariadb.Pool | mariadb.Connection> implements SqlQueryable {
|
|
22
|
-
protected client: Connection;
|
|
22
|
+
protected readonly client: Connection;
|
|
23
|
+
protected readonly mariadbOptions?: {
|
|
24
|
+
useTextProtocol?: boolean | undefined;
|
|
25
|
+
} | undefined;
|
|
23
26
|
readonly provider = "mysql";
|
|
24
27
|
readonly adapterName: string;
|
|
25
|
-
constructor(client: Connection
|
|
28
|
+
constructor(client: Connection, mariadbOptions?: {
|
|
29
|
+
useTextProtocol?: boolean | undefined;
|
|
30
|
+
} | undefined);
|
|
26
31
|
queryRaw(query: SqlQuery): Promise<SqlResultSet>;
|
|
27
32
|
executeRaw(query: SqlQuery): Promise<number>;
|
|
28
33
|
protected performIO(query: SqlQuery): Promise<ArrayModeResult>;
|
|
@@ -39,8 +44,8 @@ export declare class PrismaMariaDb implements SqlDriverAdapterFactory {
|
|
|
39
44
|
|
|
40
45
|
declare class PrismaMariaDbAdapter extends MariaDbQueryable<mariadb.Pool> implements SqlDriverAdapter {
|
|
41
46
|
private readonly capabilities;
|
|
42
|
-
|
|
43
|
-
constructor(client: mariadb.Pool, capabilities: Capabilities,
|
|
47
|
+
protected readonly mariadbOptions?: PrismaMariadbOptions | undefined;
|
|
48
|
+
constructor(client: mariadb.Pool, capabilities: Capabilities, mariadbOptions?: PrismaMariadbOptions | undefined);
|
|
44
49
|
executeScript(_script: string): Promise<void>;
|
|
45
50
|
getConnectionInfo(): ConnectionInfo;
|
|
46
51
|
startTransaction(isolationLevel?: IsolationLevel): Promise<Transaction>;
|
|
@@ -49,7 +54,11 @@ declare class PrismaMariaDbAdapter extends MariaDbQueryable<mariadb.Pool> implem
|
|
|
49
54
|
}
|
|
50
55
|
|
|
51
56
|
declare type PrismaMariadbOptions = {
|
|
57
|
+
/** The name of the database to use in generated queries */
|
|
52
58
|
database?: string;
|
|
59
|
+
/** Use the driver's text protocol (`query`) instead of the binary protocol (`execute`). */
|
|
60
|
+
useTextProtocol?: boolean;
|
|
61
|
+
/** Callback attached to transaction connection `error` events. */
|
|
53
62
|
onConnectionError?: (err: mariadb.SqlError) => void;
|
|
54
63
|
};
|
|
55
64
|
|
package/dist/index.js
CHANGED
|
@@ -304,8 +304,9 @@ function isDriverError(error) {
|
|
|
304
304
|
// src/mariadb.ts
|
|
305
305
|
var debug = (0, import_driver_adapter_utils2.Debug)("prisma:driver-adapter:mariadb");
|
|
306
306
|
var MariaDbQueryable = class {
|
|
307
|
-
constructor(client) {
|
|
307
|
+
constructor(client, mariadbOptions) {
|
|
308
308
|
this.client = client;
|
|
309
|
+
this.mariadbOptions = mariadbOptions;
|
|
309
310
|
}
|
|
310
311
|
provider = "mysql";
|
|
311
312
|
adapterName = name;
|
|
@@ -343,7 +344,8 @@ var MariaDbQueryable = class {
|
|
|
343
344
|
typeCast
|
|
344
345
|
};
|
|
345
346
|
const values = args.map((arg, i) => mapArg(arg, query.argTypes[i]));
|
|
346
|
-
|
|
347
|
+
const execute = this.mariadbOptions?.useTextProtocol ? this.client.query.bind(this.client) : this.client.execute.bind(this.client);
|
|
348
|
+
return await execute(req, values);
|
|
347
349
|
} catch (e) {
|
|
348
350
|
const error = e;
|
|
349
351
|
this.onError(error);
|
|
@@ -355,8 +357,8 @@ var MariaDbQueryable = class {
|
|
|
355
357
|
}
|
|
356
358
|
};
|
|
357
359
|
var MariaDbTransaction = class extends MariaDbQueryable {
|
|
358
|
-
constructor(conn, options, cleanup) {
|
|
359
|
-
super(conn);
|
|
360
|
+
constructor(conn, mariadbOptions, options, cleanup) {
|
|
361
|
+
super(conn, mariadbOptions);
|
|
360
362
|
this.conn = conn;
|
|
361
363
|
this.options = options;
|
|
362
364
|
this.cleanup = cleanup;
|
|
@@ -394,17 +396,17 @@ var MariaDbTransaction = class extends MariaDbQueryable {
|
|
|
394
396
|
}
|
|
395
397
|
};
|
|
396
398
|
var PrismaMariaDbAdapter = class extends MariaDbQueryable {
|
|
397
|
-
constructor(client, capabilities,
|
|
398
|
-
super(client);
|
|
399
|
+
constructor(client, capabilities, mariadbOptions) {
|
|
400
|
+
super(client, mariadbOptions);
|
|
399
401
|
this.capabilities = capabilities;
|
|
400
|
-
this.
|
|
402
|
+
this.mariadbOptions = mariadbOptions;
|
|
401
403
|
}
|
|
402
404
|
executeScript(_script) {
|
|
403
405
|
throw new Error("Not implemented yet");
|
|
404
406
|
}
|
|
405
407
|
getConnectionInfo() {
|
|
406
408
|
return {
|
|
407
|
-
schemaName: this.
|
|
409
|
+
schemaName: this.mariadbOptions?.database,
|
|
408
410
|
supportsRelationJoins: this.capabilities.supportsRelationJoins
|
|
409
411
|
};
|
|
410
412
|
}
|
|
@@ -417,14 +419,14 @@ var PrismaMariaDbAdapter = class extends MariaDbQueryable {
|
|
|
417
419
|
const conn = await this.client.getConnection().catch((error) => this.onError(error));
|
|
418
420
|
const onError = (err) => {
|
|
419
421
|
debug(`Error from connection: ${err.message} %O`, err);
|
|
420
|
-
this.
|
|
422
|
+
this.mariadbOptions?.onConnectionError?.(err);
|
|
421
423
|
};
|
|
422
424
|
conn.on("error", onError);
|
|
423
425
|
const cleanup = () => {
|
|
424
426
|
conn.removeListener("error", onError);
|
|
425
427
|
};
|
|
426
428
|
try {
|
|
427
|
-
const tx = new MariaDbTransaction(conn, options, cleanup);
|
|
429
|
+
const tx = new MariaDbTransaction(conn, this.mariadbOptions, options, cleanup);
|
|
428
430
|
if (isolationLevel) {
|
|
429
431
|
await tx.executeRaw({
|
|
430
432
|
sql: `SET TRANSACTION ISOLATION LEVEL ${isolationLevel}`,
|
|
@@ -454,7 +456,24 @@ var PrismaMariaDbAdapterFactory = class {
|
|
|
454
456
|
#config;
|
|
455
457
|
#options;
|
|
456
458
|
constructor(config, options) {
|
|
457
|
-
|
|
459
|
+
if (typeof config === "string") {
|
|
460
|
+
try {
|
|
461
|
+
const url = new URL(config);
|
|
462
|
+
if (!url.searchParams.has("prepareCacheLength")) {
|
|
463
|
+
url.searchParams.set("prepareCacheLength", "0");
|
|
464
|
+
}
|
|
465
|
+
this.#config = rewriteConnectionString(url).toString();
|
|
466
|
+
} catch (error) {
|
|
467
|
+
debug("Error parsing connection string: %O", error);
|
|
468
|
+
this.#config = config;
|
|
469
|
+
}
|
|
470
|
+
} else {
|
|
471
|
+
if (config.prepareCacheLength === void 0) {
|
|
472
|
+
this.#config = { ...config, prepareCacheLength: 0 };
|
|
473
|
+
} else {
|
|
474
|
+
this.#config = config;
|
|
475
|
+
}
|
|
476
|
+
}
|
|
458
477
|
this.#options = options;
|
|
459
478
|
}
|
|
460
479
|
async connect() {
|
|
@@ -502,14 +521,11 @@ function inferCapabilities(version) {
|
|
|
502
521
|
const supportsRelationJoins = !isMariaDB && (major > 8 || major === 8 && (minor > 0 || minor === 0 && patch >= 13));
|
|
503
522
|
return { supportsRelationJoins };
|
|
504
523
|
}
|
|
505
|
-
function rewriteConnectionString(
|
|
506
|
-
if (
|
|
507
|
-
|
|
508
|
-
}
|
|
509
|
-
if (!config.startsWith("mysql://")) {
|
|
510
|
-
return config;
|
|
524
|
+
function rewriteConnectionString(url) {
|
|
525
|
+
if (url.protocol === "mysql:") {
|
|
526
|
+
url.protocol = "mariadb:";
|
|
511
527
|
}
|
|
512
|
-
return
|
|
528
|
+
return url;
|
|
513
529
|
}
|
|
514
530
|
// Annotate the CommonJS export names for ESM import in node:
|
|
515
531
|
0 && (module.exports = {
|
package/dist/index.mjs
CHANGED
|
@@ -268,8 +268,9 @@ function isDriverError(error) {
|
|
|
268
268
|
// src/mariadb.ts
|
|
269
269
|
var debug = Debug("prisma:driver-adapter:mariadb");
|
|
270
270
|
var MariaDbQueryable = class {
|
|
271
|
-
constructor(client) {
|
|
271
|
+
constructor(client, mariadbOptions) {
|
|
272
272
|
this.client = client;
|
|
273
|
+
this.mariadbOptions = mariadbOptions;
|
|
273
274
|
}
|
|
274
275
|
provider = "mysql";
|
|
275
276
|
adapterName = name;
|
|
@@ -307,7 +308,8 @@ var MariaDbQueryable = class {
|
|
|
307
308
|
typeCast
|
|
308
309
|
};
|
|
309
310
|
const values = args.map((arg, i) => mapArg(arg, query.argTypes[i]));
|
|
310
|
-
|
|
311
|
+
const execute = this.mariadbOptions?.useTextProtocol ? this.client.query.bind(this.client) : this.client.execute.bind(this.client);
|
|
312
|
+
return await execute(req, values);
|
|
311
313
|
} catch (e) {
|
|
312
314
|
const error = e;
|
|
313
315
|
this.onError(error);
|
|
@@ -319,8 +321,8 @@ var MariaDbQueryable = class {
|
|
|
319
321
|
}
|
|
320
322
|
};
|
|
321
323
|
var MariaDbTransaction = class extends MariaDbQueryable {
|
|
322
|
-
constructor(conn, options, cleanup) {
|
|
323
|
-
super(conn);
|
|
324
|
+
constructor(conn, mariadbOptions, options, cleanup) {
|
|
325
|
+
super(conn, mariadbOptions);
|
|
324
326
|
this.conn = conn;
|
|
325
327
|
this.options = options;
|
|
326
328
|
this.cleanup = cleanup;
|
|
@@ -358,17 +360,17 @@ var MariaDbTransaction = class extends MariaDbQueryable {
|
|
|
358
360
|
}
|
|
359
361
|
};
|
|
360
362
|
var PrismaMariaDbAdapter = class extends MariaDbQueryable {
|
|
361
|
-
constructor(client, capabilities,
|
|
362
|
-
super(client);
|
|
363
|
+
constructor(client, capabilities, mariadbOptions) {
|
|
364
|
+
super(client, mariadbOptions);
|
|
363
365
|
this.capabilities = capabilities;
|
|
364
|
-
this.
|
|
366
|
+
this.mariadbOptions = mariadbOptions;
|
|
365
367
|
}
|
|
366
368
|
executeScript(_script) {
|
|
367
369
|
throw new Error("Not implemented yet");
|
|
368
370
|
}
|
|
369
371
|
getConnectionInfo() {
|
|
370
372
|
return {
|
|
371
|
-
schemaName: this.
|
|
373
|
+
schemaName: this.mariadbOptions?.database,
|
|
372
374
|
supportsRelationJoins: this.capabilities.supportsRelationJoins
|
|
373
375
|
};
|
|
374
376
|
}
|
|
@@ -381,14 +383,14 @@ var PrismaMariaDbAdapter = class extends MariaDbQueryable {
|
|
|
381
383
|
const conn = await this.client.getConnection().catch((error) => this.onError(error));
|
|
382
384
|
const onError = (err) => {
|
|
383
385
|
debug(`Error from connection: ${err.message} %O`, err);
|
|
384
|
-
this.
|
|
386
|
+
this.mariadbOptions?.onConnectionError?.(err);
|
|
385
387
|
};
|
|
386
388
|
conn.on("error", onError);
|
|
387
389
|
const cleanup = () => {
|
|
388
390
|
conn.removeListener("error", onError);
|
|
389
391
|
};
|
|
390
392
|
try {
|
|
391
|
-
const tx = new MariaDbTransaction(conn, options, cleanup);
|
|
393
|
+
const tx = new MariaDbTransaction(conn, this.mariadbOptions, options, cleanup);
|
|
392
394
|
if (isolationLevel) {
|
|
393
395
|
await tx.executeRaw({
|
|
394
396
|
sql: `SET TRANSACTION ISOLATION LEVEL ${isolationLevel}`,
|
|
@@ -418,7 +420,24 @@ var PrismaMariaDbAdapterFactory = class {
|
|
|
418
420
|
#config;
|
|
419
421
|
#options;
|
|
420
422
|
constructor(config, options) {
|
|
421
|
-
|
|
423
|
+
if (typeof config === "string") {
|
|
424
|
+
try {
|
|
425
|
+
const url = new URL(config);
|
|
426
|
+
if (!url.searchParams.has("prepareCacheLength")) {
|
|
427
|
+
url.searchParams.set("prepareCacheLength", "0");
|
|
428
|
+
}
|
|
429
|
+
this.#config = rewriteConnectionString(url).toString();
|
|
430
|
+
} catch (error) {
|
|
431
|
+
debug("Error parsing connection string: %O", error);
|
|
432
|
+
this.#config = config;
|
|
433
|
+
}
|
|
434
|
+
} else {
|
|
435
|
+
if (config.prepareCacheLength === void 0) {
|
|
436
|
+
this.#config = { ...config, prepareCacheLength: 0 };
|
|
437
|
+
} else {
|
|
438
|
+
this.#config = config;
|
|
439
|
+
}
|
|
440
|
+
}
|
|
422
441
|
this.#options = options;
|
|
423
442
|
}
|
|
424
443
|
async connect() {
|
|
@@ -466,14 +485,11 @@ function inferCapabilities(version) {
|
|
|
466
485
|
const supportsRelationJoins = !isMariaDB && (major > 8 || major === 8 && (minor > 0 || minor === 0 && patch >= 13));
|
|
467
486
|
return { supportsRelationJoins };
|
|
468
487
|
}
|
|
469
|
-
function rewriteConnectionString(
|
|
470
|
-
if (
|
|
471
|
-
|
|
472
|
-
}
|
|
473
|
-
if (!config.startsWith("mysql://")) {
|
|
474
|
-
return config;
|
|
488
|
+
function rewriteConnectionString(url) {
|
|
489
|
+
if (url.protocol === "mysql:") {
|
|
490
|
+
url.protocol = "mariadb:";
|
|
475
491
|
}
|
|
476
|
-
return
|
|
492
|
+
return url;
|
|
477
493
|
}
|
|
478
494
|
export {
|
|
479
495
|
PrismaMariaDbAdapterFactory as PrismaMariaDb
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@prisma/adapter-mariadb",
|
|
3
|
-
"version": "7.6.0-dev.
|
|
3
|
+
"version": "7.6.0-dev.15",
|
|
4
4
|
"description": "Prisma's driver adapter for \"mariadb\"",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"module": "dist/index.mjs",
|
|
@@ -32,7 +32,7 @@
|
|
|
32
32
|
"sideEffects": false,
|
|
33
33
|
"dependencies": {
|
|
34
34
|
"mariadb": "3.4.5",
|
|
35
|
-
"@prisma/driver-adapter-utils": "7.6.0-dev.
|
|
35
|
+
"@prisma/driver-adapter-utils": "7.6.0-dev.15"
|
|
36
36
|
},
|
|
37
37
|
"scripts": {
|
|
38
38
|
"dev": "DEV=true tsx helpers/build.ts",
|