rake-db 2.8.50 → 2.9.1

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  import * as orchid_core from 'orchid-core';
2
- import { ColumnTypesBase, EmptyObject, RawExpression, raw, MaybeArray } from 'orchid-core';
2
+ import { ColumnTypesBase, EmptyObject, RawSQLBase, MaybeArray } from 'orchid-core';
3
3
  import * as pqb from 'pqb';
4
- import { ColumnsShape, Db as Db$1, ColumnType, EnumColumn, Adapter, DefaultColumnTypes, DbResult, TransactionAdapter, QueryLogObject, IndexColumnOptions, IndexOptions, ForeignKeyOptions, TextColumn, NoPrimaryKeyOption, TableData, SingleColumnIndexOptions, AdapterOptions, QueryLogOptions } from 'pqb';
4
+ import { ColumnsShape, Db as Db$1, ColumnType, EnumColumn, raw, Adapter, DefaultColumnTypes, DbResult, TransactionAdapter, QueryLogObject, IndexColumnOptions, IndexOptions, ForeignKeyOptions, TextColumn, NoPrimaryKeyOption, TableData, SingleColumnIndexOptions, AdapterOptions, QueryLogOptions } from 'pqb';
5
5
 
6
6
  type CreateTableResult<Table extends string, Shape extends ColumnsShape> = {
7
7
  table: Db$1<Table, Shape>;
@@ -16,8 +16,8 @@ declare function add(items: Record<string, ColumnType>, options?: {
16
16
  }): Record<string, RakeDbAst.ChangeTableItem.Column>;
17
17
  type Change = RakeDbAst.ChangeTableItem.Change & ChangeOptions;
18
18
  type ChangeOptions = {
19
- usingUp?: RawExpression;
20
- usingDown?: RawExpression;
19
+ usingUp?: RawSQLBase;
20
+ usingDown?: RawSQLBase;
21
21
  };
22
22
  type TableChangeMethods = typeof tableChangeMethods;
23
23
  declare const tableChangeMethods: {
@@ -25,7 +25,7 @@ declare const tableChangeMethods: {
25
25
  add: typeof add;
26
26
  drop: typeof add;
27
27
  change(this: ColumnTypesBase, from: ColumnType | Change, to: ColumnType | Change, options?: ChangeOptions): Change;
28
- default(value: unknown | RawExpression): Change;
28
+ default(value: unknown | RawSQLBase): Change;
29
29
  nullable(): Change;
30
30
  nonNullable(): Change;
31
31
  comment(comment: string | null): Change;
@@ -76,7 +76,7 @@ type ConstraintArg = {
76
76
  foreignColumn: [string, ...string[]],
77
77
  options: Omit<ForeignKeyOptions, 'name' | 'dropMode'>
78
78
  ];
79
- check?: RawExpression;
79
+ check?: RawSQLBase;
80
80
  dropMode?: DropMode;
81
81
  };
82
82
  /**
@@ -400,14 +400,14 @@ declare class Migration<CT extends ColumnTypesBase> {
400
400
  * @param tableName - name of the table to add the check into
401
401
  * @param check - raw SQL for the check
402
402
  */
403
- addCheck(tableName: string, check: RawExpression): Promise<void>;
403
+ addCheck(tableName: string, check: RawSQLBase): Promise<void>;
404
404
  /**
405
405
  * Drop the schema, create it on rollback. See {@link addConstraint}.
406
406
  *
407
407
  * @param tableName - name of the table to add the check into
408
408
  * @param check - raw SQL for the check
409
409
  */
410
- dropCheck(tableName: string, check: RawExpression): Promise<void>;
410
+ dropCheck(tableName: string, check: RawSQLBase): Promise<void>;
411
411
  /**
412
412
  * Add or drop a constraint with check and a foreign key references.
413
413
  *
@@ -707,14 +707,14 @@ declare class Migration<CT extends ColumnTypesBase> {
707
707
  * @param options - view options
708
708
  * @param sql - SQL to create the view with
709
709
  */
710
- createView(name: string, options: RakeDbAst.ViewOptions, sql: string | RawExpression): Promise<void>;
710
+ createView(name: string, options: RakeDbAst.ViewOptions, sql: string | RawSQLBase): Promise<void>;
711
711
  /**
712
712
  * See {@link createView}
713
713
  *
714
714
  * @param name - name of the view
715
715
  * @param sql - SQL to create the view with
716
716
  */
717
- createView(name: string, sql: string | RawExpression): Promise<void>;
717
+ createView(name: string, sql: string | RawSQLBase): Promise<void>;
718
718
  /**
719
719
  * Drop the view, create it on rollback. See {@link createView}.
720
720
  *
@@ -722,14 +722,14 @@ declare class Migration<CT extends ColumnTypesBase> {
722
722
  * @param options - view options
723
723
  * @param sql - SQL to create the view with
724
724
  */
725
- dropView(name: string, options: RakeDbAst.ViewOptions, sql: string | RawExpression): Promise<void>;
725
+ dropView(name: string, options: RakeDbAst.ViewOptions, sql: string | RawSQLBase): Promise<void>;
726
726
  /**
727
727
  * Drop the view, create it on rollback. See {@link createView}.
728
728
  *
729
729
  * @param name - name of the view
730
730
  * @param sql - SQL to create the view with
731
731
  */
732
- dropView(name: string, sql: string | RawExpression): Promise<void>;
732
+ dropView(name: string, sql: string | RawSQLBase): Promise<void>;
733
733
  /**
734
734
  * Returns boolean to know if table exists:
735
735
  *
@@ -816,7 +816,7 @@ declare namespace RakeDbAst {
816
816
  name?: string;
817
817
  from: ColumnChange;
818
818
  to: ColumnChange;
819
- using?: RawExpression;
819
+ using?: RawSQLBase;
820
820
  };
821
821
  type Rename = {
822
822
  type: 'rename';
@@ -827,12 +827,12 @@ declare namespace RakeDbAst {
827
827
  column?: ColumnType;
828
828
  type?: string;
829
829
  collate?: string;
830
- default?: unknown | RawExpression;
830
+ default?: unknown | RawSQLBase;
831
831
  nullable?: boolean;
832
832
  comment?: string | null;
833
833
  compression?: string;
834
834
  primaryKey?: boolean;
835
- check?: RawExpression;
835
+ check?: RawSQLBase;
836
836
  foreignKeys?: ({
837
837
  table: string;
838
838
  columns: string[];
@@ -879,8 +879,8 @@ declare namespace RakeDbAst {
879
879
  baseType: ColumnType;
880
880
  notNull?: boolean;
881
881
  collation?: string;
882
- default?: RawExpression;
883
- check?: RawExpression;
882
+ default?: RawSQLBase;
883
+ check?: RawSQLBase;
884
884
  cascade?: boolean;
885
885
  };
886
886
  type Collation = {
@@ -915,7 +915,7 @@ declare namespace RakeDbAst {
915
915
  schema?: string;
916
916
  name: string;
917
917
  shape: ColumnsShape;
918
- sql: RawExpression;
918
+ sql: RawSQLBase;
919
919
  options: ViewOptions;
920
920
  };
921
921
  type ViewOptions = {
@@ -1008,12 +1008,12 @@ declare const rakeDb: <CT extends Record<string, orchid_core.AnyColumnTypeCreato
1008
1008
  };
1009
1009
  timestamp(): T;
1010
1010
  timestampsSnakeCase(): {
1011
- createdAt: orchid_core.ColumnWithDefault<T, orchid_core.RawExpression>;
1012
- updatedAt: orchid_core.ColumnWithDefault<T, orchid_core.RawExpression>;
1011
+ createdAt: orchid_core.ColumnWithDefault<T, orchid_core.RawSQLBase<orchid_core.ColumnTypeBase<unknown, orchid_core.BaseOperators, unknown, orchid_core.ColumnDataBase>, {}>>;
1012
+ updatedAt: orchid_core.ColumnWithDefault<T, orchid_core.RawSQLBase<orchid_core.ColumnTypeBase<unknown, orchid_core.BaseOperators, unknown, orchid_core.ColumnDataBase>, {}>>;
1013
1013
  };
1014
1014
  }): {
1015
- createdAt: orchid_core.ColumnWithDefault<T, orchid_core.RawExpression>;
1016
- updatedAt: orchid_core.ColumnWithDefault<T, orchid_core.RawExpression>;
1015
+ createdAt: orchid_core.ColumnWithDefault<T, orchid_core.RawSQLBase<orchid_core.ColumnTypeBase<unknown, orchid_core.BaseOperators, unknown, orchid_core.ColumnDataBase>, {}>>;
1016
+ updatedAt: orchid_core.ColumnWithDefault<T, orchid_core.RawSQLBase<orchid_core.ColumnTypeBase<unknown, orchid_core.BaseOperators, unknown, orchid_core.ColumnDataBase>, {}>>;
1017
1017
  };
1018
1018
  timestampsSnakeCase<T_1 extends orchid_core.ColumnTypeBase<unknown, orchid_core.BaseOperators, unknown, orchid_core.ColumnDataBase>>(this: {
1019
1019
  name(name: string): {
@@ -1021,8 +1021,8 @@ declare const rakeDb: <CT extends Record<string, orchid_core.AnyColumnTypeCreato
1021
1021
  };
1022
1022
  timestamp(): T_1;
1023
1023
  }): {
1024
- createdAt: orchid_core.ColumnWithDefault<T_1, orchid_core.RawExpression>;
1025
- updatedAt: orchid_core.ColumnWithDefault<T_1, orchid_core.RawExpression>;
1024
+ createdAt: orchid_core.ColumnWithDefault<T_1, orchid_core.RawSQLBase<orchid_core.ColumnTypeBase<unknown, orchid_core.BaseOperators, unknown, orchid_core.ColumnDataBase>, {}>>;
1025
+ updatedAt: orchid_core.ColumnWithDefault<T_1, orchid_core.RawSQLBase<orchid_core.ColumnTypeBase<unknown, orchid_core.BaseOperators, unknown, orchid_core.ColumnDataBase>, {}>>;
1026
1026
  };
1027
1027
  timestampsNoTZ<T_2 extends orchid_core.ColumnTypeBase<unknown, orchid_core.BaseOperators, unknown, orchid_core.ColumnDataBase>>(this: {
1028
1028
  name(name: string): {
@@ -1030,12 +1030,12 @@ declare const rakeDb: <CT extends Record<string, orchid_core.AnyColumnTypeCreato
1030
1030
  };
1031
1031
  timestampNoTZ(): T_2;
1032
1032
  timestampsNoTZSnakeCase(): {
1033
- createdAt: orchid_core.ColumnWithDefault<T_2, orchid_core.RawExpression>;
1034
- updatedAt: orchid_core.ColumnWithDefault<T_2, orchid_core.RawExpression>;
1033
+ createdAt: orchid_core.ColumnWithDefault<T_2, orchid_core.RawSQLBase<orchid_core.ColumnTypeBase<unknown, orchid_core.BaseOperators, unknown, orchid_core.ColumnDataBase>, {}>>;
1034
+ updatedAt: orchid_core.ColumnWithDefault<T_2, orchid_core.RawSQLBase<orchid_core.ColumnTypeBase<unknown, orchid_core.BaseOperators, unknown, orchid_core.ColumnDataBase>, {}>>;
1035
1035
  };
1036
1036
  }): {
1037
- createdAt: orchid_core.ColumnWithDefault<T_2, orchid_core.RawExpression>;
1038
- updatedAt: orchid_core.ColumnWithDefault<T_2, orchid_core.RawExpression>;
1037
+ createdAt: orchid_core.ColumnWithDefault<T_2, orchid_core.RawSQLBase<orchid_core.ColumnTypeBase<unknown, orchid_core.BaseOperators, unknown, orchid_core.ColumnDataBase>, {}>>;
1038
+ updatedAt: orchid_core.ColumnWithDefault<T_2, orchid_core.RawSQLBase<orchid_core.ColumnTypeBase<unknown, orchid_core.BaseOperators, unknown, orchid_core.ColumnDataBase>, {}>>;
1039
1039
  };
1040
1040
  timestampsNoTZSnakeCase<T_3 extends orchid_core.ColumnTypeBase<unknown, orchid_core.BaseOperators, unknown, orchid_core.ColumnDataBase>>(this: {
1041
1041
  name(name: string): {
@@ -1043,15 +1043,15 @@ declare const rakeDb: <CT extends Record<string, orchid_core.AnyColumnTypeCreato
1043
1043
  };
1044
1044
  timestampNoTZ(): T_3;
1045
1045
  }): {
1046
- createdAt: orchid_core.ColumnWithDefault<T_3, orchid_core.RawExpression>;
1047
- updatedAt: orchid_core.ColumnWithDefault<T_3, orchid_core.RawExpression>;
1046
+ createdAt: orchid_core.ColumnWithDefault<T_3, orchid_core.RawSQLBase<orchid_core.ColumnTypeBase<unknown, orchid_core.BaseOperators, unknown, orchid_core.ColumnDataBase>, {}>>;
1047
+ updatedAt: orchid_core.ColumnWithDefault<T_3, orchid_core.RawSQLBase<orchid_core.ColumnTypeBase<unknown, orchid_core.BaseOperators, unknown, orchid_core.ColumnDataBase>, {}>>;
1048
1048
  };
1049
1049
  name: typeof orchid_core.name;
1050
1050
  sql: {
1051
- (sql: TemplateStringsArray, ...values: unknown[]): orchid_core.RawExpression;
1052
- (sql: string): orchid_core.RawExpression;
1053
- (values: Record<string, unknown>, sql: string): orchid_core.RawExpression;
1054
- (values: Record<string, unknown>): (strings: TemplateStringsArray, ...values: unknown[]) => orchid_core.RawExpression;
1051
+ (sql: TemplateStringsArray, ...values: unknown[]): orchid_core.RawSQLBase<orchid_core.ColumnTypeBase<unknown, orchid_core.BaseOperators, unknown, orchid_core.ColumnDataBase>, {}>;
1052
+ (sql: string): orchid_core.RawSQLBase<orchid_core.ColumnTypeBase<unknown, orchid_core.BaseOperators, unknown, orchid_core.ColumnDataBase>, {}>;
1053
+ (values: Record<string, unknown>, sql: string): orchid_core.RawSQLBase<orchid_core.ColumnTypeBase<unknown, orchid_core.BaseOperators, unknown, orchid_core.ColumnDataBase>, {}>;
1054
+ (values: Record<string, unknown>): (strings: TemplateStringsArray, ...values: unknown[]) => orchid_core.RawSQLBase<orchid_core.ColumnTypeBase<unknown, orchid_core.BaseOperators, unknown, orchid_core.ColumnDataBase>, {}>;
1055
1055
  };
1056
1056
  smallint(): pqb.SmallIntColumn;
1057
1057
  integer(): pqb.IntegerColumn;
@@ -1140,14 +1140,14 @@ declare const rakeDb: <CT extends Record<string, orchid_core.AnyColumnTypeCreato
1140
1140
  constraint<Table extends string | (() => orchid_core.ForeignKeyTable), Columns extends Table extends () => orchid_core.ForeignKeyTable ? [orchid_core.ColumnNameOfTable<ReturnType<Table>>, ...orchid_core.ColumnNameOfTable<ReturnType<Table>>[]] : [string, ...string[]]>({ name, references, check, dropMode, }: {
1141
1141
  name?: string | undefined;
1142
1142
  references?: [columns: string[], fnOrTable: Table, foreignColumns: Columns, options?: pqb.ForeignKeyOptions | undefined] | undefined;
1143
- check?: orchid_core.RawExpression | undefined;
1143
+ check?: orchid_core.RawSQLBase<orchid_core.ColumnTypeBase<unknown, orchid_core.BaseOperators, unknown, orchid_core.ColumnDataBase>, {}> | undefined;
1144
1144
  dropMode?: pqb.DropMode | undefined;
1145
1145
  }): {};
1146
1146
  foreignKey<Table_1 extends string | (() => orchid_core.ForeignKeyTable), Columns_1 extends Table_1 extends () => orchid_core.ForeignKeyTable ? [orchid_core.ColumnNameOfTable<ReturnType<Table_1>>, ...orchid_core.ColumnNameOfTable<ReturnType<Table_1>>[]] : [string, ...string[]]>(columns: string[], fnOrTable: Table_1, foreignColumns: Columns_1, options?: (pqb.ForeignKeyOptions & {
1147
1147
  name?: string | undefined;
1148
1148
  dropMode?: pqb.DropMode | undefined;
1149
1149
  }) | undefined): {};
1150
- check(check: orchid_core.RawExpression): {};
1150
+ check(check: orchid_core.RawSQLBase<orchid_core.ColumnTypeBase<unknown, orchid_core.BaseOperators, unknown, orchid_core.ColumnDataBase>, {}>): {};
1151
1151
  }>(options: MaybeArray<AdapterOptions>, partialConfig?: InputRakeDbConfig<CT>, args?: string[]) => ((fn: ChangeCallback<CT>) => void) & {
1152
1152
  promise: Promise<void>;
1153
1153
  };
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 (typeof item.data.default === "object" && item.data.default && orchidCore.isRaw(item.data.default)) {
333
- line.push(`DEFAULT ${pqb.getRaw(item.data.default, values)}`);
332
+ if (typeof item.data.default === "object" && item.data.default && 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 (${pqb.getRaw(check, 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 ${typeof options.where === "object" && options.where && orchidCore.isRaw(options.where) ? pqb.getRaw(options.where, 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 ${pqb.getRaw(item.using, 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.isRaw(to.default) ? pqb.getRaw(to.default, 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,8 +1088,7 @@ const astToQueries = (ast, snakeCase) => {
1088
1088
  if (to.check) {
1089
1089
  alterTable.push(
1090
1090
  `ADD CONSTRAINT "${checkName}"
1091
- CHECK (${pqb.getRaw(
1092
- to.check,
1091
+ CHECK (${to.check.toSQL(
1093
1092
  values
1094
1093
  )})`
1095
1094
  );
@@ -1235,7 +1234,7 @@ const createView$1 = async (migration, up, name, options, sql) => {
1235
1234
  };
1236
1235
  const makeAst = (up, name, options, sql) => {
1237
1236
  if (typeof sql === "string") {
1238
- sql = orchidCore.raw(sql);
1237
+ sql = pqb.raw({ raw: sql });
1239
1238
  }
1240
1239
  return {
1241
1240
  type: "view",
@@ -1274,7 +1273,7 @@ const astToQuery = (ast) => {
1274
1273
  list.push(`security_invoker = true`);
1275
1274
  sql.push(`WITH ( ${list.join(", ")} )`);
1276
1275
  }
1277
- sql.push(`AS (${pqb.getRaw(ast.sql, values)})`);
1276
+ sql.push(`AS (${ast.sql.toSQL(values)})`);
1278
1277
  } else {
1279
1278
  sql.push("DROP VIEW");
1280
1279
  if (options == null ? void 0 : options.dropIfExists)
@@ -2038,9 +2037,9 @@ const createDomain$1 = async (migration, up, name, fn, options) => {
2038
2037
  if (ast.action === "create") {
2039
2038
  query = `CREATE DOMAIN ${quotedName} AS ${columnTypeToSql(ast.baseType)}${ast.collation ? `
2040
2039
  COLLATION ${orchidCore.singleQuote(ast.collation)}` : ""}${ast.default ? `
2041
- DEFAULT ${pqb.getRaw(ast.default, values)}` : ""}${ast.notNull || ast.check ? "\n" : ""}${[
2040
+ DEFAULT ${ast.default.toSQL(values)}` : ""}${ast.notNull || ast.check ? "\n" : ""}${[
2042
2041
  ast.notNull && "NOT NULL",
2043
- ast.check && `CHECK ${pqb.getRaw(ast.check, values)}`
2042
+ ast.check && `CHECK ${ast.check.toSQL(values)}`
2044
2043
  ].filter(Boolean).join(" ")}`;
2045
2044
  } else {
2046
2045
  query = `DROP DOMAIN ${quotedName}${ast.cascade ? " CASCADE" : ""}`;
@@ -2954,7 +2953,7 @@ const structureToAst = async (ctx, db) => {
2954
2953
  notNull: it.notNull,
2955
2954
  collation: it.collation,
2956
2955
  default: pqb.simplifyColumnDefault(it.default),
2957
- check: it.check ? orchidCore.raw(it.check) : void 0
2956
+ check: it.check ? pqb.raw({ raw: it.check }) : void 0
2958
2957
  });
2959
2958
  }
2960
2959
  for (const key in pendingTables) {
@@ -3111,7 +3110,7 @@ const pushTableAst = (ctx, ast, data, domains, table, pendingTables, innerConstr
3111
3110
  onDelete: fkeyActionMap[references.onDelete]
3112
3111
  }
3113
3112
  } : void 0,
3114
- check: check ? orchidCore.raw(check.expression) : void 0
3113
+ check: check ? pqb.raw({ raw: check.expression }) : void 0
3115
3114
  };
3116
3115
  const name = item.name && item.name !== getConstraintName(tableName, constraint) ? item.name : void 0;
3117
3116
  if (name) {
@@ -3211,7 +3210,7 @@ const constraintToAst = (ctx, item) => {
3211
3210
  options.onDelete = onDelete;
3212
3211
  }
3213
3212
  if (check) {
3214
- result.check = orchidCore.raw(check.expression);
3213
+ result.check = pqb.raw({ raw: check.expression });
3215
3214
  }
3216
3215
  if (item.name && item.name !== getConstraintName(item.tableName, result)) {
3217
3216
  result.name = item.name;
@@ -3251,7 +3250,7 @@ const viewToAst = (ctx, data, domains, view) => {
3251
3250
  schema: view.schemaName === ctx.currentSchema ? void 0 : view.schemaName,
3252
3251
  name: view.name,
3253
3252
  shape,
3254
- sql: orchidCore.raw(view.sql),
3253
+ sql: pqb.raw({ raw: view.sql }),
3255
3254
  options
3256
3255
  };
3257
3256
  };
@@ -3310,7 +3309,7 @@ const makeColumnsShape = (ctx, data, domains, tableName, columns, primaryKey, in
3310
3309
  }
3311
3310
  const check = checks == null ? void 0 : checks[item.name];
3312
3311
  if (check) {
3313
- column.data.check = orchidCore.raw(check);
3312
+ column.data.check = pqb.raw({ raw: check });
3314
3313
  }
3315
3314
  const camelCaseName = orchidCore.toCamelCase(item.name);
3316
3315
  if (ctx.snakeCase) {
@@ -3421,9 +3420,9 @@ const createDomain = (ast) => {
3421
3420
  if (ast.collation)
3422
3421
  props.push(`collation: ${orchidCore.singleQuote(ast.collation)},`);
3423
3422
  if (ast.default)
3424
- props.push(`default: ${orchidCore.rawToCode("db", ast.default)},`);
3423
+ props.push(`default: ${ast.default.toCode("db")},`);
3425
3424
  if (ast.check)
3426
- props.push(`check: ${orchidCore.rawToCode("db", ast.check)},`);
3425
+ props.push(`check: ${ast.check.toCode("db")},`);
3427
3426
  orchidCore.addCode(code, ", {");
3428
3427
  code.push(props);
3429
3428
  orchidCore.addCode(code, "}");
@@ -3494,7 +3493,7 @@ const isTimestamp = (column, type) => {
3494
3493
  if (!column)
3495
3494
  return false;
3496
3495
  const { default: def } = column.data;
3497
- return column instanceof type && !column.data.isNullable && def && typeof def === "object" && orchidCore.isRaw(def) && def.__raw === "now()";
3496
+ return column instanceof type && !column.data.isNullable && def && typeof def === "object" && orchidCore.isRawSQL(def) && def._sql === "now()";
3498
3497
  };
3499
3498
  const getTimestampsInfo = (config, ast, type) => {
3500
3499
  var _a, _b, _c, _d, _e, _f;
@@ -3524,7 +3523,7 @@ const createConstraint = (item) => {
3524
3523
  ];
3525
3524
  }
3526
3525
  if (kind === "check" && item.check) {
3527
- return [`await db.addCheck(${table}, ${orchidCore.rawToCode("t", item.check)});`];
3526
+ return [`await db.addCheck(${table}, ${item.check.toCode("t")});`];
3528
3527
  }
3529
3528
  return [
3530
3529
  `await db.addConstraint(${table}, {`,
@@ -3549,8 +3548,8 @@ const createView = (ast) => {
3549
3548
  code.push(options, "}");
3550
3549
  }
3551
3550
  orchidCore.addCode(code, ", ");
3552
- if (!ast.sql.__values) {
3553
- const raw = ast.sql.__raw;
3551
+ if (!ast.sql._values) {
3552
+ const raw = ast.sql._sql;
3554
3553
  let sql;
3555
3554
  if (typeof raw === "string") {
3556
3555
  sql = raw;
@@ -3565,7 +3564,7 @@ const createView = (ast) => {
3565
3564
  }
3566
3565
  orchidCore.addCode(code, orchidCore.backtickQuote(sql));
3567
3566
  } else {
3568
- orchidCore.addCode(code, orchidCore.rawToCode("db", ast.sql));
3567
+ orchidCore.addCode(code, ast.sql.toCode("db"));
3569
3568
  }
3570
3569
  orchidCore.addCode(code, ");");
3571
3570
  return code;