@prisma/adapter-mariadb 6.11.0-dev.23 → 6.11.0-dev.24

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.js CHANGED
@@ -81,6 +81,9 @@ function mapColumnType(field) {
81
81
  case "VARCHAR" /* VARCHAR */:
82
82
  case "VAR_STRING" /* VAR_STRING */:
83
83
  case "STRING" /* STRING */:
84
+ case "BLOB" /* BLOB */:
85
+ case "TINY_BLOB" /* TINY_BLOB */:
86
+ case "MEDIUM_BLOB" /* MEDIUM_BLOB */:
84
87
  if (field.flags.valueOf() & BINARY_FLAG) {
85
88
  return import_driver_adapter_utils.ColumnTypeEnum.Bytes;
86
89
  } else {
@@ -90,9 +93,6 @@ function mapColumnType(field) {
90
93
  return import_driver_adapter_utils.ColumnTypeEnum.Enum;
91
94
  case "JSON" /* JSON */:
92
95
  return import_driver_adapter_utils.ColumnTypeEnum.Json;
93
- case "BLOB" /* BLOB */:
94
- case "TINY_BLOB" /* TINY_BLOB */:
95
- case "MEDIUM_BLOB" /* MEDIUM_BLOB */:
96
96
  case "BIT" /* BIT */:
97
97
  case "GEOMETRY" /* GEOMETRY */:
98
98
  return import_driver_adapter_utils.ColumnTypeEnum.Bytes;
@@ -111,20 +111,15 @@ function mapArg(arg) {
111
111
  function mapRow(row, fields) {
112
112
  return row.map((value, i) => {
113
113
  const type = fields?.[i].type;
114
- if (value === null && type !== "JSON" /* JSON */) {
114
+ if (value === null) {
115
115
  return null;
116
116
  }
117
- if (typeof value === "boolean" && type === "BIT" /* BIT */) {
118
- return value ? [1] : [0];
119
- }
120
117
  switch (type) {
121
118
  case "TIMESTAMP" /* TIMESTAMP */:
122
119
  case "TIMESTAMP2" /* TIMESTAMP2 */:
123
120
  case "DATETIME" /* DATETIME */:
124
121
  case "DATETIME2" /* DATETIME2 */:
125
122
  return (/* @__PURE__ */ new Date(`${value}Z`)).toISOString();
126
- case "JSON" /* JSON */:
127
- return JSON.stringify(value);
128
123
  }
129
124
  if (Buffer.isBuffer(value)) {
130
125
  return Array.from(value);
@@ -135,6 +130,12 @@ function mapRow(row, fields) {
135
130
  return value;
136
131
  });
137
132
  }
133
+ var typeCast = (field, next) => {
134
+ if (field.type === "GEOMETRY" /* GEOMETRY */) {
135
+ return field.buffer();
136
+ }
137
+ return next();
138
+ };
138
139
 
139
140
  // src/errors.ts
140
141
  function convertDriverError(error) {
@@ -280,14 +281,19 @@ var MariaDbQueryable = class {
280
281
  async performIO(query) {
281
282
  const { sql, args: values } = query;
282
283
  try {
283
- return await this.client.query(
284
- {
285
- sql,
286
- dateStrings: true,
287
- rowsAsArray: true
288
- },
289
- values.map(mapArg)
290
- );
284
+ const query2 = {
285
+ sql,
286
+ rowsAsArray: true,
287
+ dateStrings: true,
288
+ // Return JSON strings as strings, not objects.
289
+ // Available in the driver, but not provided in the typings.
290
+ jsonStrings: true,
291
+ // Disable automatic conversion of BIT(1) to boolean.
292
+ // Available in the driver, but not provided in the typings.
293
+ bitOneIsBoolean: false,
294
+ typeCast
295
+ };
296
+ return await this.client.query(query2, values.map(mapArg));
291
297
  } catch (e) {
292
298
  const error = e;
293
299
  onError(error);
@@ -373,7 +379,7 @@ var PrismaMariaDbAdapterFactory = class {
373
379
  async function getCapabilities(pool) {
374
380
  const tag = "[js::getCapabilities]";
375
381
  try {
376
- const [rows] = await pool.query({
382
+ const rows = await pool.query({
377
383
  sql: `SELECT VERSION()`,
378
384
  rowsAsArray: true
379
385
  });
package/dist/index.mjs CHANGED
@@ -45,6 +45,9 @@ function mapColumnType(field) {
45
45
  case "VARCHAR" /* VARCHAR */:
46
46
  case "VAR_STRING" /* VAR_STRING */:
47
47
  case "STRING" /* STRING */:
48
+ case "BLOB" /* BLOB */:
49
+ case "TINY_BLOB" /* TINY_BLOB */:
50
+ case "MEDIUM_BLOB" /* MEDIUM_BLOB */:
48
51
  if (field.flags.valueOf() & BINARY_FLAG) {
49
52
  return ColumnTypeEnum.Bytes;
50
53
  } else {
@@ -54,9 +57,6 @@ function mapColumnType(field) {
54
57
  return ColumnTypeEnum.Enum;
55
58
  case "JSON" /* JSON */:
56
59
  return ColumnTypeEnum.Json;
57
- case "BLOB" /* BLOB */:
58
- case "TINY_BLOB" /* TINY_BLOB */:
59
- case "MEDIUM_BLOB" /* MEDIUM_BLOB */:
60
60
  case "BIT" /* BIT */:
61
61
  case "GEOMETRY" /* GEOMETRY */:
62
62
  return ColumnTypeEnum.Bytes;
@@ -75,20 +75,15 @@ function mapArg(arg) {
75
75
  function mapRow(row, fields) {
76
76
  return row.map((value, i) => {
77
77
  const type = fields?.[i].type;
78
- if (value === null && type !== "JSON" /* JSON */) {
78
+ if (value === null) {
79
79
  return null;
80
80
  }
81
- if (typeof value === "boolean" && type === "BIT" /* BIT */) {
82
- return value ? [1] : [0];
83
- }
84
81
  switch (type) {
85
82
  case "TIMESTAMP" /* TIMESTAMP */:
86
83
  case "TIMESTAMP2" /* TIMESTAMP2 */:
87
84
  case "DATETIME" /* DATETIME */:
88
85
  case "DATETIME2" /* DATETIME2 */:
89
86
  return (/* @__PURE__ */ new Date(`${value}Z`)).toISOString();
90
- case "JSON" /* JSON */:
91
- return JSON.stringify(value);
92
87
  }
93
88
  if (Buffer.isBuffer(value)) {
94
89
  return Array.from(value);
@@ -99,6 +94,12 @@ function mapRow(row, fields) {
99
94
  return value;
100
95
  });
101
96
  }
97
+ var typeCast = (field, next) => {
98
+ if (field.type === "GEOMETRY" /* GEOMETRY */) {
99
+ return field.buffer();
100
+ }
101
+ return next();
102
+ };
102
103
 
103
104
  // src/errors.ts
104
105
  function convertDriverError(error) {
@@ -244,14 +245,19 @@ var MariaDbQueryable = class {
244
245
  async performIO(query) {
245
246
  const { sql, args: values } = query;
246
247
  try {
247
- return await this.client.query(
248
- {
249
- sql,
250
- dateStrings: true,
251
- rowsAsArray: true
252
- },
253
- values.map(mapArg)
254
- );
248
+ const query2 = {
249
+ sql,
250
+ rowsAsArray: true,
251
+ dateStrings: true,
252
+ // Return JSON strings as strings, not objects.
253
+ // Available in the driver, but not provided in the typings.
254
+ jsonStrings: true,
255
+ // Disable automatic conversion of BIT(1) to boolean.
256
+ // Available in the driver, but not provided in the typings.
257
+ bitOneIsBoolean: false,
258
+ typeCast
259
+ };
260
+ return await this.client.query(query2, values.map(mapArg));
255
261
  } catch (e) {
256
262
  const error = e;
257
263
  onError(error);
@@ -337,7 +343,7 @@ var PrismaMariaDbAdapterFactory = class {
337
343
  async function getCapabilities(pool) {
338
344
  const tag = "[js::getCapabilities]";
339
345
  try {
340
- const [rows] = await pool.query({
346
+ const rows = await pool.query({
341
347
  sql: `SELECT VERSION()`,
342
348
  rowsAsArray: true
343
349
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@prisma/adapter-mariadb",
3
- "version": "6.11.0-dev.23",
3
+ "version": "6.11.0-dev.24",
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.2",
35
- "@prisma/driver-adapter-utils": "6.11.0-dev.23"
35
+ "@prisma/driver-adapter-utils": "6.11.0-dev.24"
36
36
  },
37
37
  "devDependencies": {
38
38
  "vitest": "3.0.9"