I want to add a custom field when doing a complex join with a value Basically something like this:
SELECT p.first_name, "Smith" AS "last_name"
FROM person p
WHERE first_name = "John"
In kotlin that would be something like this:
PersonTable
.slice(PersonTable.first_name, "" HERE IS WHERE I’D LIKE TO PUT SOMETHING "")
.select(PersonTable.first_name eq "John")
The field "last_name" doesn't exist in any table in this example. I want to add it to the ResultRow.
My real query is much more complex but I can't share it publically. Basically what I want is to add the last_name column to every ResultRow I would get out of the query with the value "Smith". And then a way to access that column later.
Can this be done in JetBrains Exposed?
This is what I have tried unsuccessfully:
PersonTable
.slice(PersonTable.first_name, stringLiteral("Smith").alias("last_name"))
.select(PersonTable.first_name eq "John")
The above doesn't work the way I want it to. It does add a column that has the value "Smith" but the column name/alias is 'Smith'last_name instead of just last_name. The reason why this doesn't work is that I will be doing a union with another select that will have a different value for last_name and therefore I need the column name to be the same in both those selects.