slick.compiler
Slick AST to database query compiler
Attributes
Members list
Type members
Classlikes
Ensure that all symbol definitions in a tree are unique. The same symbol can initially occur in multiple sub-trees when some part of a query is reused multiple times. This phase assigns new, uniqe symbols, so that later phases do not have to take scopes into account for identifying the source of a symbol. The rewriting is performed for both, term symbols and type symbols.
Ensure that all symbol definitions in a tree are unique. The same symbol can initially occur in multiple sub-trees when some part of a query is reused multiple times. This phase assigns new, uniqe symbols, so that later phases do not have to take scopes into account for identifying the source of a symbol. The rewriting is performed for both, term symbols and type symbols.
The phase state is a collection of flags depending on the presence or absence of certain node types in the AST. This information can be used to selectively skip later compiler phases when it is already known that there is nothing for them to translate.
Attributes
- Source:
- AssignUniqueSymbols.scala
- Graph
- Supertypes
A standard skeleton for a code generator phase.
A standard skeleton for a code generator phase.
Attributes
- Companion:
- object
- Source:
- CodeGen.scala
- Graph
- Supertypes
- Known subtypes
Attributes
- Companion:
- class
- Source:
- CodeGen.scala
- Graph
- Supertypes
- class Objecttrait Matchableclass Any
- Self type
- CodeGen.type
The current state of a compiler run, consisting of the current AST and additional immutable state of individual phases. Mutability is confined to the SymbolNamer. The state is tied to a specific compiler instance so that phases can call back into the compiler.
The current state of a compiler run, consisting of the current AST and additional immutable state of individual phases. Mutability is confined to the SymbolNamer. The state is tied to a specific compiler instance so that phases can call back into the compiler.
Attributes
- Source:
- QueryCompiler.scala
- Graph
- Supertypes
- class Objecttrait Matchableclass Any
Rewrite aggregation function calls to Aggregate nodes.
Rewrite aggregation function calls to Aggregate nodes.
Attributes
- Source:
- CreateAggregates.scala
- Graph
- Supertypes
Create a ResultSetMapping root node, ensure that the top-level server-side node returns a
collection, and hoist client-side type conversions into the ResultSetMapping. The original
result type (which was removed by removeMappedTypes) is assigned back to the top level.
Create a ResultSetMapping root node, ensure that the top-level server-side node returns a
collection, and hoist client-side type conversions into the ResultSetMapping. The original
result type (which was removed by removeMappedTypes) is assigned back to the top level.
Attributes
- Source:
- CreateResultSetMapping.scala
- Graph
- Supertypes
An optional phase which rewrites outer joins into more commonly supported operations for use on databases that lack outer join support.
An optional phase which rewrites outer joins into more commonly supported operations for use on databases that lack outer join support.
Full outer joins are always emulated. Right joins can be replaced by left joins (or an emulated version thereof). Left joins can be emulated with inner joins and unions.
Attributes
- Source:
- EmulateOuterJoins.scala
- Graph
- Supertypes
Expand paths of record types to reference all fields individually and recreate the record structure at the call site.
Expand paths of record types to reference all fields individually and recreate the record structure at the call site.
Attributes
- Source:
- ExpandRecords.scala
- Graph
- Supertypes
Expand sum types and their catamorphisms to equivalent product type operations.
Expand sum types and their catamorphisms to equivalent product type operations.
Attributes
- Source:
- ExpandSums.scala
- Graph
- Supertypes
Expand table-valued expressions in the result type to their star projection and compute the missing structural expansions of table types. After this phase the AST should always be well-typed.
Expand table-valued expressions in the result type to their star projection and compute the missing structural expansions of table types. After this phase the AST should always be well-typed.
Attributes
- Source:
- ExpandTables.scala
- Graph
- Supertypes
Inject the proper orderings into the RowNumber nodes produced earlier by the resolveFixJoins phase.
Inject the proper orderings into the RowNumber nodes produced earlier by the resolveFixJoins phase.
Attributes
- Source:
- FixRowNumberOrdering.scala
- Graph
- Supertypes
Flatten all Pure node contents into a single StructNode.
Flatten all Pure node contents into a single StructNode.
After this phase, all Pure nodes produce a StructNode of primitive fields. As a
side-effect, nested NominalTypes are eliminated.
Attributes
- Source:
- FlattenProjections.scala
- Graph
- Supertypes
Ensure that all collection operations are wrapped in a Bind so that we have a place for expanding references later. FilteredQueries are allowed on top of collection operations without a Bind in between, unless that operation is a Join, Pure or Distinct node.
Ensure that all collection operations are wrapped in a Bind so that we have a place for expanding references later. FilteredQueries are allowed on top of collection operations without a Bind in between, unless that operation is a Join, Pure or Distinct node.
Attributes
- Source:
- ForceOuterBinds.scala
- Graph
- Supertypes
Lift applicable operations at the top level to the client side.
Lift applicable operations at the top level to the client side.
Attributes
- Source:
- HoistClientOps.scala
- Graph
- Supertypes
Infer all missing types.
A custom compiler for INSERT statements. We could reuse the standard phases with a minor modification instead, but this is much faster.
A custom compiler for INSERT statements. We could reuse the standard phases with a minor modification instead, but this is much faster.
Attributes
- Companion:
- object
- Source:
- InsertCompiler.scala
- Graph
- Supertypes
Attributes
- Companion:
- class
- Source:
- InsertCompiler.scala
- Graph
- Supertypes
- class Objecttrait Matchableclass Any
- Self type
- InsertCompiler.type
This phase merges nested nodes of types Bind, Filter, GroupBy, SortBy, Take, Drop, CollectionCast and Distinct to Comprehension nodes. Nodes can be merged if they occur in the following order:
This phase merges nested nodes of types Bind, Filter, GroupBy, SortBy, Take, Drop, CollectionCast and Distinct to Comprehension nodes. Nodes can be merged if they occur in the following order:
[Source] -> Filter (where) -> GroupBy -> SortBy / (Distinct | Filter (having)) -> Take / Drop
Aliasing Binds and CollectionCasts are allowed everywhere in the chain. Any out of order operation starts a new chain with a subquery as the source.
Attributes
- Source:
- MergeToComprehensions.scala
- Graph
- Supertypes
Optimize scalar expressions
A phase of the query compiler, identified by a unique name
A phase of the query compiler, identified by a unique name
Attributes
- Companion:
- object
- Source:
- QueryCompiler.scala
- Graph
- Supertypes
- Known subtypes
- class AssignUniqueSymbolsclass CodeGenclass JdbcCodeGenclass JdbcInsertCodeGenclass MemoryCodeGenclass MemoryInsertCodeGenclass CreateAggregatesclass CreateResultSetMappingclass EmulateOuterJoinsclass ExpandRecordsclass ExpandSumsclass ExpandTablesclass FixRowNumberOrderingclass FlattenProjectionsclass ForceOuterBindsclass HoistClientOpsclass InferTypesclass InsertCompilerclass MergeToComprehensionsclass OptimizeScalarclass PruneProjectionsclass RelabelUnionsclass RemoveFieldNamesclass RemoveMappedTypesclass RemoveTakeDropclass ReorderOperationsclass ResolveZipJoinsclass MySQLResolveZipJoinsclass RewriteBooleansclass RewriteDistinctclass RewriteJoinsclass SpecializeParametersclass UnrollTailBindsclass VerifySymbolsclass VerifyTypesclass RemoveSubqueryOrderingclass ProtectGroupByclass Distribute
The Phase companion objects contains ready-to-use Phase objects for
the standard phases of the query compiler
The Phase companion objects contains ready-to-use Phase objects for
the standard phases of the query compiler
Attributes
- Companion:
- trait
- Source:
- QueryCompiler.scala
- Graph
- Supertypes
- class Objecttrait Matchableclass Any
- Self type
- Phase.type
Remove unreferenced fields from StructNodes.
An immutable, stateless query compiler consisting of a series of phases
An immutable, stateless query compiler consisting of a series of phases
Attributes
- Companion:
- object
- Source:
- QueryCompiler.scala
- Graph
- Supertypes
Attributes
- Companion:
- class
- Source:
- QueryCompiler.scala
- Graph
- Supertypes
- class Objecttrait Matchableclass Any
- Self type
- QueryCompiler.type
Assign the AnonSymbols of fields from the left side of a Union to the right side. This ensures that both sides are protected when we prune unused references pointing to left-side Symbols.
Assign the AnonSymbols of fields from the left side of a Union to the right side. This ensures that both sides are protected when we prune unused references pointing to left-side Symbols.
Attributes
- Source:
- RelabelUnions.scala
- Graph
- Supertypes
Convert unreferenced StructNodes to single columns or ProductNodes (which is needed for aggregation functions and at the top level).
Convert unreferenced StructNodes to single columns or ProductNodes (which is needed for aggregation functions and at the top level).
Attributes
- Source:
- RemoveFieldNames.scala
- Graph
- Supertypes
Remove all mapped types from the tree and store the original top-level type as the phase state to be used later for building the ResultSetMapping.
Remove all mapped types from the tree and store the original top-level type as the phase state to be used later for building the ResultSetMapping.
Attributes
- Source:
- CreateResultSetMapping.scala
- Graph
- Supertypes
Replace all occurrences of Take and Drop with row number computations based on
zipWithIndex operations.
Replace all occurrences of Take and Drop with row number computations based on
zipWithIndex operations.
Attributes
- Source:
- RemoveTakeDrop.scala
- Graph
- Supertypes
Reorder certain stream operations for more efficient merging in mergeToComprehensions.
Reorder certain stream operations for more efficient merging in mergeToComprehensions.
Attributes
- Source:
- ReorderOperations.scala
- Graph
- Supertypes
Rewrite zip joins into a form suitable for SQL using inner joins and RowNumber columns.
Rewrite zip joins into a form suitable for SQL using inner joins and RowNumber columns.
We rely on having a Bind around every Join and both of its generators, which should have been
generated by Phase.forceOuterBinds. The inner Binds need to select Pure(StructNode(...))
which should be the outcome of Phase.flattenProjections.
Attributes
- rownumStyle
Whether to use
Subqueryboundaries suitable for Oracle-style ROWNUM semantics instead of standard ROW_NUMBER().- Source:
- ResolveZipJoins.scala
- Graph
- Supertypes
- Known subtypes
- class MySQLResolveZipJoins
For SQL back-ends which do not support real boolean types for fields and general expressions but which do have special boolean expressions and operators, this phase injects conversions between fake and real boolean values.
For SQL back-ends which do not support real boolean types for fields and general expressions but which do have special boolean expressions and operators, this phase injects conversions between fake and real boolean values.
The default for booleans in the AST is to use the fake type (mapped to a numeric type by the profile). There are specific places where a real boolean (that can be used in boolean expressions) is required or produced, so we inject a call to ToRealBoolean or ToFakeBoolean as needed.
Attributes
- Companion:
- object
- Source:
- RewriteBooleans.scala
- Graph
- Supertypes
Attributes
- Companion:
- class
- Source:
- RewriteBooleans.scala
- Graph
- Supertypes
- class Objecttrait Matchableclass Any
- Self type
- RewriteBooleans.type
Rewrite "distinct on" to "distinct" or "group by"
Rewrite "distinct on" to "distinct" or "group by"
Attributes
- Source:
- RewriteDistinct.scala
- Graph
- Supertypes
Rewrite monadic joins to applicative joins. After this phase all Bind nodes are of the
form Bind(_, _, Pure(_, _)) (i.e. flatMap has been reduced to map).
Rewrite monadic joins to applicative joins. After this phase all Bind nodes are of the
form Bind(_, _, Pure(_, _)) (i.e. flatMap has been reduced to map).
Attributes
- Source:
- RewriteJoins.scala
- Graph
- Supertypes
Specialize the AST for edge cases of query parameters. This is required for
compiling take(0) for some databases which do not allow LIMIT 0.
Specialize the AST for edge cases of query parameters. This is required for
compiling take(0) for some databases which do not allow LIMIT 0.
Attributes
- Source:
- SpecializeParameters.scala
- Graph
- Supertypes
Attributes
- Source:
- UnrollTailBinds.scala
- Graph
- Supertypes
Attributes
- Source:
- AssignUniqueSymbols.scala
- Graph
- Supertypes
- trait Serializabletrait Producttrait Equalsclass Objecttrait Matchableclass Any
Verify that all monadic joins have been transformed into applicative joins and that the resulting tree does not contain references to unreachable symbols.
Verify that all monadic joins have been transformed into applicative joins and that the resulting tree does not contain references to unreachable symbols.
Attributes
- Source:
- VerifySymbols.scala
- Graph
- Supertypes
Optional phase which verifies that retyping the tree does not change any types. Useful for debugging type-related problems with large trees.
Optional phase which verifies that retyping the tree does not change any types. Useful for debugging type-related problems with large trees.
Attributes
- Source:
- VerifyTypes.scala
- Graph
- Supertypes