orchid-orm 1.9.19 → 1.9.21

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
@@ -141,27 +141,28 @@ type TableToDb<T extends Table> = Db<T['table'], T['columns']['shape'], 'relatio
141
141
  name: string;
142
142
  };
143
143
  type DbTable<T extends TableClass> = TableToDb<InstanceType<T>> & Omit<MapRelations<InstanceType<T>>, keyof Query>;
144
- type TableConfig = {
144
+ type ColumnsConfig = {
145
145
  shape: ColumnsShape;
146
146
  type: unknown;
147
147
  };
148
148
  type ScopeFn<Related extends TableClass, Scope extends Query> = (q: DbTable<Related>) => Scope;
149
149
  type Table = {
150
150
  table: string;
151
- columns: TableConfig;
151
+ columns: ColumnsConfig;
152
152
  schema?: string;
153
153
  columnTypes: ColumnTypesBase;
154
154
  noPrimaryKey?: boolean;
155
155
  filePath: string;
156
156
  };
157
- declare const createBaseTable: <CT extends Record<string, orchid_core.AnyColumnTypeCreator>>({ columnTypes, snakeCase, filePath, }?: {
157
+ declare const createBaseTable: <CT extends Record<string, orchid_core.AnyColumnTypeCreator>>({ columnTypes, snakeCase, filePath, nowSQL, }?: {
158
158
  columnTypes?: CT | ((t: DefaultColumnTypes) => CT) | undefined;
159
159
  snakeCase?: boolean | undefined;
160
160
  filePath?: string | undefined;
161
+ nowSQL?: string | undefined;
161
162
  }) => {
162
163
  new (): {
163
164
  table: string;
164
- columns: TableConfig;
165
+ columns: ColumnsConfig;
165
166
  schema?: string | undefined;
166
167
  noPrimaryKey?: boolean | undefined;
167
168
  snakeCase: boolean | undefined;
@@ -512,6 +513,7 @@ declare const createBaseTable: <CT extends Record<string, orchid_core.AnyColumnT
512
513
  };
513
514
  };
514
515
  filePath: string;
516
+ nowSQL: string | undefined;
515
517
  };
516
518
 
517
519
  type QueryMethods<T extends Query> = Record<string, (q: T, ...args: any[]) => any>;
package/dist/index.js CHANGED
@@ -30,7 +30,8 @@ var path__namespace = /*#__PURE__*/_interopNamespaceDefault(path);
30
30
  const createBaseTable = ({
31
31
  columnTypes,
32
32
  snakeCase,
33
- filePath
33
+ filePath,
34
+ nowSQL
34
35
  } = { columnTypes: pqb.columnTypes }) => {
35
36
  const ct = typeof columnTypes === "function" ? columnTypes(pqb.columnTypes) : columnTypes || pqb.columnTypes;
36
37
  filePath != null ? filePath : filePath = orchidCore.getCallerFilePath();
@@ -42,10 +43,11 @@ const createBaseTable = ({
42
43
  return create(
43
44
  ct,
44
45
  filePath,
45
- snakeCase
46
+ snakeCase,
47
+ nowSQL
46
48
  );
47
49
  };
48
- const create = (columnTypes, filePath, snakeCase) => {
50
+ const create = (columnTypes, filePath, snakeCase, nowSQL) => {
49
51
  var _a;
50
52
  const base = (_a = class {
51
53
  constructor() {
@@ -63,7 +65,7 @@ const create = (columnTypes, filePath, snakeCase) => {
63
65
  this.filePath = filePath2;
64
66
  }
65
67
  columnTypes[orchidCore.snakeCaseKey] = this.snakeCase;
66
- const shape = pqb.getColumnTypes(columnTypes, fn);
68
+ const shape = pqb.getColumnTypes(columnTypes, fn, nowSQL);
67
69
  if (this.snakeCase) {
68
70
  for (const key in shape) {
69
71
  const column = shape[key];
@@ -112,7 +114,7 @@ const create = (columnTypes, filePath, snakeCase) => {
112
114
  options
113
115
  };
114
116
  }
115
- }, _a.filePath = filePath, _a);
117
+ }, _a.filePath = filePath, _a.nowSQL = nowSQL, _a);
116
118
  base.prototype.columnTypes = columnTypes;
117
119
  return base;
118
120
  };