trait
SQLPrimitive[T] extends AnyRef
Abstract Value Members
-
abstract
def
fromRow(row: Row, name: String): Option[T]
-
abstract
def
sqlType: String
-
abstract
def
toSQL(value: T): String
Concrete Value Members
-
final
def
!=(arg0: AnyRef): Boolean
-
final
def
!=(arg0: Any): Boolean
-
final
def
##(): Int
-
final
def
==(arg0: AnyRef): Boolean
-
final
def
==(arg0: Any): Boolean
-
final
def
asInstanceOf[T0]: T0
-
def
clone(): AnyRef
-
final
def
eq(arg0: AnyRef): Boolean
-
def
equals(arg0: Any): Boolean
-
def
finalize(): Unit
-
final
def
getClass(): Class[_]
-
def
hashCode(): Int
-
final
def
isInstanceOf[T0]: Boolean
-
final
def
ne(arg0: AnyRef): Boolean
-
final
def
notify(): Unit
-
final
def
notifyAll(): Unit
-
final
def
synchronized[T0](arg0: ⇒ T0): T0
-
def
toString(): String
-
final
def
wait(): Unit
-
final
def
wait(arg0: Long, arg1: Int): Unit
-
final
def
wait(arg0: Long): Unit
Inherited from AnyRef
Inherited from Any
The innocent reader may now try and ask the question "What does this do?". The type class approach is meant to limit the amount of Data types we inherently recognise as defaults or primitives.
This allows for a very simple limitation mechanism where we exploit the basic Scala implicit resolution mechanism to perform efficient type restrictions and encoding/decoding to/from database results. If a type needs serialisation, we simply request for type evidence via the below type class using
implicity[SQLPrimitive[T]]{code}.
If proof exists that the type T has an SQLPrimitive type class associated with it, then the type is considered primitive with regards to the current SQL database in use. This means we will allow for variation of primitive type implementations between different SQL databases. The challenge arises from needing to parse Primitives implicitly in the DSL module itself to create the basic extendable functionality.
We then need to allow other database specific implementations to override these implementations and pass the new ones explicity. As this encapsulates very important information, such as how to decode a specific type from a given database implementation when a query is performed, the breach of this contract means we might as well start another project.
Any below weirdness or poor choice of semantics is probably the only possible way through which the above was achieved This involves defining the default extendable types as normal classes instead of traits to allow their instantiation as overridable vals.
The primitive SQL data type to create a type class for.