Hello people, I have a question about SqlDelight (...
# squarelibraries
d
Hello people, I have a question about SqlDelight (2.0 alpha). I have
Movie
and
TvShow
tables, I wanna query them together, so I'm planning to create a
View
and map it to a sealed class in my data layer. Before procede, I wanna make sure there isn't any native support to sealed classes in SqlDelight, in order to avoid to reinvent the wheel. 🙏
a
no nothing will generated sealed classes for you
d
Thanks for confirming 🍻
h
Curios why do want to use a sealed class?
d
Movie
and
TvShow
have many common fields, but some unique ones, so I can have a list of items with
title, genres, poster
(parent) and have a detailed screen with unique fields, like
seasons
for
TvShow
or
releaseDate
for
Movie
h
Got it, okay creating some automapping sounds like an erroneous idea because it extremely depends on your internal data structure and its meaning. The generated classes don't contain data/values only but logic/meaning now, which is absolutely fine in OOP but hard to create with a generator without any information resulting in strange edge cases. I do use sealed classes too in some projects but you have to do the mapping by yourself.
d
Yes I agree, but since all the magic that SqlDelight does, better to make sure 😄