We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
I may be misunderstanding the use of the * functions in korma.core, but I can't get where* to work with a map, as described in the API docs.
This works: (-> (select* users) (where* "username = 'tom'") select)
However, this doesn't: (-> (select* users) (where* {:username "tom"}) select)
The error message indicates that where* is inserting some intermediate form of the clause into the query, instead of rendering it as the SQL text:
Failure to execute query with SQL: SELECT "users".* FROM "users" WHERE {:korma.sql.utils/pred #<engine$do_group korma.sql.engine$do_group@3c200d0>, :korma.sql.utils/args [" AND " ({:korma.sql.utils/pred #<engine$do_infix korma.sql.engine$do_infix@e99fb6>, :korma.sql.utils/args [{:korma.sql.utils/generated ""users"."username""} "=" "tom"]})]} :: [] PSQLException: Message: ERROR: syntax error at or near "{" Position: 37 SQLState: 42601 Error Code: 0
The text was updated successfully, but these errors were encountered:
It looks like you can simply use where in this case:
where
(let [organization-id nil service "korma" query {:service service} query (if organization-id (assoc query :organization_id organization-id) query)] (-> (korm/select* db/oauth-tokens) (korm/where query) (korm/as-sql) println)) ;; SELECT "oauth_tokens".* FROM "oauth_tokens" WHERE ("oauth_tokens"."service" = ?) (let [organization-id 3 service "korma" query {:service service} query (if organization-id (assoc query :organization_id organization-id) query)] (-> (korm/select* db/oauth-tokens) (korm/where query) (korm/as-sql) println)) ;; SELECT "oauth_tokens".* FROM "oauth_tokens" WHERE ("oauth_tokens"."organization_id" = ? AND "oauth_tokens"."service" = ?)
Sorry, something went wrong.
No branches or pull requests
I may be misunderstanding the use of the * functions in korma.core, but I can't get where* to work with a map, as described in the API docs.
This works:
(-> (select* users)
(where* "username = 'tom'")
select)
However, this doesn't:
(-> (select* users)
(where* {:username "tom"})
select)
The error message indicates that where* is inserting some intermediate form of the clause into the query, instead of rendering it as the SQL text:
Failure to execute query with SQL:
SELECT "users".* FROM "users" WHERE {:korma.sql.utils/pred #<engine$do_group korma.sql.engine$do_group@3c200d0>, :korma.sql.utils/args [" AND " ({:korma.sql.utils/pred #<engine$do_infix korma.sql.engine$do_infix@e99fb6>, :korma.sql.utils/args [{:korma.sql.utils/generated ""users"."username""} "=" "tom"]})]} :: []
PSQLException:
Message: ERROR: syntax error at or near "{"
Position: 37
SQLState: 42601
Error Code: 0
The text was updated successfully, but these errors were encountered: