Skip to content
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

Column is not quote escaped. #232

Closed
changsu-farmmorning opened this issue Nov 4, 2022 · 1 comment · Fixed by #233
Closed

Column is not quote escaped. #232

changsu-farmmorning opened this issue Nov 4, 2022 · 1 comment · Fixed by #233
Assignees
Labels
bug Something isn't working

Comments

@changsu-farmmorning
Copy link

changsu-farmmorning commented Nov 4, 2022

Describe the bug
In for-insert-multi function, the column is not quote escaped.
https://github.com/seancorfield/next-jdbc/blob/develop/src/next/jdbc/sql/builder.clj#L155

Other function, for example for-insert, table name and column name are both covered by safe-name function.

To Reproduce
Steps to reproduce the behavior (preferably code -- or link to a GitHub repo containing a small, self-contained repro example):

if you call this function, you will see sql error because "order" and "usage" are reserved word in mysql query.
(insert-multi! your-datasource your-table [:order :usage] (->> [[1 "u1"] [2 "u3"]] (map seq)))

Expected behavior
A clear and concise description of what you expected to happen.
I think the column name will be quote escape.

As-is
params (str/join ", " (map (comp column-fn name) cols))
To-be (two choice)
params (str/join ", " (map (comp column-fn safe-name name) cols))
params (str/join ", " (map (comp safe-name column-fn name) cols))

스크린샷 2022-11-04 오전 10 24 57

스크린샷 2022-11-04 오전 10 25 10

스크린샷 2022-11-04 오전 10 25 33

Thank you!

@seancorfield
Copy link
Owner

Thank you -- good catch!

@seancorfield seancorfield self-assigned this Nov 4, 2022
@seancorfield seancorfield added the bug Something isn't working label Nov 4, 2022
seancorfield added a commit that referenced this issue Nov 5, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants