com.websudos.morpheus.column

ForeignKey

abstract class ForeignKey[T <: BaseTable[T, R], R, T1 <: BaseTable[T1, _]] extends AbstractColumn[String] with IndexColumn with ForeignKeyDefinition

This is the implementation of a ForeignKey column. This is not a value column, therefore the apply method is overridden to throw an exception. It is used at reflection time and schema generation time to correctly create the schema for a given table and serialise a ForeignKey accordingly.

The peculiar type signature is very simple really. It's using the all known and loved shapeless type inequality constraint, essentially forcing DSL users to specify 2 different owning tables for the origin and reference of a FOREIGN_KEY. It's a way of making FOREIGN_KEY indexes impossible between a table and itself and it's also nicely confining all columns to belong to the same reference table, effectively enforcing the SQL constraint that a ForeignKey cannot reference columns from more than one table.

The second type constraint enforced via the ev2 implicit parameter is requesting that the columns referenced in a ForeignKey are not an Index or ForeignKey themselves, as this is invalid with respect to SQL syntax.

By default the action performed is DefaultForeignKeyConstraints.NoAction, with respect to the SQL standard.

T

The type of the owner table.

R

The type of the record.

Annotations
@implicitNotFound( ... )
Linear Supertypes
ForeignKeyDefinition, IndexColumn, AbstractColumn[String], SchemaSerializer, AnyRef, Any
Ordering
  1. Alphabetic
  2. By inheritance
Inherited
  1. ForeignKey
  2. ForeignKeyDefinition
  3. IndexColumn
  4. AbstractColumn
  5. SchemaSerializer
  6. AnyRef
  7. Any
  1. Hide All
  2. Show all
Learn more about member selection
Visibility
  1. Public
  2. All

Instance Constructors

  1. new ForeignKey(origin: T, columns: Column[T1, _, _]*)(implicit ev: =:!=[T, T1], ev2: <:!<[Column[T1, _, _], IndexColumn])

    origin

    The table owning the foreign key.

    columns

    The columns this foreign key references.

Type Members

  1. type NonIndexColumn[Owner <: BaseTable[Owner, _]] = Column[Owner, _, _]

    Definition Classes
    IndexColumn
  2. type Value = String

    Definition Classes
    AbstractColumn

Value Members

  1. final def !=(arg0: AnyRef): Boolean

    Definition Classes
    AnyRef
  2. final def !=(arg0: Any): Boolean

    Definition Classes
    Any
  3. final def ##(): Int

    Definition Classes
    AnyRef → Any
  4. final def ==(arg0: AnyRef): Boolean

    Definition Classes
    AnyRef
  5. final def ==(arg0: Any): Boolean

    Definition Classes
    Any
  6. def apply(r: Row): String

    Definition Classes
    IndexColumn
  7. final def asInstanceOf[T0]: T0

    Definition Classes
    Any
  8. def clone(): AnyRef

    Attributes
    protected[java.lang]
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  9. final def eq(arg0: AnyRef): Boolean

    Definition Classes
    AnyRef
  10. def equals(arg0: Any): Boolean

    Definition Classes
    AnyRef → Any
  11. def finalize(): Unit

    Attributes
    protected[java.lang]
    Definition Classes
    AnyRef
    Annotations
    @throws( classOf[java.lang.Throwable] )
  12. final def getClass(): Class[_]

    Definition Classes
    AnyRef → Any
  13. def hashCode(): Int

    Definition Classes
    AnyRef → Any
  14. final def isInstanceOf[T0]: Boolean

    Definition Classes
    Any
  15. lazy val name: String

    Definition Classes
    AbstractColumn
  16. final def ne(arg0: AnyRef): Boolean

    Definition Classes
    AnyRef
  17. def notNull: Boolean

    This method, overridden by the Null and NotNull Key mixins, tells if a column is allowed to be null with respect to the SQL schema.

    This method, overridden by the Null and NotNull Key mixins, tells if a column is allowed to be null with respect to the SQL schema. Using the stackable trait pattern it's easier for the end DSL users to mentally map a Scala schema to an SQL schema with 0 effort and inversely, go from SQL to Morpheus DSL code.

    returns

    A Boolean value.

    Definition Classes
    AbstractColumn
  18. final def notify(): Unit

    Definition Classes
    AnyRef
  19. final def notifyAll(): Unit

    Definition Classes
    AnyRef
  20. def onDelete: ForeignKeyConstraint

  21. def onUpdate: ForeignKeyConstraint

    The default ForeignKey constraint with respect to the MySQL documentation is NoAction and we enforce that here.

    The default ForeignKey constraint with respect to the MySQL documentation is NoAction and we enforce that here. If the constraint defined on either update or delete is NoAction, then there will be no serialisation output as MySQL doesn't need it.

    returns

    The ForeignKey Constraint to execute on update.

  22. def qb: SQLBuiltQuery

    Definition Classes
    ForeignKey → AbstractColumn → SchemaSerializer
  23. def sqlType: String

    This is actually irrelevant at any further point, since the query builder of ForeignKey will not account for it's SQL type.

    This is actually irrelevant at any further point, since the query builder of ForeignKey will not account for it's SQL type. We do however need to satisfy the context bound of an SQL primitive and we do so easily but using a random predefined type.

    returns

    The SQL type of the column, ignored in the current context.

    Definition Classes
    ForeignKey → AbstractColumn
  24. final def synchronized[T0](arg0: ⇒ T0): T0

    Definition Classes
    AnyRef
  25. def table: BaseTable[_, _]

    A dangerous mix indeed, since it will all go to hell if the user defines a ForeignKey constraint to no column.

    A dangerous mix indeed, since it will all go to hell if the user defines a ForeignKey constraint to no column. The above root cause of evil for the below line is not valid SQL syntax, but we should likely upgrade to a more sensible error. TODO (flavian): Idiotic line, upgrade the preconditions.

    returns

    Definition Classes
    ForeignKey → AbstractColumn
  26. def toQueryString(v: String): String

    Same story as above, these are placeholders to satisfy the structure we've defined for our DSL.

    Same story as above, these are placeholders to satisfy the structure we've defined for our DSL. It is likely proof we could have decoupled certain things to prevent the need for impromptu definitions like this, but we didn't so far.

    v

    The value to convert to an SQL value.

    returns

    Definition Classes
    ForeignKey → AbstractColumn
  27. def toString(): String

    Definition Classes
    AnyRef → Any
  28. final def wait(): Unit

    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  29. final def wait(arg0: Long, arg1: Int): Unit

    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  30. final def wait(arg0: Long): Unit

    Definition Classes
    AnyRef
    Annotations
    @throws( ... )

Inherited from ForeignKeyDefinition

Inherited from IndexColumn

Inherited from AbstractColumn[String]

Inherited from SchemaSerializer

Inherited from AnyRef

Inherited from Any

Ungrouped