Fork me on GitHub
#sql
<
2019-02-10
>
leontalbot14:02:06

Hi! I was wondering: say you want to make a single update! call, that can update more than one row (where clause matching many), how can I get back the rows that were updated? (db is postgresql)

leontalbot14:02:39

as I understand it, (update! db-spec :items {:checked true} ["color like '%black%'"]) => [17]

leontalbot14:02:06

adding {:return-keys true}, returns one row only

seancorfield18:02:25

@leontalbot figure out how to do it in SQL first. There's no magic in Java.jdbc -- it's just calling the Postgresql driver to do whatever you tell it.

👍 5
seancorfield18:02:38

That said, as noted before, I would not expect :return-keys to do anything sensible on an update (but under the hood all that does is ask the Postgresql driver to return any generated keys on the preparated statement).