SQLDefinition

doobie.SQLDefinition
See theSQLDefinition companion object
trait SQLDefinition[A] extends SQLDefinitionRead[A]

An SQL definition that produces a value of type A.

The definition can be either:

Attributes

Companion
object
Source
SQLDefinition.scala
Graph
Supertypes
trait Prefixable[A]
class Object
trait Matchable
class Any
Show all
Known subtypes
class Column[A]
Self type

Members list

Type members

Types

type Result = A

Used in dependent type expressions.

Used in dependent type expressions.

Attributes

Source
SQLDefinition.scala
type Self[X] <: SQLDefinition[X]

Attributes

Source
SQLDefinition.scala

Value members

Abstract methods

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

Source
SQLDefinition.scala
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

Source
SQLDefinition.scala
def imap[B](mapper: A => B)(contramapper: B => A): Self[B]

Changes the type of the definition. The change must be invariant and cannot fail. Useful for wrapper types.

Changes the type of the definition. The change must be invariant and cannot fail. Useful for wrapper types.

Attributes

Source
SQLDefinition.scala

Was this SQLDefinition created from a option method.

Was this SQLDefinition created from a option method.

Attributes

Source
SQLDefinition.scala
def option[B](using ng: NotGiven[A =:= Option[B]]): Self[Option[A]]

Creates an Option version of the SQLDefinition, giving that it is not already an Option.

Creates an Option version of the SQLDefinition, giving that it is not already an Option.

Useful when you are doing joins and want a non-nullable Column/SQLDefinition to be represented as a nullable one.

Attributes

Source
SQLDefinition.scala
def write: Write[A]

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

Source
SQLDefinition.scala

Concrete methods

Returns Update for batch inserts into the given table.

Returns Update for batch inserts into the given table.

Attributes

Source
SQLDefinition.scala

Full SQL for inserting into the given table.

Full SQL for inserting into the given table.

Attributes

Source
SQLDefinition.scala

Generates a Fragment that sets all columns of the SQLDefinition to their excluded values.

Generates a Fragment that sets all columns of the SQLDefinition to their excluded values.

Attributes

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 (SQLDefinition[Int], SQLDefinition[String]).

Attributes

Source
SQLDefinition.scala

Inherited methods

override def fragment: Fragment

Attributes

Definition Classes
Inherited from:
SQLDefinitionRead
Source
SQLDefinition.scala
def map[B](mapper: A => B): SQLDefinitionRead[B]

Changes the type of the definition. The change cannot fail. Useful for wrapper types.

Changes the type of the definition. The change cannot fail. Useful for wrapper types.

Attributes

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

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

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

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

Attributes

Inherited from:
SQLDefinitionRead
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

Inherited and Abstract methods

Vector of columns

Vector of columns

Attributes

Inherited from:
SQLDefinitionRead
Source
SQLDefinition.scala
def prefixedWith(prefix: String): 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

Inherited from:
Prefixable
Source
TypedMultiFragment.scala
def read: Read[A]

Attributes

Inherited from:
TypedMultiFragment
Source
TypedMultiFragment.scala

Concrete fields

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

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

Source
SQLDefinition.scala

Inherited fields

lazy val excluded: 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:
Prefixable
Source
TypedMultiFragment.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:
SQLDefinitionRead
Source
SQLDefinition.scala

Givens

Givens

given given_Write_A: Write[A]

Attributes

Source
SQLDefinition.scala

Inherited givens

given given_Read_A: Read[A]

Attributes

Inherited from:
SQLDefinitionRead
Source
SQLDefinition.scala