orchid-orm 1.75.0 → 1.76.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 +55 -36
- package/dist/index.js +17 -5
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +17 -5
- package/dist/index.mjs.map +1 -1
- package/dist/migrations/index.js +12 -5
- package/dist/migrations/index.js.map +1 -1
- package/dist/migrations/index.mjs +12 -5
- package/dist/migrations/index.mjs.map +1 -1
- package/package.json +5 -5
|
@@ -1276,10 +1276,12 @@ const collectCodeFkeys = (config, { codeTable, changeTableAst: { shape } }, curr
|
|
|
1276
1276
|
};
|
|
1277
1277
|
const fnOrTableToString = (fnOrTable) => {
|
|
1278
1278
|
if (typeof fnOrTable !== "string") {
|
|
1279
|
-
const { schema, table } = new (fnOrTable())();
|
|
1279
|
+
const { schema, table, nameInDb } = new (fnOrTable())();
|
|
1280
|
+
const name = nameInDb || table;
|
|
1281
|
+
if (!name) throw new Error("Referenced table is missing table property");
|
|
1280
1282
|
fnOrTable = concatSchemaAndName({
|
|
1281
1283
|
schema,
|
|
1282
|
-
name
|
|
1284
|
+
name
|
|
1283
1285
|
});
|
|
1284
1286
|
}
|
|
1285
1287
|
return fnOrTable;
|
|
@@ -3331,15 +3333,16 @@ const getActualItems = async (db, currentSchema, internal, columnTypes) => {
|
|
|
3331
3333
|
const table = db[key];
|
|
3332
3334
|
if (!table.table) throw new Error(`Table ${key} is missing table property`);
|
|
3333
3335
|
const schema = getQuerySchema(table);
|
|
3336
|
+
const tableName = getQueryNameInDb(table);
|
|
3334
3337
|
const name = concatSchemaAndName({
|
|
3335
3338
|
schema,
|
|
3336
|
-
name:
|
|
3339
|
+
name: tableName
|
|
3337
3340
|
});
|
|
3338
3341
|
if (tableNames.has(name)) throw new Error(`Table ${name} is defined more than once`);
|
|
3339
3342
|
tableNames.add(name);
|
|
3340
3343
|
if (schema) codeItems.schemas.add(schema);
|
|
3341
3344
|
codeItems.tables.push({
|
|
3342
|
-
table:
|
|
3345
|
+
table: tableName,
|
|
3343
3346
|
shape: table.shape,
|
|
3344
3347
|
internal: {
|
|
3345
3348
|
...table.internal,
|
|
@@ -3357,9 +3360,10 @@ const getActualItems = async (db, currentSchema, internal, columnTypes) => {
|
|
|
3357
3360
|
if (views) for (const key in views) {
|
|
3358
3361
|
const view = views[key];
|
|
3359
3362
|
const schema = getQuerySchema(view);
|
|
3363
|
+
const viewName = getQueryNameInDb(view);
|
|
3360
3364
|
if (schema) codeItems.schemas.add(schema);
|
|
3361
3365
|
codeItems.views.push({
|
|
3362
|
-
name:
|
|
3366
|
+
name: viewName,
|
|
3363
3367
|
shape: view.shape,
|
|
3364
3368
|
internal: view.internal,
|
|
3365
3369
|
q: { schema },
|
|
@@ -3393,6 +3397,9 @@ const getActualItems = async (db, currentSchema, internal, columnTypes) => {
|
|
|
3393
3397
|
if (internal.grants) for (const grant of internal.grants) addGrantSchemas(codeItems.schemas, currentSchema, grant);
|
|
3394
3398
|
return codeItems;
|
|
3395
3399
|
};
|
|
3400
|
+
const getQueryNameInDb = (query) => {
|
|
3401
|
+
return query.q.nameInDb || query.table;
|
|
3402
|
+
};
|
|
3396
3403
|
const processCodeItemShape = (shape, currentSchema, codeItems, domains) => {
|
|
3397
3404
|
for (const key in shape) {
|
|
3398
3405
|
const column = shape[key];
|