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

the exec order of korma update set-fields #364

Open
EasonYan opened this issue Aug 31, 2016 · 5 comments
Open

the exec order of korma update set-fields #364

EasonYan opened this issue Aug 31, 2016 · 5 comments
Labels
inactive-issue? This issue should be closed within 2 weeks of the most recent comment due to inactivity

Comments

@EasonYan
Copy link

(def my-map
{:a 1
:b 2}
(->(update* table)
(set-field my-map)
(exec)
)
it seems that korma will always exec in an order like this "set a=1 and b=2",because letter a is always ahead of letter b。
my question is that are there any methods that can make korma exec like this "set b=2 and a=1"。because the set sequence make different in mysql.Thanks a lot!

@immoh
Copy link
Member

immoh commented Sep 2, 2016

I'm afraid it is not possible to control the order of columns to update. The reason why columns are ordered is to generate consistent SQL across different Clojure versions.

Can you elaborate on reasons why the order makes difference in MySQL?

@vladanghene
Copy link

hi, I'm finding myself exactly in this situation.
i want to batch update a unique key column by increments of 2, and korma renders the error duplicate entry. while standard sql allows me to order desc so statements can be executed, korma doesn't give me the chance of ordering by desc before executing.
is there any other way except falling back to raw ?

@immoh
Copy link
Member

immoh commented Oct 25, 2016

@avabinary This issue is about order of columns, I think you are talking about order of rows. It should be fairly straightforward to make update support order-by, pull request welcome :)

@venantius
Copy link
Contributor

@immoh would passing a sorted-map into set-field work?

I'm going through old issues and trying to clean them up. Has this issue persisted?

If there hasn't been a response to this issue in 2 weeks, I'll close the ticket.

@venantius venantius added the inactive-issue? This issue should be closed within 2 weeks of the most recent comment due to inactivity label Feb 27, 2018
@immoh
Copy link
Member

immoh commented Feb 28, 2018

@venantius I don't think it would. Korma is explicitly ordering column names so that generated SQL is same across Clojure versions.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
inactive-issue? This issue should be closed within 2 weeks of the most recent comment due to inactivity
Projects
None yet
Development

No branches or pull requests

4 participants