drizzle-kit 1.0.0-beta.1-2e234ba → 1.0.0-beta.1-9e70ee7
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/api.js +1148 -1080
- package/api.mjs +1148 -1080
- package/bin.cjs +173 -119
- package/package.json +1 -1
- package/utils.js +3 -0
- package/utils.mjs +3 -0
package/bin.cjs
CHANGED
@@ -7865,6 +7865,9 @@ function escapeSingleQuotes(str) {
|
|
7865
7865
|
return str.replace(/'/g, "''");
|
7866
7866
|
}
|
7867
7867
|
function unescapeSingleQuotes(str, ignoreFirstAndLastChar) {
|
7868
|
+
if (str === "''") {
|
7869
|
+
return str;
|
7870
|
+
}
|
7868
7871
|
const regex = ignoreFirstAndLastChar ? /(?<!^)'(?!$)/g : /'/g;
|
7869
7872
|
return str.replace(/''/g, "'").replace(regex, "\\'");
|
7870
7873
|
}
|
@@ -18444,6 +18447,30 @@ function prepareRoles(entities) {
|
|
18444
18447
|
}
|
18445
18448
|
return { useRoles, includeRoles, excludeRoles };
|
18446
18449
|
}
|
18450
|
+
function parsePgArray(input) {
|
18451
|
+
const content = input.slice(1, -1);
|
18452
|
+
const result = [];
|
18453
|
+
let current = "";
|
18454
|
+
let inQuotes = false;
|
18455
|
+
for (let i2 = 0; i2 < content.length; i2++) {
|
18456
|
+
const char = content[i2];
|
18457
|
+
if (char === '"') {
|
18458
|
+
if (inQuotes && content[i2 + 1] === '"') {
|
18459
|
+
current += '"';
|
18460
|
+
i2++;
|
18461
|
+
} else {
|
18462
|
+
inQuotes = !inQuotes;
|
18463
|
+
}
|
18464
|
+
} else if (char === "," && !inQuotes) {
|
18465
|
+
result.push(current);
|
18466
|
+
current = "";
|
18467
|
+
} else {
|
18468
|
+
current += char;
|
18469
|
+
}
|
18470
|
+
}
|
18471
|
+
result.push(current);
|
18472
|
+
return result.map((item) => item.trim());
|
18473
|
+
}
|
18447
18474
|
var import_drizzle_orm4, import_pg_core2, indexName2, generatePgSnapshot, trimChar, fromDatabase2, defaultForColumn, getColumnsInfoQuery;
|
18448
18475
|
var init_pgSerializer = __esm({
|
18449
18476
|
"src/serializer/pgSerializer.ts"() {
|
@@ -19308,74 +19335,77 @@ WHERE
|
|
19308
19335
|
}
|
19309
19336
|
const tableForeignKeys = await db.query(
|
19310
19337
|
`SELECT
|
19311
|
-
|
19312
|
-
|
19313
|
-
|
19314
|
-
|
19315
|
-
|
19316
|
-
|
19317
|
-
|
19318
|
-
|
19319
|
-
|
19320
|
-
|
19321
|
-
|
19322
|
-
|
19323
|
-
|
19324
|
-
|
19325
|
-
|
19326
|
-
|
19327
|
-
|
19328
|
-
|
19329
|
-
|
19330
|
-
|
19331
|
-
|
19332
|
-
|
19333
|
-
|
19334
|
-
|
19335
|
-
|
19336
|
-
|
19337
|
-
|
19338
|
-
|
19339
|
-
|
19340
|
-
|
19341
|
-
|
19342
|
-
|
19343
|
-
|
19344
|
-
|
19345
|
-
|
19346
|
-
|
19338
|
+
con.contype::text AS constraint_type,
|
19339
|
+
nsp.nspname AS constraint_schema,
|
19340
|
+
con.conname AS constraint_name,
|
19341
|
+
rel.relname AS table_name,
|
19342
|
+
pg_get_constraintdef(con.oid) AS expression,
|
19343
|
+
fnsp.nspname AS foreign_table_schema,
|
19344
|
+
frel.relname AS foreign_table_name,
|
19345
|
+
-- Aggregate the local column names in order
|
19346
|
+
array_agg(att.attname ORDER BY gs.n) AS column_names,
|
19347
|
+
-- Aggregate the column order numbers (which will be 1,2,...)
|
19348
|
+
array_agg(gs.n ORDER BY gs.n) AS column_positions,
|
19349
|
+
-- Aggregate the foreign (referenced) column names in order
|
19350
|
+
array_agg(fatt.attname ORDER BY gs.n) AS foreign_column_names,
|
19351
|
+
CASE con.confupdtype
|
19352
|
+
WHEN 'a' THEN 'NO ACTION'
|
19353
|
+
WHEN 'r' THEN 'RESTRICT'
|
19354
|
+
WHEN 'n' THEN 'SET NULL'
|
19355
|
+
WHEN 'c' THEN 'CASCADE'
|
19356
|
+
WHEN 'd' THEN 'SET DEFAULT'
|
19357
|
+
END AS update_rule,
|
19358
|
+
CASE con.confdeltype
|
19359
|
+
WHEN 'a' THEN 'NO ACTION'
|
19360
|
+
WHEN 'r' THEN 'RESTRICT'
|
19361
|
+
WHEN 'n' THEN 'SET NULL'
|
19362
|
+
WHEN 'c' THEN 'CASCADE'
|
19363
|
+
WHEN 'd' THEN 'SET DEFAULT'
|
19364
|
+
END AS delete_rule
|
19365
|
+
FROM pg_constraint con
|
19366
|
+
JOIN pg_namespace nsp ON nsp.oid = con.connamespace
|
19367
|
+
JOIN pg_class rel ON rel.oid = con.conrelid
|
19368
|
+
-- Unnest the array of referencing column numbers with ordinality
|
19369
|
+
JOIN LATERAL unnest(con.conkey) WITH ORDINALITY AS gs(attnum, n) ON true
|
19370
|
+
JOIN pg_attribute att
|
19371
|
+
ON att.attrelid = con.conrelid
|
19372
|
+
AND att.attnum = gs.attnum
|
19373
|
+
LEFT JOIN pg_class frel ON frel.oid = con.confrelid
|
19374
|
+
LEFT JOIN pg_namespace fnsp ON fnsp.oid = frel.relnamespace
|
19375
|
+
-- Unnest the array of referenced column numbers in the same order
|
19376
|
+
JOIN LATERAL unnest(con.confkey) WITH ORDINALITY AS gs2(attnum, n) ON gs.n = gs2.n
|
19377
|
+
JOIN pg_attribute fatt
|
19378
|
+
ON fatt.attrelid = con.confrelid
|
19379
|
+
AND fatt.attnum = gs2.attnum
|
19380
|
+
WHERE con.contype = 'f'
|
19381
|
+
AND rel.relname = '${tableName}'
|
19382
|
+
AND nsp.nspname = '${tableSchema}'
|
19383
|
+
GROUP BY con.oid, nsp.nspname, con.conname, rel.relname, fnsp.nspname, frel.relname,
|
19384
|
+
con.contype, con.confupdtype, con.confdeltype
|
19385
|
+
ORDER BY con.conname;`
|
19347
19386
|
);
|
19348
19387
|
foreignKeysCount += tableForeignKeys.length;
|
19349
19388
|
if (progressCallback) {
|
19350
19389
|
progressCallback("fks", foreignKeysCount, "fetching");
|
19351
19390
|
}
|
19352
19391
|
for (const fk5 of tableForeignKeys) {
|
19353
|
-
const
|
19392
|
+
const columnsFrom = parsePgArray(fk5.column_names);
|
19354
19393
|
const tableTo = fk5.foreign_table_name;
|
19355
|
-
const
|
19394
|
+
const columnsTo = parsePgArray(fk5.foreign_column_names);
|
19356
19395
|
const schemaTo = fk5.foreign_table_schema;
|
19357
19396
|
const foreignKeyName = fk5.constraint_name;
|
19358
19397
|
const onUpdate = (_a = fk5.update_rule) == null ? void 0 : _a.toLowerCase();
|
19359
19398
|
const onDelete = (_b = fk5.delete_rule) == null ? void 0 : _b.toLowerCase();
|
19360
|
-
|
19361
|
-
|
19362
|
-
|
19363
|
-
|
19364
|
-
|
19365
|
-
|
19366
|
-
|
19367
|
-
|
19368
|
-
|
19369
|
-
|
19370
|
-
columnsTo: [columnTo],
|
19371
|
-
onDelete,
|
19372
|
-
onUpdate
|
19373
|
-
};
|
19374
|
-
}
|
19375
|
-
foreignKeysToReturn[foreignKeyName].columnsFrom = [
|
19376
|
-
...new Set(foreignKeysToReturn[foreignKeyName].columnsFrom)
|
19377
|
-
];
|
19378
|
-
foreignKeysToReturn[foreignKeyName].columnsTo = [...new Set(foreignKeysToReturn[foreignKeyName].columnsTo)];
|
19399
|
+
foreignKeysToReturn[foreignKeyName] = {
|
19400
|
+
name: foreignKeyName,
|
19401
|
+
tableFrom: tableName,
|
19402
|
+
tableTo,
|
19403
|
+
schemaTo,
|
19404
|
+
columnsFrom,
|
19405
|
+
columnsTo,
|
19406
|
+
onDelete,
|
19407
|
+
onUpdate
|
19408
|
+
};
|
19379
19409
|
}
|
19380
19410
|
const uniqueConstrainsRows = tableConstraints.filter((mapRow) => mapRow.constraint_type === "UNIQUE");
|
19381
19411
|
for (const unqs of uniqueConstrainsRows) {
|
@@ -20102,6 +20132,13 @@ function extractGeneratedColumns(input) {
|
|
20102
20132
|
}
|
20103
20133
|
return columns;
|
20104
20134
|
}
|
20135
|
+
function filterIgnoredTablesByField(fieldName) {
|
20136
|
+
return `${fieldName} != '__drizzle_migrations'
|
20137
|
+
AND ${fieldName} NOT LIKE '\\_cf\\_%' ESCAPE '\\'
|
20138
|
+
AND ${fieldName} NOT LIKE '\\_litestream\\_%' ESCAPE '\\'
|
20139
|
+
AND ${fieldName} NOT LIKE 'libsql\\_%' ESCAPE '\\'
|
20140
|
+
AND ${fieldName} NOT LIKE 'sqlite\\_%' ESCAPE '\\'`;
|
20141
|
+
}
|
20105
20142
|
var import_drizzle_orm6, import_sqlite_core2, generateSqliteSnapshot, fromDatabase3;
|
20106
20143
|
var init_sqliteSerializer = __esm({
|
20107
20144
|
"src/serializer/sqliteSerializer.ts"() {
|
@@ -20406,29 +20443,26 @@ ${withStyle.errorWarning(
|
|
20406
20443
|
fromDatabase3 = async (db, tablesFilter = (table6) => true, progressCallback) => {
|
20407
20444
|
const result = {};
|
20408
20445
|
const resultViews = {};
|
20409
|
-
const columns = await db.query(
|
20410
|
-
|
20411
|
-
|
20412
|
-
|
20413
|
-
|
20414
|
-
|
20415
|
-
|
20416
|
-
|
20417
|
-
|
20418
|
-
|
20419
|
-
|
20420
|
-
|
20421
|
-
|
20422
|
-
|
20446
|
+
const columns = await db.query(`SELECT
|
20447
|
+
m.name as "tableName",
|
20448
|
+
p.name as "columnName",
|
20449
|
+
p.type as "columnType",
|
20450
|
+
p."notnull" as "notNull",
|
20451
|
+
p.dflt_value as "defaultValue",
|
20452
|
+
p.pk as pk,
|
20453
|
+
p.hidden as hidden,
|
20454
|
+
m.sql,
|
20455
|
+
m.type as type
|
20456
|
+
FROM sqlite_master AS m
|
20457
|
+
JOIN pragma_table_xinfo(m.name) AS p
|
20458
|
+
WHERE (m.type = 'table' OR m.type = 'view')
|
20459
|
+
AND ${filterIgnoredTablesByField("m.tbl_name")};`);
|
20423
20460
|
const tablesWithSeq = [];
|
20424
|
-
const seq = await db.query(
|
20425
|
-
|
20426
|
-
|
20427
|
-
|
20428
|
-
|
20429
|
-
and tbl_name != '_cf_KV'
|
20430
|
-
and sql GLOB '*[ *' || CHAR(9) || CHAR(10) || CHAR(13) || ']AUTOINCREMENT[^'']*';`
|
20431
|
-
);
|
20461
|
+
const seq = await db.query(`SELECT
|
20462
|
+
*
|
20463
|
+
FROM sqlite_master
|
20464
|
+
WHERE sql GLOB '*[ *' || CHAR(9) || CHAR(10) || CHAR(13) || ']AUTOINCREMENT[^'']*'
|
20465
|
+
AND ${filterIgnoredTablesByField("tbl_name")};`);
|
20432
20466
|
for (const s2 of seq) {
|
20433
20467
|
tablesWithSeq.push(s2.name);
|
20434
20468
|
}
|
@@ -20523,11 +20557,19 @@ ${withStyle.errorWarning(
|
|
20523
20557
|
progressCallback("tables", tablesCount.size, "done");
|
20524
20558
|
}
|
20525
20559
|
try {
|
20526
|
-
const fks = await db.query(
|
20527
|
-
|
20528
|
-
|
20529
|
-
|
20530
|
-
|
20560
|
+
const fks = await db.query(`SELECT
|
20561
|
+
m.name as "tableFrom",
|
20562
|
+
f.id as "id",
|
20563
|
+
f."table" as "tableTo",
|
20564
|
+
f."from",
|
20565
|
+
f."to",
|
20566
|
+
f."on_update" as "onUpdate",
|
20567
|
+
f."on_delete" as "onDelete",
|
20568
|
+
f.seq as "seq"
|
20569
|
+
FROM
|
20570
|
+
sqlite_master m,
|
20571
|
+
pragma_foreign_key_list(m.name) as f
|
20572
|
+
WHERE ${filterIgnoredTablesByField("m.tbl_name")};`);
|
20531
20573
|
const fkByTableName = {};
|
20532
20574
|
for (const fkRow of fks) {
|
20533
20575
|
foreignKeysCount += 1;
|
@@ -20574,21 +20616,20 @@ ${withStyle.errorWarning(
|
|
20574
20616
|
if (progressCallback) {
|
20575
20617
|
progressCallback("fks", foreignKeysCount, "done");
|
20576
20618
|
}
|
20577
|
-
const idxs = await db.query(
|
20578
|
-
|
20579
|
-
|
20580
|
-
|
20581
|
-
|
20582
|
-
|
20583
|
-
|
20584
|
-
|
20585
|
-
|
20586
|
-
|
20587
|
-
WHERE
|
20588
|
-
|
20589
|
-
|
20590
|
-
|
20591
|
-
);
|
20619
|
+
const idxs = await db.query(`SELECT
|
20620
|
+
m.tbl_name as tableName,
|
20621
|
+
il.name as indexName,
|
20622
|
+
ii.name as columnName,
|
20623
|
+
il.[unique] as isUnique,
|
20624
|
+
il.seq as seq
|
20625
|
+
FROM
|
20626
|
+
sqlite_master AS m,
|
20627
|
+
pragma_index_list(m.name) AS il,
|
20628
|
+
pragma_index_info(il.name) AS ii
|
20629
|
+
WHERE
|
20630
|
+
m.type = 'table'
|
20631
|
+
AND il.name NOT LIKE 'sqlite\\_autoindex\\_%' ESCAPE '\\'
|
20632
|
+
AND ${filterIgnoredTablesByField("m.tbl_name")};`);
|
20592
20633
|
for (const idxRow of idxs) {
|
20593
20634
|
const tableName = idxRow.tableName;
|
20594
20635
|
const constraintName = idxRow.indexName;
|
@@ -20648,9 +20689,12 @@ WHERE
|
|
20648
20689
|
const unnamedCheckPattern = /CHECK\s*\((.*?)\)/gi;
|
20649
20690
|
let checkCounter = 0;
|
20650
20691
|
const checkConstraints = {};
|
20651
|
-
const checks = await db.query(`SELECT
|
20692
|
+
const checks = await db.query(`SELECT
|
20693
|
+
name as "tableName",
|
20694
|
+
sql as "sql"
|
20652
20695
|
FROM sqlite_master
|
20653
|
-
WHERE type = 'table'
|
20696
|
+
WHERE type = 'table'
|
20697
|
+
AND ${filterIgnoredTablesByField("tbl_name")};`);
|
20654
20698
|
for (const check2 of checks) {
|
20655
20699
|
if (!tablesFilter(check2.tableName))
|
20656
20700
|
continue;
|
@@ -82011,18 +82055,17 @@ var init_push = __esm({
|
|
82011
82055
|
(0, import_hanji13.render)(`
|
82012
82056
|
[${source_default.blue("i")}] No changes detected`);
|
82013
82057
|
} else {
|
82014
|
-
|
82015
|
-
|
82016
|
-
|
82017
|
-
|
82018
|
-
|
82019
|
-
}
|
82020
|
-
await db.run("commit");
|
82021
|
-
} catch (e2) {
|
82022
|
-
console.error(e2);
|
82023
|
-
await db.run("rollback");
|
82024
|
-
process.exit(1);
|
82058
|
+
const isNotD1 = !("driver" in credentials2 && credentials2.driver === "d1-http");
|
82059
|
+
isNotD1 ?? await db.run("begin");
|
82060
|
+
try {
|
82061
|
+
for (const dStmnt of statementsToExecute) {
|
82062
|
+
await db.run(dStmnt);
|
82025
82063
|
}
|
82064
|
+
isNotD1 ?? await db.run("commit");
|
82065
|
+
} catch (e2) {
|
82066
|
+
console.error(e2);
|
82067
|
+
isNotD1 ?? await db.run("rollback");
|
82068
|
+
process.exit(1);
|
82026
82069
|
}
|
82027
82070
|
(0, import_hanji13.render)(`[${source_default.green("\u2713")}] Changes applied`);
|
82028
82071
|
}
|
@@ -84323,6 +84366,7 @@ var init_introspect_pg = __esm({
|
|
84323
84366
|
"interval",
|
84324
84367
|
"cidr",
|
84325
84368
|
"inet",
|
84369
|
+
"bytea",
|
84326
84370
|
"macaddr",
|
84327
84371
|
"macaddr8",
|
84328
84372
|
"bigint",
|
@@ -84417,7 +84461,7 @@ var init_introspect_pg = __esm({
|
|
84417
84461
|
return escapeColumnKey4(value);
|
84418
84462
|
}
|
84419
84463
|
if (casing2 === "camel") {
|
84420
|
-
return escapeColumnKey4(
|
84464
|
+
return escapeColumnKey4((0, import_casing5.toCamelCase)(value));
|
84421
84465
|
}
|
84422
84466
|
assertUnreachable(casing2);
|
84423
84467
|
};
|
@@ -84700,6 +84744,9 @@ import { sql } from "drizzle-orm"
|
|
84700
84744
|
if (enumTypes.has(`${typeSchema}.${type.replace("[]", "")}`)) {
|
84701
84745
|
return typeof defaultValue !== "undefined" ? `.default(${mapColumnDefault4(unescapeSingleQuotes(defaultValue, true), isExpression)})` : "";
|
84702
84746
|
}
|
84747
|
+
if (lowered.startsWith("bytea")) {
|
84748
|
+
return typeof defaultValue !== "undefined" ? `.default(${mapColumnDefault4(defaultValue, isExpression)})` : "";
|
84749
|
+
}
|
84703
84750
|
if (lowered.startsWith("integer")) {
|
84704
84751
|
return typeof defaultValue !== "undefined" ? `.default(${mapColumnDefault4(defaultValue, isExpression)})` : "";
|
84705
84752
|
}
|
@@ -84797,6 +84844,10 @@ import { sql } from "drizzle-orm"
|
|
84797
84844
|
if (lowered.startsWith("bigserial")) {
|
84798
84845
|
return `${withCasing3(name, casing2)}: bigserial(${dbColumnName4({ name, casing: casing2, withMode: true })}{ mode: "bigint" })`;
|
84799
84846
|
}
|
84847
|
+
if (lowered.startsWith("bytea")) {
|
84848
|
+
let out = `${withCasing3(name, casing2)}: bytea(${dbColumnName4({ name, casing: casing2 })})`;
|
84849
|
+
return out;
|
84850
|
+
}
|
84800
84851
|
if (lowered.startsWith("integer")) {
|
84801
84852
|
let out = `${withCasing3(name, casing2)}: integer(${dbColumnName4({ name, casing: casing2 })})`;
|
84802
84853
|
return out;
|
@@ -86204,11 +86255,14 @@ var init_introspect = __esm({
|
|
86204
86255
|
}
|
86205
86256
|
tableRelations[toTable2].push({
|
86206
86257
|
name: (0, import_pluralize.plural)(toTable1),
|
86207
|
-
type: "many",
|
86258
|
+
type: "many-through",
|
86208
86259
|
tableFrom: tableFrom2,
|
86209
86260
|
columnsFrom: fk22.columnsFrom,
|
86210
86261
|
tableTo: toTable2,
|
86211
|
-
columnsTo: columnsTo2
|
86262
|
+
columnsTo: columnsTo2,
|
86263
|
+
tableThrough,
|
86264
|
+
columnsThroughFrom,
|
86265
|
+
columnsThroughTo
|
86212
86266
|
});
|
86213
86267
|
}
|
86214
86268
|
} else {
|
@@ -86267,7 +86321,7 @@ import * as schema from "./schema";
|
|
86267
86321
|
(it, originIndex) => relationIndex !== originIndex && it.name === relation.name
|
86268
86322
|
);
|
86269
86323
|
if (hasDuplicatedRelation) {
|
86270
|
-
name = `${relation.name}_${relation.type === "one" ? relation.columnsFrom.join("_") : relation.columnsTo.join("_")}`;
|
86324
|
+
name = `${relation.name}_${relation.type === "through" ? `via_${relation.tableThrough}` : relation.type === "many-through" ? `via_${relation.tableThrough}` : relation.type === "one" ? relation.columnsFrom.join("_") : relation.columnsTo.join("_")}`;
|
86271
86325
|
}
|
86272
86326
|
return {
|
86273
86327
|
...relation,
|
@@ -86288,14 +86342,14 @@ import * as schema from "./schema";
|
|
86288
86342
|
to: ${to}` + (relation.relationName ? `,
|
86289
86343
|
alias: "${relation.relationName}"` : "") + `
|
86290
86344
|
}),`;
|
86291
|
-
} else if (relation.type === "many") {
|
86345
|
+
} else if (relation.type === "many" || relation.type === "many-through") {
|
86292
86346
|
relationString += `
|
86293
86347
|
${relation.name}: r.many.${relation.tableTo}(` + (relation.relationName ? `{
|
86294
86348
|
alias: "${relation.relationName}"
|
86295
86349
|
}` : "") + `),`;
|
86296
86350
|
} else {
|
86297
86351
|
const from = relation.columnsThroughFrom.length === 1 ? `r.${relation.tableFrom}.${relation.columnsFrom[0]}.through(r.${relation.tableThrough}.${relation.columnsThroughFrom[0]})` : `[${relation.columnsThroughFrom.map((it) => `r.${relation.tableFrom}.${it}.through(${relation.tableThrough}.${it})`).join(", ")}]`;
|
86298
|
-
const to = relation.columnsThroughTo.length === 1 ? `r.${relation.tableTo}.${relation.
|
86352
|
+
const to = relation.columnsThroughTo.length === 1 ? `r.${relation.tableTo}.${relation.columnsTo[0]}.through(r.${relation.tableThrough}.${relation.columnsThroughTo[0]})` : `[${relation.columnsThroughTo.map((it) => `r.${relation.tableTo}.${it}.through(${relation.tableThrough}.${it})`).join(", ")}]`;
|
86299
86353
|
relationString += `
|
86300
86354
|
${relation.name}: r.many.${relation.tableTo}({
|
86301
86355
|
from: ${from},
|
@@ -92667,7 +92721,7 @@ init_utils5();
|
|
92667
92721
|
var version2 = async () => {
|
92668
92722
|
const { npmVersion } = await ormCoreVersions();
|
92669
92723
|
const ormVersion = npmVersion ? `drizzle-orm: v${npmVersion}` : "";
|
92670
|
-
const envVersion = "1.0.0-beta.1-
|
92724
|
+
const envVersion = "1.0.0-beta.1-9e70ee7";
|
92671
92725
|
const kitVersion = envVersion ? `v${envVersion}` : "--";
|
92672
92726
|
const versions = `drizzle-kit: ${kitVersion}
|
92673
92727
|
${ormVersion}`;
|
package/package.json
CHANGED
package/utils.js
CHANGED
@@ -6254,6 +6254,9 @@ function escapeSingleQuotes(str) {
|
|
6254
6254
|
return str.replace(/'/g, "''");
|
6255
6255
|
}
|
6256
6256
|
function unescapeSingleQuotes(str, ignoreFirstAndLastChar) {
|
6257
|
+
if (str === "''") {
|
6258
|
+
return str;
|
6259
|
+
}
|
6257
6260
|
const regex = ignoreFirstAndLastChar ? /(?<!^)'(?!$)/g : /'/g;
|
6258
6261
|
return str.replace(/''/g, "'").replace(regex, "\\'");
|
6259
6262
|
}
|
package/utils.mjs
CHANGED
@@ -6231,6 +6231,9 @@ function escapeSingleQuotes(str) {
|
|
6231
6231
|
return str.replace(/'/g, "''");
|
6232
6232
|
}
|
6233
6233
|
function unescapeSingleQuotes(str, ignoreFirstAndLastChar) {
|
6234
|
+
if (str === "''") {
|
6235
|
+
return str;
|
6236
|
+
}
|
6234
6237
|
const regex = ignoreFirstAndLastChar ? /(?<!^)'(?!$)/g : /'/g;
|
6235
6238
|
return str.replace(/''/g, "'").replace(regex, "\\'");
|
6236
6239
|
}
|