Description and expected behavior
When trying to filter by a field that comes from a relations base model using polymorphism, zenstack fails with error: missing FROM-clause entry for table "Resource"
Code
model Location {
id String @id
// ...
}
enum ResourceType {
DESK
}
model Resource {
// ...
name String
type ResourceType
locationId String
location Location @relation(fields: [locationId], references: [id], onDelete: Cascade)
@@delegate(type)
}
model ResourceDesk extends Resource {
employeeDeskSessions EmployeeDeskSession[]
@@delegateMap(DESK)
}
model EmployeeDeskSession {
// ...
deskId String
desk ResourceDesk @relation(fields: [deskId], references: [id], onDelete: Cascade)
}
const deskSessions = await this.dbService.employeeDeskSession.findMany({
where: {
desk: {
locationId,
},
},
});
Full log:
[error] error: missing FROM-clause entry for table "Resource"
at ./node_modules/pg/lib/client.js:646:17
at process.processTicksAndRejections (node:internal/process/task_queues:103:5)
at async PostgresConnection.executeQuery (file://./node_modules/kysely/dist/dialect/postgres/postgres-driver.js:113:28)
at async PostgresConnection.connection.executeQuery (./node_modules/@zenstackhq/orm/src/client/executor/zenstack-driver.ts:140:24)
at async ZenStackQueryExecutor.internalExecuteQuery (./node_modules/@zenstackhq/orm/src/client/executor/zenstack-query-executor.ts:696:28)
at async ZenStackQueryExecutor.proceedQueryWithKyselyInterceptors (./node_modules/@zenstackhq/orm/src/client/executor/zenstack-query-executor.ts:222:24)
at async <anonymous> (./node_modules/@zenstackhq/orm/src/client/executor/zenstack-query-executor.ts:161:32)
at async DefaultConnectionProvider.provideConnection (file://./node_modules/kysely/dist/driver/default-connection-provider.js:10:20)
at async ZenStackQueryExecutor.executeQuery (./node_modules/@zenstackhq/orm/src/client/executor/zenstack-query-executor.ts:147:24)
at async FindOperationHandler.read (./node_modules/@zenstackhq/orm/src/client/crud/operations/base.ts:313:23)
at PostgresConnection.executeQuery (file://./node_modules/kysely/dist/dialect/postgres/postgres-driver.js:126:41)
at process.processTicksAndRejections (node:internal/process/task_queues:103:5)
at async PostgresConnection.connection.executeQuery (./node_modules/@zenstackhq/orm/src/client/executor/zenstack-driver.ts:140:24)
at async ZenStackQueryExecutor.internalExecuteQuery (./node_modules/@zenstackhq/orm/src/client/executor/zenstack-query-executor.ts:696:28)
at async ZenStackQueryExecutor.proceedQueryWithKyselyInterceptors (./node_modules/@zenstackhq/orm/src/client/executor/zenstack-query-executor.ts:222:24)
at async <anonymous> (./node_modules/@zenstackhq/orm/src/client/executor/zenstack-query-executor.ts:161:32)
at async DefaultConnectionProvider.provideConnection (file://./node_modules/kysely/dist/driver/default-connection-provider.js:10:20)
at async ZenStackQueryExecutor.executeQuery (./node_modules/@zenstackhq/orm/src/client/executor/zenstack-query-executor.ts:147:24)
at async FindOperationHandler.read (./node_modules/@zenstackhq/orm/src/client/crud/operations/base.ts:313:23)
at async FindOperationHandler.handle (./node_modules/@zenstackhq/orm/src/client/crud/operations/find.ts:27:24) {
length: 120,
severity: 'ERROR',
code: '42P01',
detail: undefined,
hint: undefined,
position: '495',
internalPosition: undefined,
internalQuery: undefined,
where: undefined,
schema: undefined,
table: undefined,
column: undefined,
dataType: undefined,
constraint: undefined,
file: 'parse_relation.c',
line: '3655',
routine: 'errorMissingRTE'
}
Screenshots
/
Environment (please complete the following information):
- ZenStack version: 3.8.3
- Database type: Postgresql
- Node.js/Bun version: 24.13.1
- Package manager: npm
Additional context
Add any other context about the problem here.
Description and expected behavior
When trying to filter by a field that comes from a relations base model using polymorphism, zenstack fails with
error: missing FROM-clause entry for table "Resource"Code
Full log:
Screenshots
/
Environment (please complete the following information):
Additional context
Add any other context about the problem here.