Trait

com.lucidchart.open.relate

Expandable

Related Doc: package relate

Permalink

sealed trait Expandable extends ParameterizableSql

Expandable is a trait for SQL queries that can be expanded.

It defines two expansion methods:

These methods should be called in the expand method.

import com.lucidchart.open.relate._
import com.lucidchart.open.relate.Query._

val ids = Array(1L, 2L, 3L)

SQL("""
  SELECT *
  FROM users
  WHERE id IN ({ids})
""").expand { implicit query =>
  commaSeparated("ids", ids.size)
}.on {
  longs("ids", ids)
}
Linear Supertypes
Ordering
  1. Alphabetic
  2. By inheritance
Inherited
  1. Expandable
  2. ParameterizableSql
  3. ParameterizedSql
  4. Sql
  5. AnyRef
  6. Any
  1. Hide All
  2. Show all
Visibility
  1. Public
  2. All

Type Members

  1. class BaseStatement extends AnyRef

    Permalink
    Attributes
    protected[com.lucidchart.open.relate]
    Definition Classes
    Sql

Abstract Value Members

  1. abstract def getCopy(params: List[(SqlStatement) ⇒ Unit]): ParameterizableSql

    Permalink

    Classes that inherit the Sql trait will have to implement a method to copy themselves given just a different set of parameters.

    Classes that inherit the Sql trait will have to implement a method to copy themselves given just a different set of parameters. HINT: Use a case class!

    Attributes
    protected
    Definition Classes
    ParameterizableSql
  2. abstract val listParams: Map[String, ListParam]

    Permalink

    The names of list params mapped to their size

  3. abstract val params: List[(SqlStatement) ⇒ Unit]

    Permalink

    A list of anonymous functions that insert parameters into a SqlStatement

    A list of anonymous functions that insert parameters into a SqlStatement

    Attributes
    protected
    Definition Classes
    ParameterizableSql
  4. abstract def queryParams: QueryParams

    Permalink
    Attributes
    protected[com.lucidchart.open.relate]
    Definition Classes
    ParameterizedSql

Concrete Value Members

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

    Permalink
    Definition Classes
    AnyRef → Any
  2. final def ##(): Int

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

    Permalink
    Definition Classes
    AnyRef → Any
  4. def applyParams(stmt: PreparedStatement): Unit

    Permalink
    Attributes
    protected
    Definition Classes
    ParameterizedSqlSql
  5. def as[A]()(implicit arg0: Parseable[A], connection: Connection): A

    Permalink
    Definition Classes
    Sql
  6. def asCollection[U, T[_]]()(implicit arg0: Parseable[U], cbf: CanBuildFrom[T[U], U, T[U]], connection: Connection): T[U]

    Permalink
    Definition Classes
    Sql
  7. def asCollection[U, T[_]](parser: (SqlResult) ⇒ U)(implicit cbf: CanBuildFrom[T[U], U, T[U]], connection: Connection): T[U]

    Permalink

    Execute this query and get back the result as an arbitrary collection of records

    Execute this query and get back the result as an arbitrary collection of records

    parser

    the RowParser to use when parsing the result set

    connection

    the connection to use when executing the query

    returns

    the results as an arbitrary collection of records

    Definition Classes
    Sql
  8. final def asInstanceOf[T0]: T0

    Permalink
    Definition Classes
    Any
  9. def asIterable[A]()(implicit arg0: Parseable[A], connection: Connection): Iterable[A]

    Permalink
    Definition Classes
    Sql
  10. def asIterable[A](parser: (SqlResult) ⇒ A)(implicit connection: Connection): Iterable[A]

    Permalink

    Execute this query and get back the result as an iterable of records

    Execute this query and get back the result as an iterable of records

    parser

    the RowParser to use when parsing the result set

    connection

    the connection to use when executing the query

    returns

    the results as an iterable of records

    Definition Classes
    Sql
  11. def asIterator[A](parser: (SqlResult) ⇒ A, fetchSize: Int = 100)(implicit connection: Connection): Iterator[A]

    Permalink

    The asIterator method returns an Iterator that will stream data out of the database.

    The asIterator method returns an Iterator that will stream data out of the database. This avoids an OutOfMemoryError when dealing with large datasets. Bear in mind that many JDBC implementations will not allow additional queries to the connection before all records in the Iterator have been retrieved.

    parser

    the RowParser to parse rows with

    fetchSize

    the number of rows to fetch at a time, defaults to 100. If the JDBC Driver is MySQL, the fetchSize will always default to Int.MinValue, as MySQL's JDBC implementation ignores all other fetchSize values and only streams if fetchSize is Int.MinValue

    Definition Classes
    Sql
  12. def asList[A]()(implicit arg0: Parseable[A], connection: Connection): List[A]

    Permalink
    Definition Classes
    Sql
  13. def asList[A](parser: (SqlResult) ⇒ A)(implicit connection: Connection): List[A]

    Permalink

    Execute this query and get back the result as a List of records

    Execute this query and get back the result as a List of records

    parser

    the RowParser to use when parsing the result set

    connection

    the connection to use when executing the query

    returns

    the results as a List of records

    Definition Classes
    Sql
  14. def asMap[U, V]()(implicit connection: Connection, p: Parseable[(U, V)]): Map[U, V]

    Permalink
    Definition Classes
    Sql
  15. def asMap[U, V](parser: (SqlResult) ⇒ (U, V))(implicit connection: Connection): Map[U, V]

    Permalink

    Execute this query and get back the result as a Map of records

    Execute this query and get back the result as a Map of records

    parser

    the RowParser to use when parsing the result set. The RowParser should return a Tuple of size 2 containing the key and value

    connection

    the connection to use when executing the query

    returns

    the results as a Map of records

    Definition Classes
    Sql
  16. def asMultiMap[U, V]()(implicit connection: Connection, p: Parseable[(U, V)]): Map[U, Set[V]]

    Permalink
    Definition Classes
    Sql
  17. def asMultiMap[U, V](parser: (SqlResult) ⇒ (U, V))(implicit connection: Connection): Map[U, Set[V]]

    Permalink
    Definition Classes
    Sql
  18. def asPairCollection[U, V, T[_, _]]()(implicit cbf: CanBuildFrom[T[U, V], (U, V), T[U, V]], connection: Connection, p: Parseable[(U, V)]): T[U, V]

    Permalink
    Definition Classes
    Sql
  19. def asPairCollection[U, V, T[_, _]](parser: (SqlResult) ⇒ (U, V))(implicit cbf: CanBuildFrom[T[U, V], (U, V), T[U, V]], connection: Connection): T[U, V]

    Permalink

    Execute this query and get back the result as an arbitrary collection of key value pairs

    Execute this query and get back the result as an arbitrary collection of key value pairs

    parser

    the RowParser to use when parsing the result set

    connection

    the connection to use when executing the query

    returns

    the results as an arbitrary collection of key value pairs

    Definition Classes
    Sql
  20. def asScalar[A]()(implicit connection: Connection): A

    Permalink

    Execute this query and get back the result as a single value.

    Execute this query and get back the result as a single value. Assumes that there is only one row and one value in the result set.

    connection

    the connection to use when executing the query

    returns

    the results as a single value

    Definition Classes
    Sql
  21. def asScalarOption[A]()(implicit connection: Connection): Option[A]

    Permalink

    Execute this query and get back the result as an optional single value.

    Execute this query and get back the result as an optional single value. Assumes that there is only one row and one value in the result set.

    connection

    the connection to use when executing the query

    returns

    the results as an optional single value

    Definition Classes
    Sql
  22. def asSeq[A]()(implicit arg0: Parseable[A], connection: Connection): Seq[A]

    Permalink
    Definition Classes
    Sql
  23. def asSeq[A](parser: (SqlResult) ⇒ A)(implicit connection: Connection): Seq[A]

    Permalink

    Execute this query and get back the result as a sequence of records

    Execute this query and get back the result as a sequence of records

    parser

    the RowParser to use when parsing the result set

    connection

    the connection to use when executing the query

    returns

    the results as a sequence of records

    Definition Classes
    Sql
  24. def asSet[A]()(implicit arg0: Parseable[A], connection: Connection): Set[A]

    Permalink
    Definition Classes
    Sql
  25. def asSet[A](parser: (SqlResult) ⇒ A)(implicit connection: Connection): Set[A]

    Permalink

    Execute this query and get back the result as a Set of records

    Execute this query and get back the result as a Set of records

    parser

    the RowParser to use when parsing the result set

    connection

    the connection to use when executing the query

    returns

    the results as a Set of records

    Definition Classes
    Sql
  26. def asSingle[A]()(implicit arg0: Parseable[A], connection: Connection): A

    Permalink
    Definition Classes
    Sql
  27. def asSingle[A](parser: (SqlResult) ⇒ A)(implicit connection: Connection): A

    Permalink

    Execute this query and get back the result as a single record

    Execute this query and get back the result as a single record

    parser

    the RowParser to use when parsing the result set

    connection

    the connection to use when executing the query

    returns

    the results as a single record

    Definition Classes
    Sql
  28. def asSingleOption[A]()(implicit arg0: Parseable[A], connection: Connection): Option[A]

    Permalink
    Definition Classes
    Sql
  29. def asSingleOption[A](parser: (SqlResult) ⇒ A)(implicit connection: Connection): Option[A]

    Permalink

    Execute this query and get back the result as an optional single record

    Execute this query and get back the result as an optional single record

    parser

    the RowParser to use when parsing the result set

    connection

    the connection to use when executing the query

    returns

    the results as an optional single record

    Definition Classes
    Sql
  30. def clone(): AnyRef

    Permalink
    Attributes
    protected[java.lang]
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  31. def commaSeparated(name: String, count: Int): Unit

    Permalink

    Replace the provided identifier with a comma separated list of parameters WARNING: modifies this Expandable in place

    Replace the provided identifier with a comma separated list of parameters WARNING: modifies this Expandable in place

    name

    the identifier for the parameter

    count

    the count of parameters in the list

  32. def commas(name: String, count: Int): Expandable

    Permalink

    Shorthand for calling commaSeparated within an expand block.

    Shorthand for calling commaSeparated within an expand block.

    SQL("SELECT * FROM users WHERE id IN ({ids})").commas("ids", 10)

    is equivalent to

    SQL("SELECT * FROM users WHERE id IN ({ids})").expand { implicit query =>
      commaSeparated("ids", 10)
    }

    WARNING: modifies this Expandable in place

    name

    the parameter name to expand

    count

    the number of items in the comma separated list

    returns

    this Expandable with the added list parameters

  33. final def eq(arg0: AnyRef): Boolean

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

    Permalink
    Definition Classes
    AnyRef → Any
  35. def execute()(implicit connection: Connection): Boolean

    Permalink

    Execute a statement

    Execute a statement

    connection

    the db connection to use when executing the query

    returns

    whether the query succeeded in its execution

    Definition Classes
    Sql
  36. def executeInsertCollection[U, T[_]](parser: (SqlResult) ⇒ U)(implicit cbf: CanBuildFrom[T[U], U, T[U]], connection: Connection): T[U]

    Permalink

    Execute the query and get the auto-incremented keys using a RowParser.

    Execute the query and get the auto-incremented keys using a RowParser. Provided for the case that a primary key is not an Int or BigInt

    parser

    the RowParser that can parse the returned keys

    connection

    the connection to use when executing the query

    returns

    the auto-incremented keys

    Definition Classes
    Sql
  37. def executeInsertInt()(implicit connection: Connection): Int

    Permalink

    Execute the query and get the auto-incremented key as an Int

    Execute the query and get the auto-incremented key as an Int

    connection

    the connection to use when executing the query

    returns

    the auto-incremented key as an Int

    Definition Classes
    Sql
  38. def executeInsertInts()(implicit connection: Connection): List[Int]

    Permalink

    Execute the query and get the auto-incremented keys as a List of Ints

    Execute the query and get the auto-incremented keys as a List of Ints

    connection

    the connection to use when executing the query

    returns

    the auto-incremented keys as a List of Ints

    Definition Classes
    Sql
  39. def executeInsertLong()(implicit connection: Connection): Long

    Permalink

    Execute the query and get the auto-incremented key as a Long

    Execute the query and get the auto-incremented key as a Long

    connection

    the connection to use when executing the query

    returns

    the auto-incremented key as a Long

    Definition Classes
    Sql
  40. def executeInsertLongs()(implicit connection: Connection): List[Long]

    Permalink

    Execute the query and get the auto-incremented keys as a a List of Longs

    Execute the query and get the auto-incremented keys as a a List of Longs

    connection

    the connection to use when executing the query

    returns

    the auto-incremented keys as a a List of Longs

    Definition Classes
    Sql
  41. def executeInsertSingle[U](parser: (SqlResult) ⇒ U)(implicit connection: Connection): U

    Permalink

    Execute the query and get the auto-incremented key using a RowParser.

    Execute the query and get the auto-incremented key using a RowParser. Provided for the case that a primary key is not an Int or BigInt

    parser

    the RowParser that can parse the returned key

    connection

    the connection to use when executing the query

    returns

    the auto-incremented key

    Definition Classes
    Sql
  42. def executeUpdate()(implicit connection: Connection): Int

    Permalink

    Execute an update

    Execute an update

    connection

    the db connection to use when executing the query

    returns

    the number of rows update by the query

    Definition Classes
    Sql
  43. def expand(f: (Expandable) ⇒ Unit): Expandable

    Permalink

    Expand out the query by turning an TraversableOnce into several parameters

    Expand out the query by turning an TraversableOnce into several parameters

    returns

    a copy of this Expandable with the query expanded

  44. def finalize(): Unit

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

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

    Permalink
    Definition Classes
    AnyRef → Any
  47. def insertionStatement(implicit connection: Connection): BaseStatement with InsertionStatementPreparer

    Permalink
    Attributes
    protected
    Definition Classes
    Sql
  48. final def isInstanceOf[T0]: Boolean

    Permalink
    Definition Classes
    Any
  49. final def ne(arg0: AnyRef): Boolean

    Permalink
    Definition Classes
    AnyRef
  50. def normalStatement(implicit connection: Connection): BaseStatement with NormalStatementPreparer

    Permalink
    Attributes
    protected
    Definition Classes
    Sql
  51. final def notify(): Unit

    Permalink
    Definition Classes
    AnyRef
  52. final def notifyAll(): Unit

    Permalink
    Definition Classes
    AnyRef
  53. def on(f: (SqlStatement) ⇒ Unit): ParameterizableSql

    Permalink

    Put in values for parameters in the query

    Put in values for parameters in the query

    f

    a function that takes a SqlStatement and sets parameter values using its methods

    returns

    a copy of this Sql with the new params

    Definition Classes
    ParameterizableSql
  54. def onTuples[A](name: String, tuples: TraversableOnce[A])(f: (A, TupleStatement) ⇒ Unit): ParameterizableSql

    Permalink

    Put in values for tuple parameters in the query

    Put in values for tuple parameters in the query

    name

    the tuple identifier in the query

    tuples

    the objects to loop over and use to insert data into the query

    f

    a function that takes a TupleStatement and sets parameter values using its methods

    returns

    a copy of this Sql with the new tuple params

    Definition Classes
    ParameterizableSql
  55. val parsedParams: Map[String, List[Int]]

    Permalink
    Attributes
    protected
    Definition Classes
    ParameterizedSql
  56. val parsedQuery: String

    Permalink
    Attributes
    protected
    Definition Classes
    ParameterizedSqlSql
  57. def results()(implicit connection: Connection): ResultSet

    Permalink

    Provides direct access to the underlying java.sql.ResultSet.

    Provides direct access to the underlying java.sql.ResultSet. Note that this ResultSet must be closed manually or by wrapping it in SqlResult.

    val results = SQL(query).results()
    . . .
    SqlResult(results).asList[A](parser)
    // or
    results.close()
    returns

    java.sql.ResultSet

    Definition Classes
    Sql
  58. def statementString(implicit connection: Connection): String

    Permalink

    Calls PreparedStatement#toString, which for many JDBC implementations is the SQL query after parameter substitution.

    Calls PreparedStatement#toString, which for many JDBC implementations is the SQL query after parameter substitution. This is intended primarily for ad-hoc debugging.

    For more routine logging, consider other solutions, such as log4jdbc.

    Definition Classes
    Sql
  59. def streamedStatement(fetchSize: Int)(implicit connection: Connection): BaseStatement with StreamedStatementPreparer

    Permalink
    Attributes
    protected
    Definition Classes
    Sql
  60. final def synchronized[T0](arg0: ⇒ T0): T0

    Permalink
    Definition Classes
    AnyRef
  61. def toString(): String

    Permalink

    Returns the SQL query, before parameter substitution.

    Returns the SQL query, before parameter substitution.

    Definition Classes
    Sql → AnyRef → Any
  62. def tupled(name: String, columns: Seq[String], numTuples: Int): Unit

    Permalink

    Replace the provided identifier with a comma separated list of tuples WARNING: modifies this Expandable in place

    Replace the provided identifier with a comma separated list of tuples WARNING: modifies this Expandable in place

    name

    the identifier for the tuples

    columns

    a list of the column names in the order they should be inserted into the tuples

    numTuples

    the number of tuples to insert

  63. final def wait(): Unit

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

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

    Permalink
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )

Inherited from ParameterizableSql

Inherited from ParameterizedSql

Inherited from Sql

Inherited from AnyRef

Inherited from Any

Ungrouped