-
-
Notifications
You must be signed in to change notification settings - Fork 175
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
Syntax for expanding records in PostgreSQL #474
Comments
Something like this (name TBD): user=> (sql/register-fn! :project (fn [_ [expr col]] (let [[sql & params] (sql/format-expr expr)] (into [(str "(" sql ")." (sql/format-entity col))] params))))
...
user=> (sql/format {:select [[[:project :v :*]]]})
["SELECT (v).*"]
user=> (sql/format {:select [[[:project :v :*]]]} {:quoted true})
["SELECT (\"v\").*"]
user=> (sql/format {:select [[[:project :v :a]]]} {:quoted true})
["SELECT (\"v\").\"a\""]
user=> |
It turns out being able to dot-select from dynamic table or column names is useful so it makes more sense to split this in two:
|
This has been pushed to develop for testing. Documentation still to do, including a migration note about |
Currently, dot takes precisely two arguments: an expression and a column. |
Personally, I have never seen any need to support an arbitrary amount of arguments. My own version of But it might be useful for people that often use |
OK, I'll expand this to accept up to three arguments. And then document it. |
In a query like
you have to use
(v).*
because justv
would return a record andv.*
would lead to an error.Currently, the way to do it is to use
[:raw ["(" (sql/format-entity :v) ").*"]]
.The text was updated successfully, but these errors were encountered: