Parses specified array column.
Parses specified array column.
from 1 to n
import anorm.{ SQL, SqlParser } val t: (String, Array[String]) = SQL"SELECT a, sqlArrayOfString FROM test" .as(SqlParser.str("a") ~ SqlParser.array[String](2) map ( SqlParser.flatten) single)
Parses specified array column.
Parses specified array column.
import anorm.{ SQL, SqlParser } val t: (String, Array[String]) = SQL"SELECT a, sqlArrayOfString FROM test" .as(SqlParser.str("a") ~ SqlParser.array[String]("sqlArrayOfString") map ( SqlParser.flatten) single)
Parses specified column as binary stream.
Parses specified column as binary stream.
import java.io.InputStream import anorm.{ SQL, SqlParser } val parser = SqlParser.str(1) ~ SqlParser.binaryStream(2) val file: (String, InputStream) = SQL("SELECT name, data FROM files"). as(parser.single)
Parses specified column as binary stream.
Parses specified column as binary stream.
import java.io.InputStream import anorm.{ SQL, SqlParser } val parser = SqlParser.str("name") ~ SqlParser.binaryStream("data") val file: (String, InputStream) = SQL("SELECT name, data FROM files"). as(parser.single)
Parses specified column as boolean.
Parses specified column as boolean.
from 1 to n
import anorm.{ SQL, SqlParser } val t: (Boolean, String) = SQL("SELECT a, b FROM test") .as(SqlParser.bool(1) ~ SqlParser.str("b") map ( SqlParser.flatten) single)
Parses specified column as boolean.
Parses specified column as boolean.
import anorm.{ SQL, SqlParser } val t: (Boolean, String) = SQL("SELECT a, b FROM test") .as(SqlParser.bool("a") ~ SqlParser.str("b") map ( SqlParser.flatten) single)
Parses specified column as byte.
Parses specified column as byte.
from 1 to n
import anorm.{ SQL, SqlParser } val t: (Byte, String) = SQL("SELECT a, b FROM test") .as(SqlParser.byte(1) ~ SqlParser.str("b") map ( SqlParser.flatten) single)
Parses specified column as byte.
Parses specified column as byte.
import anorm.{ SQL, SqlParser } val t: (Byte, String) = SQL("SELECT a, b FROM test") .as(SqlParser.byte("a") ~ SqlParser.str("b") map ( SqlParser.flatten) single)
Parses specified column as binary stream.
Parses specified column as binary stream.
import anorm.{ SQL, SqlParser } val parser = SqlParser.str(1) ~ SqlParser.byteArray(2) val file: (String, Array[Byte]) = SQL("SELECT name, data FROM files"). as(parser.single)
Parses specified column as binary stream.
Parses specified column as binary stream.
import anorm.{ SQL, SqlParser } val parser = SqlParser.str("name") ~ SqlParser.byteArray("data") val file: (String, Array[Byte]) = SQL("SELECT name, data FROM files"). as(parser.single)
Parses specified column as date.
Parses specified column as date.
from 1 to n
import anorm.{ SQL, SqlParser } val t: (Date, String) = SQL("SELECT a, b FROM test") .as(SqlParser.date(1) ~ SqlParser.str("b") map ( SqlParser.flatten) single)
Parses specified column as date.
Parses specified column as date.
import anorm.{ SQL, SqlParser } val t: (Date, String) = SQL("SELECT a, b FROM test") .as(SqlParser.date("a") ~ SqlParser.str("b") map ( SqlParser.flatten) single)
Parses specified column as double.
Parses specified column as double.
from 1 to n
import anorm.{ SQL, SqlParser } val t: (Double, String) = SQL("SELECT a, b FROM test") .as(SqlParser.double(1) ~ SqlParser.str("b") map ( SqlParser.flatten) single)
Parses specified column as double.
Parses specified column as double.
import anorm.{ SQL, SqlParser } val t: (Double, String) = SQL("SELECT a, b FROM test") .as(SqlParser.double("a") ~ SqlParser.str("b") map ( SqlParser.flatten) single)
Flatten columns tuple-like.
Flatten columns tuple-like.
import anorm.SQL import anorm.SqlParser.{ long, str, int } val tuple: (Long, String, Int) = SQL("SELECT a, b, c FROM Test"). as(long("a") ~ str("b") ~ int("c") map (SqlParser.flatten) single)
Parses specified column as float.
Parses specified column as float.
from 1 to n
import anorm.{ SQL, SqlParser } val t: (Float, String) = SQL("SELECT a, b FROM test") .as(SqlParser.float(1) ~ SqlParser.str("b") map ( SqlParser.flatten) single)
Parses specified column as float.
Parses specified column as float.
import anorm.{ SQL, SqlParser } val t: (Float, String) = SQL("SELECT a, b FROM test") .as(SqlParser.float("a") ~ SqlParser.str("b") map ( SqlParser.flatten) single)
Returns row parser for column at given position
.
Returns row parser for column at given position
.
Column position, from 1 to n
import anorm.SQL import anorm.SqlParser.get val res: (Float, String) = // parsing columns #1 & #3 SQL("SELECT * FROM Test").as(get[String](1) ~ get[Float](3) map { case str ~ f => (f -> str) } *)
Returns row parser for column with given name
.
Returns row parser for column with given name
.
Column name
import anorm.SQL import anorm.SqlParser.get val title: String = SQL("SELECT title FROM Books"). as(get[String]("title").single)
Parses specified column as integer.
Parses specified column as integer.
from 1 to n
import anorm.{ SQL, SqlParser } val t: (Int, String) = SQL("SELECT a, b FROM test") .as(SqlParser.int(1) ~ SqlParser.str("b") map ( SqlParser.flatten) single)
Parses specified column as integer.
Parses specified column as integer.
import anorm.{ SQL, SqlParser } val t: (Int, String) = SQL("SELECT a, b FROM test") .as(SqlParser.int("a") ~ SqlParser.str("b") map ( SqlParser.flatten) single)
Parses specified array column as list.
Parses specified array column as list.
from 1 to n
import anorm.{ SQL, SqlParser } val t: (String, List[String]) = SQL("SELECT a, sqlArrayOfString FROM test") .as(SqlParser.str("a") ~ SqlParser.list(2) map ( SqlParser.flatten) single)
Parses specified array column as list.
Parses specified array column as list.
import anorm.{ SQL, SqlParser } val t: (String, List[String]) = SQL("SELECT a, sqlArrayOfString FROM test") .as(SqlParser.str("a") ~ SqlParser.list("sqlArrayOfString") map ( SqlParser.flatten) single)
Parses specified column as long.
Parses specified column as long.
from 1 to n
import anorm.{ SQL, SqlParser } val t: (Long, String) = SQL("SELECT a, b FROM test") .as(SqlParser.long(1) ~ SqlParser.str("b") map ( SqlParser.flatten) single)
Parses specified column as long.
Parses specified column as long.
import anorm.{ SQL, SqlParser } val t: (Long, String) = SQL("SELECT a, b FROM test") .as(SqlParser.long("a") ~ SqlParser.str("b") map ( SqlParser.flatten) single)
Returns row parser which true if specified column
is found
and matching expected value
.
Returns row parser which true if specified column
is found
and matching expected value
.
import anorm.SQL import anorm.SqlParser.matches val m: Boolean = SQL("SELECT * FROM table").as(matches("a", 1.2f).single) // true if column |a| is found and matching 1.2f, otherwise false
true if matches, or false if not
Returns parser for a scalar not-null value.
Returns parser for a scalar not-null value.
val count = SQL("select count(*) from Country").as(scalar[Long].single)
Parses specified column as short.
Parses specified column as short.
from 1 to n
import anorm.{ SQL, SqlParser } val t: (Short, String) = SQL("SELECT a, b FROM test") .as(SqlParser.short(1) ~ SqlParser.str("b") map ( SqlParser.flatten) single)
Parses specified column as short.
Parses specified column as short.
import anorm.{ SQL, SqlParser } val t: (Short, String) = SQL("SELECT a, b FROM test") .as(SqlParser.short("a") ~ SqlParser.str("b") map ( SqlParser.flatten) single)
Parses specified column as string.
Parses specified column as string.
from 1 to n
import anorm.{ SQL, SqlParser } val t: (Float, String) = SQL("SELECT a, b FROM test") .as(SqlParser.float("a") ~ SqlParser.str(1) map ( SqlParser.flatten) single)
Parses specified column as string.
Parses specified column as string.
import anorm.{ SQL, SqlParser } val t: (Float, String) = SQL("SELECT a, b FROM test") .as(SqlParser.float("a") ~ SqlParser.str("b") map ( SqlParser.flatten) single)
Returns row parser which throws exception if specified column
is either
missing or not matching expected value
.
Returns row parser which throws exception if specified column
is either
missing or not matching expected value
.
If row contains described column, do nothing (Unit).
import anorm.SQL import anorm.SqlParser.{ contains, str } val parser = contains("a", true) ~ str("b") map { case () ~ str => str } SQL("SELECT * FROM table").as(parser.+) // Throws exception if there no |a| column or if |a| is not true, // otherwise parses as non-empty list of |b| strings.
(Since version 2.3.0) Use matches
(Since version 2.3.3) Use get with alias