https://kotlinlang.org logo
a

Allan Wang

11/10/2018, 6:15 AM
Is there a short form for insert and get? Where I want to get not just a column but the entire row
t

tapac

11/10/2018, 9:27 AM
Entire row of what? Most of the time insert returns only autoGenerated keys + default values generated by Exposed.
a

Allan Wang

11/10/2018, 4:18 PM
I would like the outcome of I were to query again using the generated ID. For example, if I have a table with an auto generated id, name, and date of création, I'd like to insert a new entry with just the name and be able to get the entire model of id name and date back as they are auto generated. Is the only solution that I should be creating the values myself before inserting, if I don't want to do an insert and get and deal with potential failures?
t

tapac

12/23/2018, 12:04 PM
@Allan Wang, there two possible way to declare default column values: clientDefault - when value generated from code, dbDefault - value will be created on db side. If you use clientDefault then it’s possible to achieve values just after insert otherwise you should make additional select by id as not every DB has option to return values.
a

Allan Wang

12/23/2018, 8:18 PM
My original question was just if there was an insertAndGet method that returns more than the id. Currently I'm using clientDefault and I'm inserting and then calling get as two separate calls.