package generator
- Alphabetic
- Public
- All
Type Members
-
trait
CamelCaseToSnakeCase extends NamingStrategy
This strategy will make your Scala names adhere to snake_case! In 95% of cases, you probably want to use SnakeCaseToCamelCase instead.
This strategy will make your Scala names adhere to snake_case! In 95% of cases, you probably want to use SnakeCaseToCamelCase instead. (That is, NamingStrategies are "reversed" in terms of intended usage compared to Quill.)
Example (sql name => scala name): someIdent => some_ident
-
trait
CompanionEmitter extends AnyRef
Handles the transformation of one table to a model's companion object.
- class DefaultCompanionEmitter extends CompanionEmitter
-
class
DefaultModelEmitter extends ModelEmitter
Generates a simple case class based on the configured naming strategy, selected property emitter and inheritance configurations.
-
class
DefaultPropertyEmitter extends PropertyEmitter
Emits a property based on the globally configured naming strategy and without locally modifying the raw type.
- abstract class DefaultSchemaEmitter extends SchemaEmitter
- class DefaultTypeEmitter extends TypeEmitter
- sealed trait Import extends AnyRef
-
class
ImportSimplifyingTypeEmitter extends DefaultTypeEmitter
Simplifies the names of all imported types and packages.
Simplifies the names of all imported types and packages.
Simplifies "java.lang._", "scala._" and "scala.Predef._" by default, since Scala imports these namespaces by default.
-
case class
Inheritances(map: Map[String, Seq[TypeReference]]) extends Product with Serializable
Inheritances holds all inheritance declarations (extends, with) for the whole schema.
Inheritances holds all inheritance declarations (extends, with) for the whole schema. Please take care to only provide one proper class to extend (although failing to adhere to this will only result in generated code that does not compile).
Note that the inheritance map should use Scala names. Although Scala names depend on the NamingStrategy, Scala names are closer to the actual "A extends B" declaration and thus easier to use in the context of inheritance. Additionally, SQL names are usually case insensitive, which would complicate using SQL names.
Inheritance declarations are based on TypeReference instances. NamedTypeReference can be used for types which don't have a valid representation at generator runtime. For example, we can use it to support extension methods:
Say we generate a case class
Personwith a propertybirthday. We want to add anagefunction to the class, which calculates the current age from the birthday property. Instead of (unsafely) generating the method into the case class, we can extend the case class with a user-defined trait:case class Person(..., birthday: LocalDateTime) extends PersonFunctions
But how do we define the trait so that it can access the values from
Person? Like so:trait PersonFunctions { self: Person => def age: Long = self.birthday.until(LocalDateTime.now(), ChronoUnit.DAYS) }
Only problem: We can't reference PersonFunctions in the generator project as a Type, because it needs the Person case class to even compile. So NamedTypeReference allows you to pass a String instead of a Type for this and other use cases.
-
trait
KeyAsIdColumnPlugin extends ColumnPlugin
This type emitter plugin resolves primary and foreign key columns to the correct raw type:
This type emitter plugin resolves primary and foreign key columns to the correct raw type:
(1) A single-column primary key of a type
Ais resolved to a typeid(A), whereidis an overridable function which defaults toId[A]. For example, for a tablepersonwith a primary key columnid, a propertyid: Id[Person]is emitted. (2) A foreign key pointing to a single-column primary or unique key (see Column.references) is resolved to the raw type of the referenced column (as specified by its PropertyEmitter). For example, for a tableemployeeswith a foreign key columnperson_id, a propertypersonId: Id[Person]is emitted, using the typeId[Person]of the referenced column.For a primary key that is also a foreign key, case (2) prevails, since the primary key is then interpreted as the primary key of another table, just replicated here due to a one-to-one relationship. (This is valid in a few edge cases where the original table can't or shouldn't be manipulated to add more columns.)
Usage Note: The default implementation of
id(A)requires you to import any type Id[A] (via GeneratorConfiguration.imports). For Quill support, it must either extend AnyVal (which should suffice in most use cases) or come with an encoder and decoder.In any case, this emitter only handles single-column primary and foreign keys. You will have to implement some individual handling if you want to type multi-column keys.
-
trait
Literal extends NamingStrategy
Example (sql name => scala name): some_ident => some_ident
-
trait
LowerCase extends NamingStrategy
Example (sql name => scala name): SOME_IDENT => some_ident
-
trait
ModelEmitter extends AnyRef
Handles the transformation of one table to a (case) class.
-
case class
NamedTypeReference(fullName: String, typeArguments: Seq[TypeReference] = Seq.empty) extends TypeReference with Product with Serializable
A type reference pointing to a type which can not yet be referenced via typeOf, which is the case when you need to reference types that are either generated by inkwell or depend on types generated by inkwell.
A type reference pointing to a type which can not yet be referenced via typeOf, which is the case when you need to reference types that are either generated by inkwell or depend on types generated by inkwell.
Let's say the application (using inkwell) defines an
Id[A]type, which represents IDs for any typeA. Say you have a tablepersonfrom which a case classPersonis generated. You can resolve the JDBC type of its ID column toId, but you can not provide the type argumentA = PersonsincePersondoes not exist until code generation is finished. In such a case, this class can be used to represent the right type for the property.
Example: - trait NamingStrategy extends AnyRef
-
class
PartitioningSchemaEmitter extends DefaultSchemaEmitter
Partitions the schema into different packages based on a partitioning map.
Partitions the schema into different packages based on a partitioning map. A single model may be included in multiple partitions. Models not included in any partition will be generated into the base package.
-
trait
PropertyEmitter extends AnyRef
Handles the transformation of one column to a class property.
-
case class
ScalaTypeReference(t: scala.reflect.api.JavaUniverse.Type) extends TypeReference with Product with Serializable
A type reference pointing to a Scala Type, which is the most natural and safe representation possible.
A type reference pointing to a Scala Type, which is the most natural and safe representation possible. However, a Type is not always available, in which case you need to choose a different representation.
Use this class as follows:
import scala.reflect.runtime.universe.typeOf ScalaTypeReference(typeOf[MyType])
Example: -
trait
SchemaEmitter extends AnyRef
Handles the generation of the whole schema and has the power to decide in which files, objects or even packages specific classes are placed.
-
class
SingleFileSchemaEmitter extends DefaultSchemaEmitter
Generates the whole schema into a single file.
-
trait
SnakeCaseToCamelCase extends NamingStrategy
Turns table names to UpperCamelCase and column names to lowerCamelCase.
Turns table names to UpperCamelCase and column names to lowerCamelCase.
Model example (sql name => scala name): some_ident => SomeIdent Property example (sql name => scala name): some_ident => someIdent
-
trait
TypeEmitter extends ColumnPlugin
Provides various ways to turn a type reference into a string.
Provides various ways to turn a type reference into a string.
Plugins are defined so that you can mix in proper implementations at your leisure.
-
trait
TypeReference extends AnyRef
An abstract type reference used by TypeEmitter to resolve a type.
-
trait
UpperCase extends NamingStrategy
Example (sql name => scala name): some_ident => SOME_IDENT
Value Members
- object CamelCaseToSnakeCase extends CamelCaseToSnakeCase
- object Import
- object Inheritances extends Serializable
- object Literal extends Literal
- object LowerCase extends LowerCase
- object SchemaEmitter
- object SnakeCaseToCamelCase extends SnakeCaseToCamelCase
- object TypeEmitter
- object TypeReference
- object TypeUtil
- object UpperCase extends UpperCase