@tstdl/base 0.92.94 → 0.92.95

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.
@@ -8,7 +8,7 @@ type ConverterContext = {
8
8
  };
9
9
  export declare const getDrizzleTableFromType: typeof _getDrizzleTableFromType;
10
10
  export declare function getColumnDefinitions(table: PgTableWithColumns<any>): ColumnDefinition[];
11
- export declare function _getDrizzleTableFromType<T extends EntityType, S extends string>(type: T, schemaName?: S): PgTableFromType<T, S>;
11
+ export declare function _getDrizzleTableFromType<T extends EntityType, S extends string>(type: T, fallbackSchemaName?: S): PgTableFromType<T, S>;
12
12
  export declare function registerEnum(enumeration: Enumeration, name: string): void;
13
13
  export declare function getPgEnum(schema: string | PgSchema, enumeration: Enumeration, context?: ConverterContext): PgEnum<[string, ...string[]]>;
14
14
  export {};
@@ -25,7 +25,7 @@ const columnDefinitionsSymbol = Symbol('columnDefinitions');
25
25
  export function getColumnDefinitions(table) {
26
26
  return table[columnDefinitionsSymbol];
27
27
  }
28
- export function _getDrizzleTableFromType(type, schemaName) {
28
+ export function _getDrizzleTableFromType(type, fallbackSchemaName) {
29
29
  const metadata = reflectionRegistry.getMetadata(type);
30
30
  assertDefined(metadata, `Type ${type.name} does not have reflection metadata.`);
31
31
  const tableReflectionDatas = [];
@@ -36,7 +36,7 @@ export function _getDrizzleTableFromType(type, schemaName) {
36
36
  }
37
37
  }
38
38
  const tableReflectionData = tableReflectionDatas[0];
39
- const schema = assertDefinedPass(schemaName ?? tableReflectionData?.schema, 'Table schema not provided');
39
+ const schema = assertDefinedPass(tableReflectionData?.schema ?? fallbackSchemaName, 'Table schema not provided');
40
40
  const tableName = tableReflectionData?.name ?? getDefaultTableName(type);
41
41
  const dbSchema = getDbSchema(schema);
42
42
  const columnDefinitions = getPostgresColumnEntries(type, dbSchema, tableName);
@@ -168,7 +168,7 @@ function getPostgresColumn(tableName, columnName, dbSchema, propertySchema, refl
168
168
  column = column.primaryKey();
169
169
  }
170
170
  if (isDefined(reflectionData.references)) {
171
- column = column.references(() => getDrizzleTableFromType(reflectionData.references()).id);
171
+ column = column.references(() => getDrizzleTableFromType(reflectionData.references(), dbSchema.schemaName).id);
172
172
  }
173
173
  return column;
174
174
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tstdl/base",
3
- "version": "0.92.94",
3
+ "version": "0.92.95",
4
4
  "author": "Patrick Hein",
5
5
  "publishConfig": {
6
6
  "access": "public"