rake-db 2.9.2 → 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.d.ts
CHANGED
|
@@ -1129,7 +1129,7 @@ declare const rakeDb: <CT extends Record<string, orchid_core.AnyColumnTypeCreato
|
|
|
1129
1129
|
record: typeof orchid_core.record;
|
|
1130
1130
|
}) => Type)): pqb.JSONColumn<Type>;
|
|
1131
1131
|
jsonText(): pqb.JSONTextColumn;
|
|
1132
|
-
array<Item extends pqb.ColumnType<unknown,
|
|
1132
|
+
array<Item extends pqb.ColumnType<unknown, pqb.BaseOperators, unknown>>(item: Item): pqb.ArrayColumn<Item>;
|
|
1133
1133
|
type(dataType: string): pqb.CustomTypeColumn;
|
|
1134
1134
|
domain(dataType: string): pqb.DomainColumn;
|
|
1135
1135
|
primaryKey(columns: string[], options?: {
|
package/dist/index.js
CHANGED
|
@@ -329,8 +329,8 @@ const columnToSql = (name, item, values, hasMultiplePrimaryKeys, snakeCase) => {
|
|
|
329
329
|
line.push(checkToSql(item.data.check, values));
|
|
330
330
|
}
|
|
331
331
|
if (item.data.default !== void 0) {
|
|
332
|
-
if (
|
|
333
|
-
line.push(`DEFAULT ${item.data.default.toSQL(values)}`);
|
|
332
|
+
if (orchidCore.isRawSQL(item.data.default)) {
|
|
333
|
+
line.push(`DEFAULT ${item.data.default.toSQL({ values })}`);
|
|
334
334
|
} else {
|
|
335
335
|
line.push(`DEFAULT ${pqb.quote(item.data.default)}`);
|
|
336
336
|
}
|
|
@@ -427,7 +427,7 @@ const constraintToSql = ({ name }, up, constraint, values, snakeCase) => {
|
|
|
427
427
|
return sql.join(" ");
|
|
428
428
|
};
|
|
429
429
|
const checkToSql = (check, values) => {
|
|
430
|
-
return `CHECK (${check.toSQL(values)})`;
|
|
430
|
+
return `CHECK (${check.toSQL({ values })})`;
|
|
431
431
|
};
|
|
432
432
|
const foreignKeyToSql = (item, snakeCase) => {
|
|
433
433
|
return `FOREIGN KEY (${joinColumns(item.columns)}) ${referencesToSql(
|
|
@@ -513,7 +513,7 @@ const indexesToQuery = (up, { schema, name }, indexes) => {
|
|
|
513
513
|
}
|
|
514
514
|
if (options.where) {
|
|
515
515
|
sql.push(
|
|
516
|
-
`WHERE ${orchidCore.isRawSQL(options.where) ? options.where.toSQL(values) : options.where}`
|
|
516
|
+
`WHERE ${orchidCore.isRawSQL(options.where) ? options.where.toSQL({ values }) : options.where}`
|
|
517
517
|
);
|
|
518
518
|
}
|
|
519
519
|
return { text: sql.join(" "), values };
|
|
@@ -1057,7 +1057,7 @@ const astToQueries = (ast, snakeCase) => {
|
|
|
1057
1057
|
if (to.type && (from.type !== to.type || from.collate !== to.collate)) {
|
|
1058
1058
|
const type = !to.column || to.column.data.isOfCustomType ? `"${to.type}"` : to.type;
|
|
1059
1059
|
alterTable.push(
|
|
1060
|
-
`ALTER COLUMN "${name}" TYPE ${type}${to.collate ? ` COLLATE ${quoteNameFromString(to.collate)}` : ""}${item.using ? ` USING ${item.using.toSQL(values)}` : ""}`
|
|
1060
|
+
`ALTER COLUMN "${name}" TYPE ${type}${to.collate ? ` COLLATE ${quoteNameFromString(to.collate)}` : ""}${item.using ? ` USING ${item.using.toSQL({ values })}` : ""}`
|
|
1061
1061
|
);
|
|
1062
1062
|
}
|
|
1063
1063
|
if (typeof from.identity !== typeof to.identity || !orchidCore.deepCompare(from.identity, to.identity)) {
|
|
@@ -1066,7 +1066,7 @@ const astToQueries = (ast, snakeCase) => {
|
|
|
1066
1066
|
);
|
|
1067
1067
|
}
|
|
1068
1068
|
if (from.default !== to.default) {
|
|
1069
|
-
const value = typeof to.default === "object" && to.default && orchidCore.isRawSQL(to.default) ? to.default.toSQL(values) : pqb.quote(to.default);
|
|
1069
|
+
const value = typeof to.default === "object" && to.default && orchidCore.isRawSQL(to.default) ? to.default.toSQL({ values }) : pqb.quote(to.default);
|
|
1070
1070
|
const expr = value === void 0 ? "DROP DEFAULT" : `SET DEFAULT ${value}`;
|
|
1071
1071
|
alterTable.push(`ALTER COLUMN "${name}" ${expr}`);
|
|
1072
1072
|
}
|
|
@@ -1088,9 +1088,9 @@ const astToQueries = (ast, snakeCase) => {
|
|
|
1088
1088
|
if (to.check) {
|
|
1089
1089
|
alterTable.push(
|
|
1090
1090
|
`ADD CONSTRAINT "${checkName}"
|
|
1091
|
-
CHECK (${to.check.toSQL(
|
|
1091
|
+
CHECK (${to.check.toSQL({
|
|
1092
1092
|
values
|
|
1093
|
-
)})`
|
|
1093
|
+
})})`
|
|
1094
1094
|
);
|
|
1095
1095
|
}
|
|
1096
1096
|
}
|
|
@@ -1273,7 +1273,7 @@ const astToQuery = (ast) => {
|
|
|
1273
1273
|
list.push(`security_invoker = true`);
|
|
1274
1274
|
sql.push(`WITH ( ${list.join(", ")} )`);
|
|
1275
1275
|
}
|
|
1276
|
-
sql.push(`AS (${ast.sql.toSQL(values)})`);
|
|
1276
|
+
sql.push(`AS (${ast.sql.toSQL({ values })})`);
|
|
1277
1277
|
} else {
|
|
1278
1278
|
sql.push("DROP VIEW");
|
|
1279
1279
|
if (options == null ? void 0 : options.dropIfExists)
|
|
@@ -2037,9 +2037,9 @@ const createDomain$1 = async (migration, up, name, fn, options) => {
|
|
|
2037
2037
|
if (ast.action === "create") {
|
|
2038
2038
|
query = `CREATE DOMAIN ${quotedName} AS ${columnTypeToSql(ast.baseType)}${ast.collation ? `
|
|
2039
2039
|
COLLATION ${orchidCore.singleQuote(ast.collation)}` : ""}${ast.default ? `
|
|
2040
|
-
DEFAULT ${ast.default.toSQL(values)}` : ""}${ast.notNull || ast.check ? "\n" : ""}${[
|
|
2040
|
+
DEFAULT ${ast.default.toSQL({ values })}` : ""}${ast.notNull || ast.check ? "\n" : ""}${[
|
|
2041
2041
|
ast.notNull && "NOT NULL",
|
|
2042
|
-
ast.check && `CHECK ${ast.check.toSQL(values)}`
|
|
2042
|
+
ast.check && `CHECK ${ast.check.toSQL({ values })}`
|
|
2043
2043
|
].filter(Boolean).join(" ")}`;
|
|
2044
2044
|
} else {
|
|
2045
2045
|
query = `DROP DOMAIN ${quotedName}${ast.cascade ? " CASCADE" : ""}`;
|