latticesql 1.6.6 → 1.6.8
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/cli.js +13 -0
- package/dist/index.cjs +13 -0
- package/dist/index.js +13 -0
- package/package.json +1 -1
package/dist/cli.js
CHANGED
|
@@ -566,8 +566,21 @@ function translateDialect(sql) {
|
|
|
566
566
|
if (hadInsertOrIgnore && !hasOnConflictInCode(s)) {
|
|
567
567
|
s = s.replace(/(\s*;?\s*)$/, " ON CONFLICT DO NOTHING$1");
|
|
568
568
|
}
|
|
569
|
+
s = mapCodeRegions(
|
|
570
|
+
s,
|
|
571
|
+
(code) => code.replace(/CREATE(\s+)VIEW(\s+)IF\s+NOT\s+EXISTS/gi, (_m, w1, _w2) => {
|
|
572
|
+
return `CREATE${w1}OR REPLACE VIEW`;
|
|
573
|
+
})
|
|
574
|
+
);
|
|
569
575
|
s = replaceFunction(s, "hex", (arg) => `encode(${arg}, 'hex')`);
|
|
570
576
|
s = replaceFunction(s, "randomblob", (arg) => `gen_random_bytes(${arg})`);
|
|
577
|
+
s = replaceFunction(s, "datetime", (arg) => {
|
|
578
|
+
const trimmed = arg.trim();
|
|
579
|
+
if (trimmed === "'now'" || trimmed === '"now"') return "NOW()";
|
|
580
|
+
throw new Error(
|
|
581
|
+
"PostgresAdapter: datetime(" + arg + ") is not auto-translated. Only datetime('now') is supported. Use NOW() or an equivalent Postgres expression in your migration."
|
|
582
|
+
);
|
|
583
|
+
});
|
|
571
584
|
return s;
|
|
572
585
|
}
|
|
573
586
|
function hasOnConflictInCode(sql) {
|
package/dist/index.cjs
CHANGED
|
@@ -316,8 +316,21 @@ function translateDialect(sql) {
|
|
|
316
316
|
if (hadInsertOrIgnore && !hasOnConflictInCode(s)) {
|
|
317
317
|
s = s.replace(/(\s*;?\s*)$/, " ON CONFLICT DO NOTHING$1");
|
|
318
318
|
}
|
|
319
|
+
s = mapCodeRegions(
|
|
320
|
+
s,
|
|
321
|
+
(code) => code.replace(/CREATE(\s+)VIEW(\s+)IF\s+NOT\s+EXISTS/gi, (_m, w1, _w2) => {
|
|
322
|
+
return `CREATE${w1}OR REPLACE VIEW`;
|
|
323
|
+
})
|
|
324
|
+
);
|
|
319
325
|
s = replaceFunction(s, "hex", (arg) => `encode(${arg}, 'hex')`);
|
|
320
326
|
s = replaceFunction(s, "randomblob", (arg) => `gen_random_bytes(${arg})`);
|
|
327
|
+
s = replaceFunction(s, "datetime", (arg) => {
|
|
328
|
+
const trimmed = arg.trim();
|
|
329
|
+
if (trimmed === "'now'" || trimmed === '"now"') return "NOW()";
|
|
330
|
+
throw new Error(
|
|
331
|
+
"PostgresAdapter: datetime(" + arg + ") is not auto-translated. Only datetime('now') is supported. Use NOW() or an equivalent Postgres expression in your migration."
|
|
332
|
+
);
|
|
333
|
+
});
|
|
321
334
|
return s;
|
|
322
335
|
}
|
|
323
336
|
function hasOnConflictInCode(sql) {
|
package/dist/index.js
CHANGED
|
@@ -251,8 +251,21 @@ function translateDialect(sql) {
|
|
|
251
251
|
if (hadInsertOrIgnore && !hasOnConflictInCode(s)) {
|
|
252
252
|
s = s.replace(/(\s*;?\s*)$/, " ON CONFLICT DO NOTHING$1");
|
|
253
253
|
}
|
|
254
|
+
s = mapCodeRegions(
|
|
255
|
+
s,
|
|
256
|
+
(code) => code.replace(/CREATE(\s+)VIEW(\s+)IF\s+NOT\s+EXISTS/gi, (_m, w1, _w2) => {
|
|
257
|
+
return `CREATE${w1}OR REPLACE VIEW`;
|
|
258
|
+
})
|
|
259
|
+
);
|
|
254
260
|
s = replaceFunction(s, "hex", (arg) => `encode(${arg}, 'hex')`);
|
|
255
261
|
s = replaceFunction(s, "randomblob", (arg) => `gen_random_bytes(${arg})`);
|
|
262
|
+
s = replaceFunction(s, "datetime", (arg) => {
|
|
263
|
+
const trimmed = arg.trim();
|
|
264
|
+
if (trimmed === "'now'" || trimmed === '"now"') return "NOW()";
|
|
265
|
+
throw new Error(
|
|
266
|
+
"PostgresAdapter: datetime(" + arg + ") is not auto-translated. Only datetime('now') is supported. Use NOW() or an equivalent Postgres expression in your migration."
|
|
267
|
+
);
|
|
268
|
+
});
|
|
256
269
|
return s;
|
|
257
270
|
}
|
|
258
271
|
function hasOnConflictInCode(sql) {
|
package/package.json
CHANGED