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.
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: