Is it possible for SqlDelight to not create a new ...
# squarelibraries
e
Is it possible for SqlDelight to not create a new type for a query like this:
Copy code
query:
SELECT station.* FROM keyword LEFT JOIN station
ON keyword.station_id = station.id
I would like for it to just return the same type that the station table contains but it creates the exact duplicate under the name Query.
k
You aren’t required to use the generated type if you pass in a mapper when executing SQL in Kotlin https://cashapp.github.io/sqldelight/2.0.0/android_sqlite/custom_projections/
So if your case you’d do something like:
Copy code
stationQueries.query(
  mapper = ::Station
).executeAsList()
e
hmmm.. it fails to match it because some parameters in Query are nullable but in Station they are required
k
You could filter them as being non-null in SQL if that’s what you truly want.
Copy code
query:
SELECT station.* FROM keyword LEFT JOIN station
ON keyword.station_id = station.id
WHERE station.some_param IS NOT NULL;
e
I mean they are never null because the
CREATE TABLE
clause specifies it so I thought that the query should infer that
but I guess with join it cannot do that
k
I’m not sure if that’s a bug or not, though I would expect it is. Perhaps someone who maintains SQLDelight will chime in.
e
well the not null assertions fix the issue for now so thank for that 🙂
h
You can also use a view