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
package/dist/migrations/index.js
CHANGED
|
@@ -1299,10 +1299,12 @@ const collectCodeFkeys = (config, { codeTable, changeTableAst: { shape } }, curr
|
|
|
1299
1299
|
};
|
|
1300
1300
|
const fnOrTableToString = (fnOrTable) => {
|
|
1301
1301
|
if (typeof fnOrTable !== "string") {
|
|
1302
|
-
const { schema, table } = new (fnOrTable())();
|
|
1302
|
+
const { schema, table, nameInDb } = new (fnOrTable())();
|
|
1303
|
+
const name = nameInDb || table;
|
|
1304
|
+
if (!name) throw new Error("Referenced table is missing table property");
|
|
1303
1305
|
fnOrTable = (0, rake_db.concatSchemaAndName)({
|
|
1304
1306
|
schema,
|
|
1305
|
-
name
|
|
1307
|
+
name
|
|
1306
1308
|
});
|
|
1307
1309
|
}
|
|
1308
1310
|
return fnOrTable;
|
|
@@ -3354,15 +3356,16 @@ const getActualItems = async (db, currentSchema, internal, columnTypes) => {
|
|
|
3354
3356
|
const table = db[key];
|
|
3355
3357
|
if (!table.table) throw new Error(`Table ${key} is missing table property`);
|
|
3356
3358
|
const schema = (0, pqb_internal.getQuerySchema)(table);
|
|
3359
|
+
const tableName = getQueryNameInDb(table);
|
|
3357
3360
|
const name = (0, rake_db.concatSchemaAndName)({
|
|
3358
3361
|
schema,
|
|
3359
|
-
name:
|
|
3362
|
+
name: tableName
|
|
3360
3363
|
});
|
|
3361
3364
|
if (tableNames.has(name)) throw new Error(`Table ${name} is defined more than once`);
|
|
3362
3365
|
tableNames.add(name);
|
|
3363
3366
|
if (schema) codeItems.schemas.add(schema);
|
|
3364
3367
|
codeItems.tables.push({
|
|
3365
|
-
table:
|
|
3368
|
+
table: tableName,
|
|
3366
3369
|
shape: table.shape,
|
|
3367
3370
|
internal: {
|
|
3368
3371
|
...table.internal,
|
|
@@ -3380,9 +3383,10 @@ const getActualItems = async (db, currentSchema, internal, columnTypes) => {
|
|
|
3380
3383
|
if (views) for (const key in views) {
|
|
3381
3384
|
const view = views[key];
|
|
3382
3385
|
const schema = (0, pqb_internal.getQuerySchema)(view);
|
|
3386
|
+
const viewName = getQueryNameInDb(view);
|
|
3383
3387
|
if (schema) codeItems.schemas.add(schema);
|
|
3384
3388
|
codeItems.views.push({
|
|
3385
|
-
name:
|
|
3389
|
+
name: viewName,
|
|
3386
3390
|
shape: view.shape,
|
|
3387
3391
|
internal: view.internal,
|
|
3388
3392
|
q: { schema },
|
|
@@ -3416,6 +3420,9 @@ const getActualItems = async (db, currentSchema, internal, columnTypes) => {
|
|
|
3416
3420
|
if (internal.grants) for (const grant of internal.grants) addGrantSchemas(codeItems.schemas, currentSchema, grant);
|
|
3417
3421
|
return codeItems;
|
|
3418
3422
|
};
|
|
3423
|
+
const getQueryNameInDb = (query) => {
|
|
3424
|
+
return query.q.nameInDb || query.table;
|
|
3425
|
+
};
|
|
3419
3426
|
const processCodeItemShape = (shape, currentSchema, codeItems, domains) => {
|
|
3420
3427
|
for (const key in shape) {
|
|
3421
3428
|
const column = shape[key];
|