-
Notifications
You must be signed in to change notification settings - Fork 640
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Incorrect typing of idColumn
#2693
Comments
Thanks for pointing this out @jackbonaguro. I'm happy to accept a PR that fixes this. |
maybe it's better not to null, but never? static get idColumn(): never {
throw new Error(`undefined idColumn`);
} after all, if there is no idColumn, then there should be no access to it at all and this should generate an error at runtime related issue #2745 by the way, failed behavior: https://github.com/Vincit/objection.js/blob/main/lib/queryBuilder/operations/InsertOperation.js#L42 if (!isSqlite(builder.knex()) && !isMySql(builder.knex()) && !builder.has(/returning/)) {
// If the user hasn't specified a `returning` clause, we make sure
// that at least the identifier is returned.
knexBuilder = knexBuilder.returning(builder.modelClass().getIdColumn());
} if you don't specify returning in the query, then idColumn will be substituted ( => |
According to documentation, idColumn should be set to null in the event a table does not have an id column: https://vincit.github.io/objection.js/api/model/static-properties.html#static-idcolumn
But due to the typings, null is not a possible valid value for
idColumn
- onlystring | string[]
:objection.js/typings/objection/index.d.ts
Line 1541 in d1e194a
This causes an issue in my code on version 3.1.4. Doing either:
or
Results in a compiler error:
The text was updated successfully, but these errors were encountered: