-
-
Notifications
You must be signed in to change notification settings - Fork 2.2k
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
orm: add function call api #24196
base: master
Are you sure you want to change the base?
orm: add function call api #24196
Conversation
The code call qb.where('userid > ?', 123)!.query()! ... |
Looking forward to this merger. |
@medvednikov |
You're a machine! Great job :) |
@spytheman @felipensp what do you think? |
Nice work @kbkpbot! Looks a great addition. I just don't like mixing different statements via chaining calls. |
I want to know. Which of the PR grammar and the existing ORM grammar will be retained in the end?Give us directions for future use. |
Panics can not be intercepted by the callers, while returned errors can. |
The use cases are different - a static query, made with the ORM syntax, can be analyzed by the compiler, and you can get an error right away, if you mess up something. A dynamic query can not be analyzed statically, and so you will get an error at runtime, but only if you execute that piece of code, written using the query builder. If you look at it from that perspective, imho it is pretty clear what you should prefer. |
I think it is a very good compromise (except of using panics instead of returning errors, since while that may make the call sites a bit more verbose, because of the It gives an additional freedom and convenience, to people that want to construct dynamic queries at runtime, without having to drop to the underlying driver specific APIs. At the same time, it does it without having to modify the language itself, using an API that is more or less convenient, and checked by the compiler as much as possible, which is also nice. |
Ok, I think I know how to adjust my code after this pr merge |
I wonder can the error before : x := gb.where(...)!
.where(...)!
.where(...)!
.where(...)!
.where(...)!
.where(...)!
.query()! after: x := gb.where(...)
.where(...)
.where(...)
.where(...)
.where(...)
.where(...)
.query()! |
Feature Request #24178