Entities represent the actual tables/views being selected.
An Opinion represents a piece of data that needs to be propagated through AST transformations but is not directly related to how ASTs are transformed in most stages.
An Opinion represents a piece of data that needs to be propagated through AST transformations but is not directly
related to how ASTs are transformed in most stages. For instance, Renameable
controls how columns are named (i.e. whether to use a
NamingStrategy
or not) after most of the SQL transformations are done. Some transformations (e.g. RenameProperties
will use Opinions
or even modify them so that the correct kind of query comes out at the end of the normalizations.
That said, Opinions should be transparent in most steps of the normalization. In some cases e.g. BetaReduction
,
AST elements need to be neutralized (i.e. set back to defaults in the entire tree) so that this works correctly.
Properties generally represent column selection from a table or invocation of some kind of method from some other object.
Properties generally represent column selection from a table or invocation of some kind of method from some other object. Typically, something like
`SELECT p.name FROM People p`comes from something like
`Map(Entity("People"), Ident("p"), Property(Ident(p), "name"))`Properties also have an Opinion about how the
NamingStrategy
affects their name. For example something like
Property.Opinionated(Ident(p), "s_name", Fixed)
will become p.s_name
even if the NamingStrategy
is UpperCase
(whereas Property(Ident(p), "s_name")
would become p.S_NAME
). When Property is constructed without Opinionated
being used, the default opinion ByStrategy
is used.SELECT p.name FROM People p
something like
`Map(Entity("People"), Ident("p"), Property(Ident(p), "name"))`Properties also have an Opinion about how the `NamingStrategy` affects their name. For example something like `Property.Opinionated(Ident(p), "s_name", Fixed)` will become `p.s_name` even if the `NamingStrategy` is `UpperCase` (whereas `Property(Ident(p), "s_name")` would become `p.S_NAME`). When Property is constructed without `Opinionated` being used, the default opinion `ByStrategy` is used.
Ident represents a single variable name, this typically refers to a table but not always.
Ident represents a single variable name, this typically refers to a table but not always. Invisible identities are a rare case where a user returns an embedded table from a map clause:
case class Emb(id: Int, name: String) extends Embedded
case class Parent(id: Int, name: String, emb: Emb) extends Embedded
case class GrandParent(id: Int, par: Parent)
query[GrandParent]
.map(g => g.par).distinct
.map(p => (p.name, p.emb)).distinct
.map(tup => (tup._1, tup._2)).distinct
}
In these situations, the identity whose properties need to be expanded in the ExpandNestedQueries phase, needs to be marked invisible.
Entities represent the actual tables/views being selected. Typically, something like:
comes from something like: When you define aquerySchema
, the fields you mention inside becomePropertyAlias
s. For example something like: Becomes something like: Note that Entity has an Opinion calledrenameable
which will be the valueFixed
when aquerySchema
is specified. That means that even if theNamingSchema
isUpperCase
, the resulting query will selectt_person
as opposed toT_PERSON
orPerson
.
When you define a `querySchema`, the fields you mention inside become `PropertyAlias`s. For example something like: Becomes something like: Note that Entity has an Opinion called `renameable` which will be the value `Fixed` when a `querySchema` is specified. That means that even if the `NamingSchema` is `UpperCase`, the resulting query will select `t_person` as opposed to `T_PERSON` or `Person`.SELECT p.name FROM People p
something like: