WithSQLDefinition

doobie.WithSQLDefinition
trait WithSQLDefinition[A](val sqlDefinition: SQLDefinition[A]) extends SQLDefinition[A]

Allows you to inline a SQLDefinition.

This is useful when you want to expose the Read and Write of the A in the companion object.

Example:

 case class Row(matchId: MatchId, userData: UserData)
 object Row extends WithSQLDefinition[Row](Composite((
   matchId.sqlDef, UserData.sqlDef
 ))(Row.apply)(Tuple.fromProductTyped))

Attributes

Source
WithSQLDefinition.scala
Graph
Supertypes
trait SQLDefinition[A]
class Object
trait Matchable
class Any

Members list

Type members

Types

override type Self[X] = sqlDefinition.Self[X]

Attributes

Source
WithSQLDefinition.scala

Inherited types

type Result = A

Used in dependent type expressions.

Used in dependent type expressions.

Attributes

Inherited from:
SQLDefinition
Source
SQLDefinition.scala

Value members

Concrete methods

override def ===(value: A): TypedFragment[Boolean]

Returns the SQL which evaluates to true if all columns of this SQLDefinition are equal to the given value.

Returns the SQL which evaluates to true if all columns of this SQLDefinition are equal to the given value.

Attributes

Definition Classes
Source
WithSQLDefinition.scala
override def ==>(value: A): NonEmptyVector[(Fragment, Fragment)]

Converts the value into a vector of (columnName, value) pairs.

Converts the value into a vector of (columnName, value) pairs.

Attributes

Definition Classes
Source
WithSQLDefinition.scala
override def columns: NonEmptyVector[Column[_]]

Vector of columns

Vector of columns

Attributes

Definition Classes
Source
WithSQLDefinition.scala
override def prefixedWith(prefix: String): sqlDefinition.Self[A]

Prefixes all column names with prefix.. If this already had a prefix, the prefix is replaced.

Prefixes all column names with prefix.. If this already had a prefix, the prefix is replaced.

Attributes

Definition Classes
Source
WithSQLDefinition.scala
override def read: Read[A]

Attributes

Definition Classes
Source
WithSQLDefinition.scala
override def write: Write[A]

Attributes

Definition Classes
Source
WithSQLDefinition.scala

Inherited methods

Returns Update for batch inserts into the given table.

Returns Update for batch inserts into the given table.

Attributes

Inherited from:
SQLDefinition
Source
SQLDefinition.scala

Attributes

Inherited from:
SQLDefinition
Source
SQLDefinition.scala

Full SQL for inserting into the given table.

Full SQL for inserting into the given table.

Attributes

Inherited from:
SQLDefinition
Source
SQLDefinition.scala
inline def sqlDef: SQLDefinition[A]

To allow widening the type of Column and similar ones to SQLDefinition.

To allow widening the type of Column and similar ones to SQLDefinition.

This is useful when working with tuples of SQLDefinitions, because (Column[Int], Column[String]) is not the same thing as (SQLResult[Int], SQLResult[String]).

Attributes

Inherited from:
SQLDefinition
Source
SQLDefinition.scala
inline def tmf: TypedMultiFragment[A]

To allow widening the type of Column and similar ones to TypedMultiFragment.

To allow widening the type of Column and similar ones to TypedMultiFragment.

This is useful when working with tuples of TypedMultiFragments, because (Column[Int], Column[String]) is not the same thing as (TypedMultiFragment[Int], TypedMultiFragment[String]).

Attributes

Inherited from:
TypedMultiFragment
Source
TypedMultiFragment.scala

Concrete fields

Inherited fields

lazy val columnsSql: Fragment

The SQL Fragment containing all of the Column.name joined with ",".

The SQL Fragment containing all of the Column.name joined with ",".

Useful in preparing batch inserts.

 Update[Person](
   sql"INSERT INTO $personTable (${person.columnsSql}) VALUES (${person.valuesSql})".rawSql
 ).updateMany(persons)

Attributes

Inherited from:
SQLDefinition
Source
SQLDefinition.scala
lazy val excluded: sqlDefinition.Self[A]

Prefixes all column names with EXCLUDED, which is a special SQL table name when resolving insert/update conflicts.

Prefixes all column names with EXCLUDED, which is a special SQL table name when resolving insert/update conflicts.

Example:

 sql"""
    ${t.Row.insertSqlFor(t)}
    ON CONFLICT (${t.userId}, ${t.weaponId}) DO UPDATE SET ${t.kills} = ${t.kills} + ${t.kills.excluded}
 """

Attributes

Inherited from:
SQLDefinition
Source
SQLDefinition.scala
lazy val insertSql: Fragment

Combines columnsSql and valuesSql.

Combines columnsSql and valuesSql.

Useful in preparing batch inserts.

 Update[Person](
   sql"INSERT INTO $personTable ${person.insertSql}".rawSql
 ).updateMany(persons)

Attributes

Inherited from:
SQLDefinition
Source
SQLDefinition.scala
lazy val sql: Fragment

SQL that lists all of the columns to get this SQL result.

SQL that lists all of the columns to get this SQL result.

Attributes

Inherited from:
SQLDefinition
Source
SQLDefinition.scala
lazy val valuesSql: Fragment

The SQL Fragment containing as many value placeholders (?) as there are columns joined with ",".

The SQL Fragment containing as many value placeholders (?) as there are columns joined with ",".

Useful in preparing batch inserts. See columnsSql.

Attributes

Inherited from:
SQLDefinition
Source
SQLDefinition.scala

Givens

Inherited givens

given given_Read_A: Read[A]

Attributes

Inherited from:
SQLDefinition
Source
SQLDefinition.scala
given given_Write_A: Write[A]

Attributes

Inherited from:
SQLDefinition
Source
SQLDefinition.scala