https://kotlinlang.org logo
#squarelibraries
Title
# squarelibraries
a

Andrew O Hart

04/12/2022, 10:52 AM
Is it possible to return a max value from a table in SQLDelight? I'm trying
Copy code
retrieveMostRecentLastModificationDate:
SELECT MAX(Information.lastModificationDate) FROM Information LIMIT 1;
And it is returning Query<RetrieveMostRecentLastModificationDate> I just need to return the most recent date from the table, so I would expect it to return as an Int or a Long as we are storing it using toEpochMilliseconds
e

eygraber

04/12/2022, 11:47 AM
What happens if you remove the
LIMIT 1
(
max
should only ever return one value)?
a

Andrew O Hart

04/12/2022, 12:11 PM
It shows this:
Not sure on why its trying to return the SQL Query name
a

alec

04/12/2022, 1:38 PM
its just a wrapper, it probably holds the value you want
it has to be wrapped i assume because your last modification date is nullable
a

Andrew O Hart

04/12/2022, 4:52 PM
yeah calling .MAX on it returns it. That explains it more, thanks Alec