drift icon indicating copy to clipboard operation
drift copied to clipboard

[Suggestion - .drift files] Extend base data class when only 1 table.*

Open North101 opened this issue 3 years ago • 2 comments

I have a a lot of tables where I have queries like:

SELECT
  table1.**,
  table2.**,
  table3.**

but what I'd really like to do is have:

SELECT
  table1.*,
  table2.**,
  table3.**

and be able to pass the class around as if it was just table1

North101 avatar Feb 27 '22 16:02 North101

I see the advantage of this, and we can do this without a breaking change which is nice, but I'm a bit unsure about what it means to "extend" a dataclass. In particular, how should inserts / updates with this result set behave? Do we just throw the other columns away or do we just forbid calling toColumns/toCompanion on these classes? Either approach sounds somewhat reasonable which is a sign I didn't think this through enough :sweat_smile:

Is this just about avoiding the .table1 call somewhere or is there something that I'm missing?

simolus3 avatar Feb 28 '22 21:02 simolus3

Yea it's basically to avoid doing things like settingResult.settings.whatever it's something I can live with but it'd just be nice not to.

Id lean towards throwing the other columns away on insert.

North101 avatar Feb 28 '22 21:02 North101