Package

com.lucidchart.open

relate

Permalink

package relate

Relate API

Use the SQL method to start an SQL query

import com.lucidchart.open.relate._

SQL("Select 1")
Linear Supertypes
AnyRef, Any
Ordering
  1. Alphabetic
  2. By inheritance
Inherited
  1. relate
  2. AnyRef
  3. Any
  1. Hide All
  2. Show all
Visibility
  1. Public
  2. All

Type Members

  1. sealed trait Expandable extends ParameterizableSql

    Permalink

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

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

    It defines two expansion methods:

    • commaSeparated for expanding a parameter into a comma separated list
    • tupled for expanding a parameter into a comma separated list of tuples for insertion queries

    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)
    }
  2. trait ParameterizableSql extends ParameterizedSql

    Permalink
  3. trait ParameterizedSql extends Sql

    Permalink
  4. trait Parseable[A] extends AnyRef

    Permalink
  5. trait Sql extends AnyRef

    Permalink

    Sql is a trait for basic SQL queries.

    Sql is a trait for basic SQL queries.

    It provides methods for parameter insertion and query execution.

    import com.lucidchart.open.relate._
    import com.lucidchart.open.relate.Query._
    
    case class User(id: Long, name: String)
    
    SQL("""
      SELECT id, name
      FROM users
      WHERE id={id}
    """).on { implicit query =>
      long("id", 1L)
    }.asSingle(RowParser { row =>
      User(row.long("id"), row.string("name"))
    })
  6. class SqlResult extends AnyRef

    Permalink

    The SqlResult class is a wrapper around Java's ResultSet class.

    The SqlResult class is a wrapper around Java's ResultSet class.

    It provides methods to allows users to retrieve specific columns by name and datatype, but also provides methods that can, given a RowParser, parse the entire result set as a collection of records returned by the parser. These methods are also defined in the Sql trait, and are most conveniently used when chained with parameter insertion. For how to do this, see the Sql trait documentation.

    The extraction methods (int, string, long, etc.) also have "strict" counterparts. The "strict" methods are slightly faster, but do not do type checking or handle null values.

  7. class SqlStatement extends AnyRef

    Permalink

    A smart wrapper around the PreparedStatement class that allows inserting parameter values by name rather than by index.

    A smart wrapper around the PreparedStatement class that allows inserting parameter values by name rather than by index. Provides methods for inserting all necessary datatypes.

  8. case class TupleStatement(stmt: PreparedStatement, params: Map[String, Int], index: Int) extends Product with Serializable

    Permalink

    This class is used to insert tuple data into a prepared statement

  9. trait RowParser[+A] extends (SqlResult) ⇒ A

    Permalink

    A RowParser is a function that takes a SqlResult as a parameter and parses it to return a concrete type

    A RowParser is a function that takes a SqlResult as a parameter and parses it to return a concrete type

    See the RowParser for more information

    Annotations
    @deprecated
    Deprecated

    (Since version 1.7.0) Use plain SqlResult => A instead

Value Members

  1. object PaginatedQuery

    Permalink

    The PaginatedQuery companion object supplies apply methods that will create new PaginatedQuery's and execute them to get Streams of results.

    The PaginatedQuery companion object supplies apply methods that will create new PaginatedQuery's and execute them to get Streams of results.

    PaginatedQuery provides two pagination methods:

    • Using LIMIT and OFFSET
    • Allowing the user to specify the next query based on the last record in the previous page

    The latter method is provided because the LIMIT/OFFSET method has poor performance when result sets get large.

  2. object Parseable

    Permalink
  3. object Query

    Permalink

    Provide implicit method calls for syntactic sugar

    Provide implicit method calls for syntactic sugar

    These functions should be used in the on and expand methods.

    import com.lucidchart.open.relate._
    import com.lucidchart.open.relate.Query._
    
    SQL("SELECT * FROM users WHERE id={id}").on { implicit query =>
     long("id", 1L)
    }

    See the Relate Wiki for more information.

  4. object RowParser

    Permalink

    The RowParser companion object allows creation of arbitrary RowParsers with its apply method.

    The RowParser companion object allows creation of arbitrary RowParsers with its apply method.

    import com.lucidchart.open.relate.RowParser
    
    val rowParser = (row: SqlResult) =>
      (row.long("id"), row.string("name"))
    }
  5. def SQL(stmt: String): ExpandableQuery

    Permalink

    Create a SQL query with the provided statement

    Create a SQL query with the provided statement

    stmt

    the SQL statement

    val query = SQL("SELECT * FROM users")
  6. object SqlResult

    Permalink
  7. object SqlResultTypes

    Permalink

    The SqlResultTypes object provides syntactic sugar for RowParser creation.

    The SqlResultTypes object provides syntactic sugar for RowParser creation.

    import com.lucidchart.open.relate._
    import com.lucidchart.open.relate.SqlResultTypes._
    
    val rowParser = RowParser { implicit row =>
      (long("id"), string("name"))
    }

    In this example, declaring "row" as implicit precludes the need to explicitly use the long and string methods on "row".

  8. package interp

    Permalink

Inherited from AnyRef

Inherited from Any

Ungrouped