Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion typings/objection/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1442,7 +1442,7 @@ declare namespace Objection {
QueryBuilder: typeof QueryBuilder;

tableName: string;
idColumn: string | string[];
idColumn: null | string | string[];
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should probably be last, not first? Also, it was suggested here to use never instead of null? What's more suitable?

#2693 (comment)

Copy link
Copy Markdown

@salisbury-espinosa salisbury-espinosa May 27, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@geeksilva97 @lehni
null - is not safe from the point of view of logic and types!
if you do not explicitly specify returning (for example returning(*)) then this will implicitly lead to the fact that it will try to use null (since the method will return null) and this will lead to an error at runtime!
see #2693 (comment)
that is, objection will compile an invalid SQL query!
therefore never is necessary - so that at the compilation stage (on the js side) there is an error, and an invalid SQL query does not sent to the database side!

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what does 'returning(*)' mean?

Copy link
Copy Markdown
Author

@geeksilva97 geeksilva97 May 27, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't get this never thing when the doc explicitly says to use null

image

Maybe docs should be changed as well

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should probably be last, not first? Also, it was suggested here to use never instead of null? What's more suitable?

#2693 (comment)

I don't think the order matters. Just let me know if you want me to change it

Copy link
Copy Markdown

@salisbury-espinosa salisbury-espinosa May 27, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

jsonSchema: JSONSchema;
relationMappings: RelationMappings | RelationMappingsThunk;
modelPaths: string[];
Expand Down