rake-db 2.9.3 → 2.10.0
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.ts +1 -1
- package/dist/index.js +11 -11
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +11 -11
- package/dist/index.mjs.map +1 -1
- package/package.json +3 -3
package/dist/index.mjs
CHANGED
|
@@ -308,8 +308,8 @@ const columnToSql = (name, item, values, hasMultiplePrimaryKeys, snakeCase) => {
|
|
|
308
308
|
line.push(checkToSql(item.data.check, values));
|
|
309
309
|
}
|
|
310
310
|
if (item.data.default !== void 0) {
|
|
311
|
-
if (
|
|
312
|
-
line.push(`DEFAULT ${item.data.default.toSQL(values)}`);
|
|
311
|
+
if (isRawSQL(item.data.default)) {
|
|
312
|
+
line.push(`DEFAULT ${item.data.default.toSQL({ values })}`);
|
|
313
313
|
} else {
|
|
314
314
|
line.push(`DEFAULT ${quote(item.data.default)}`);
|
|
315
315
|
}
|
|
@@ -406,7 +406,7 @@ const constraintToSql = ({ name }, up, constraint, values, snakeCase) => {
|
|
|
406
406
|
return sql.join(" ");
|
|
407
407
|
};
|
|
408
408
|
const checkToSql = (check, values) => {
|
|
409
|
-
return `CHECK (${check.toSQL(values)})`;
|
|
409
|
+
return `CHECK (${check.toSQL({ values })})`;
|
|
410
410
|
};
|
|
411
411
|
const foreignKeyToSql = (item, snakeCase) => {
|
|
412
412
|
return `FOREIGN KEY (${joinColumns(item.columns)}) ${referencesToSql(
|
|
@@ -492,7 +492,7 @@ const indexesToQuery = (up, { schema, name }, indexes) => {
|
|
|
492
492
|
}
|
|
493
493
|
if (options.where) {
|
|
494
494
|
sql.push(
|
|
495
|
-
`WHERE ${isRawSQL(options.where) ? options.where.toSQL(values) : options.where}`
|
|
495
|
+
`WHERE ${isRawSQL(options.where) ? options.where.toSQL({ values }) : options.where}`
|
|
496
496
|
);
|
|
497
497
|
}
|
|
498
498
|
return { text: sql.join(" "), values };
|
|
@@ -1036,7 +1036,7 @@ const astToQueries = (ast, snakeCase) => {
|
|
|
1036
1036
|
if (to.type && (from.type !== to.type || from.collate !== to.collate)) {
|
|
1037
1037
|
const type = !to.column || to.column.data.isOfCustomType ? `"${to.type}"` : to.type;
|
|
1038
1038
|
alterTable.push(
|
|
1039
|
-
`ALTER COLUMN "${name}" TYPE ${type}${to.collate ? ` COLLATE ${quoteNameFromString(to.collate)}` : ""}${item.using ? ` USING ${item.using.toSQL(values)}` : ""}`
|
|
1039
|
+
`ALTER COLUMN "${name}" TYPE ${type}${to.collate ? ` COLLATE ${quoteNameFromString(to.collate)}` : ""}${item.using ? ` USING ${item.using.toSQL({ values })}` : ""}`
|
|
1040
1040
|
);
|
|
1041
1041
|
}
|
|
1042
1042
|
if (typeof from.identity !== typeof to.identity || !deepCompare(from.identity, to.identity)) {
|
|
@@ -1045,7 +1045,7 @@ const astToQueries = (ast, snakeCase) => {
|
|
|
1045
1045
|
);
|
|
1046
1046
|
}
|
|
1047
1047
|
if (from.default !== to.default) {
|
|
1048
|
-
const value = typeof to.default === "object" && to.default && isRawSQL(to.default) ? to.default.toSQL(values) : quote(to.default);
|
|
1048
|
+
const value = typeof to.default === "object" && to.default && isRawSQL(to.default) ? to.default.toSQL({ values }) : quote(to.default);
|
|
1049
1049
|
const expr = value === void 0 ? "DROP DEFAULT" : `SET DEFAULT ${value}`;
|
|
1050
1050
|
alterTable.push(`ALTER COLUMN "${name}" ${expr}`);
|
|
1051
1051
|
}
|
|
@@ -1067,9 +1067,9 @@ const astToQueries = (ast, snakeCase) => {
|
|
|
1067
1067
|
if (to.check) {
|
|
1068
1068
|
alterTable.push(
|
|
1069
1069
|
`ADD CONSTRAINT "${checkName}"
|
|
1070
|
-
CHECK (${to.check.toSQL(
|
|
1070
|
+
CHECK (${to.check.toSQL({
|
|
1071
1071
|
values
|
|
1072
|
-
)})`
|
|
1072
|
+
})})`
|
|
1073
1073
|
);
|
|
1074
1074
|
}
|
|
1075
1075
|
}
|
|
@@ -1252,7 +1252,7 @@ const astToQuery = (ast) => {
|
|
|
1252
1252
|
list.push(`security_invoker = true`);
|
|
1253
1253
|
sql.push(`WITH ( ${list.join(", ")} )`);
|
|
1254
1254
|
}
|
|
1255
|
-
sql.push(`AS (${ast.sql.toSQL(values)})`);
|
|
1255
|
+
sql.push(`AS (${ast.sql.toSQL({ values })})`);
|
|
1256
1256
|
} else {
|
|
1257
1257
|
sql.push("DROP VIEW");
|
|
1258
1258
|
if (options == null ? void 0 : options.dropIfExists)
|
|
@@ -2016,9 +2016,9 @@ const createDomain$1 = async (migration, up, name, fn, options) => {
|
|
|
2016
2016
|
if (ast.action === "create") {
|
|
2017
2017
|
query = `CREATE DOMAIN ${quotedName} AS ${columnTypeToSql(ast.baseType)}${ast.collation ? `
|
|
2018
2018
|
COLLATION ${singleQuote(ast.collation)}` : ""}${ast.default ? `
|
|
2019
|
-
DEFAULT ${ast.default.toSQL(values)}` : ""}${ast.notNull || ast.check ? "\n" : ""}${[
|
|
2019
|
+
DEFAULT ${ast.default.toSQL({ values })}` : ""}${ast.notNull || ast.check ? "\n" : ""}${[
|
|
2020
2020
|
ast.notNull && "NOT NULL",
|
|
2021
|
-
ast.check && `CHECK ${ast.check.toSQL(values)}`
|
|
2021
|
+
ast.check && `CHECK ${ast.check.toSQL({ values })}`
|
|
2022
2022
|
].filter(Boolean).join(" ")}`;
|
|
2023
2023
|
} else {
|
|
2024
2024
|
query = `DROP DOMAIN ${quotedName}${ast.cascade ? " CASCADE" : ""}`;
|