Closed KuceraMartin closed 1 year ago
search for "recursive" in the macro doc
another solution might be that the querybuilder generates implicit "capabilties" to join with other tables, which provide extension methods that do the joins? update: the problem here is that these extension methods would have to be generated since their names are derived from the schema definition
Nicolas was worried that there might be some problems with recursive schema definitions but that seems to be okay (see https://github.com/mbovel/scala-sql/blob/main/examples/13-relation.sc)
edit: referencing objects works, but for properties it's a bit more tricky: recursive references seem to work when you declare the types, but in reality you end up with nulls!
For generating files, we could take inspiration from Slick: https://scala-slick.org/doc/3.4.0-M1/code-generation.html which uses sbt: https://www.scala-sbt.org/1.x/docs/Howto-Generating-Files.html
Maybe we could make some sbt plugin to reduce the build.sbt
boilerplate for the users?
add one paragraph about code generation: should it always be done through macros? and if not, then how?
Nicolas suggested something similar to Alex:
class PersonScope:
def home[T](using x: F[T])(using T =:= House): x.type
where x
would be given by House
automatically using derives (TODO: try to understand this)
Guillaume suggested generating code and giving back to user through error messages -> IDE would display these and the could could be emplaced by one click.
from discussion with Viktor: could we somehow use this?
class MyList:
val value: Any = ???
val next: this.type = ???
type IntList = MyList { val value: Int }
(??? : IntList).next.next.value : Int
solutions:
HasOne extends Expression[PrimaryKeyType]
HasMany extends Expression[List[PrimaryKeyType]]
if we want to actually get data from the joined table (other than keys) => callfrom(relationship)
from(Artists).filter(from(_.releases).exists(_.genre === "Rock"))