Fork me on GitHub

@mattly: hello from the past, I think I remember you from such IRC channels as #ruby, #ror, or possibly #caboose


possibly all three!


Am I missing something obvious about getting the id of the last inserted record? I’m using Honeysql `(-> (h/insert-into :people) (h/columns :org-id :given-name :family-name :email) (h/values [[org-id given-name family-name email]]) (sql/format :quoting :mysql :allow-dashed-names? true))` with jdbc/execute! and just back a (1) . I can do a SELECT LAST_INSERT_ID() but I was under the impression I should get back a map of insert keys for a single insert. Have I gone wrong somewhere?


iirc you want to call db-do-prepared-return-keys and look for :GENERATED_KEY


it is mildly annoying


donaldball: i’ll take a look at that, thanks


i was surprised not to find a lot of queries about this via google, seems a common thing to want


I reckon most folk just use jdbc/insert! and call it a day


though I’m a fan of honeysql myself so prefer to use it exclusively when i use it


how does anyone live without honeysql


i mean, i’m used to ActiveRecord which - despite its many flaws - makes the common database stuff more or less trivial… the idea of going back to generating raw sql… brrrr


honeysql seems a pretty good middle ground


I would rather say that ActiveRecord trivializes interaction with the database, and I mean that in a bad way. A database abstraction that does not require you to think carefully about your transaction boundaries, locking and isolation level requirements is fundamentally unsound.


i wasn’t singing the praises of AR so much as musing on having to go back to generating raw SQL and wondering why people would forgo something like Honeysql


I hear that. I think some legitimately don’t need to compose queries at run-time, they can express everything in sql strings. Others I sense have been burned by cumbersome sql object hierarchies or dsls that purport to abstract the difficult bits of sql away but wind up being more trouble than they’re worth (e.g. hibernate’s query language, if that’s even a thing). I find honeysql to be a different beast entirely: it’s essentially just an AST for the most common 90% of sql.