Trait/Object

anorm

RowParser

Related Docs: object RowParser | package anorm

Permalink

trait RowParser[+A] extends (Row) ⇒ SqlResult[A]

Self Type
RowParser[A]
Source
SqlParser.scala
Linear Supertypes
(Row) ⇒ SqlResult[A], AnyRef, Any
Known Subclasses
Ordering
  1. Alphabetic
  2. By inheritance
Inherited
  1. RowParser
  2. Function1
  3. AnyRef
  4. Any
  1. Hide All
  2. Show all
Visibility
  1. Public
  2. All

Abstract Value Members

  1. abstract def apply(v1: Row): SqlResult[A]

    Permalink
    Definition Classes
    Function1

Concrete Value Members

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

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

    Permalink
    Definition Classes
    AnyRef → Any
  3. def *: ResultSetParser[List[A]]

    Permalink

    Returns possibly empty list parsed from result.

    Returns possibly empty list parsed from result.

    val price = 125
    SQL"SELECT name FROM item WHERE price < \$price".as(scalar[String].*)
  4. def +: ResultSetParser[List[A]]

    Permalink

    Returns non empty list parse from result, or raise error if there is no result.

    Returns non empty list parse from result, or raise error if there is no result.

    import anorm.SQL
    import anorm.SqlParser.str
    
    val parser = str("title") ~ str("descr")
    SQL("SELECT title, descr FROM pages").as(parser.+) // at least 1 page
  5. def <~[B](p: RowParser[B]): RowParser[A]

    Permalink

    Combines this current parser with the one given as argument p, if and only if the current parser can first successfully parse a row, without keeping the values of the parser p.

    Combines this current parser with the one given as argument p, if and only if the current parser can first successfully parse a row, without keeping the values of the parser p.

    import anorm.{ SQL, SqlParser }, SqlParser.{ int, str }
    
    val Int = SQL("SELECT * FROM test").
      as((int("id") <~ str("val")).single)
    // row has to have an int column 'id' and a string 'val' one,
    // keeping only 'id' in result
  6. final def ==(arg0: Any): Boolean

    Permalink
    Definition Classes
    AnyRef → Any
  7. def >>[B](f: (A) ⇒ RowParser[B]): RowParser[B]

    Permalink

    Alias for flatMap

  8. def ?: RowParser[Option[A]]

    Permalink

    Returns a row parser for optional column, that will turn missing or null column as None.

  9. def andThen[A](g: (SqlResult[A]) ⇒ A): (Row) ⇒ A

    Permalink
    Definition Classes
    Function1
    Annotations
    @unspecialized()
  10. final def asInstanceOf[T0]: T0

    Permalink
    Definition Classes
    Any
  11. def clone(): AnyRef

    Permalink
    Attributes
    protected[java.lang]
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  12. def collect[B](otherwise: String)(f: PartialFunction[A, B]): RowParser[B]

    Permalink

    Returns parser which collects information from already parsed row data using f.

    Returns parser which collects information from already parsed row data using f.

    otherwise

    Message returned as error if nothing can be collected using f.

    f

    Collecting function

  13. def compose[A](g: (A) ⇒ Row): (A) ⇒ SqlResult[A]

    Permalink
    Definition Classes
    Function1
    Annotations
    @unspecialized()
  14. final def eq(arg0: AnyRef): Boolean

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

    Permalink
    Definition Classes
    AnyRef → Any
  16. def finalize(): Unit

    Permalink
    Attributes
    protected[java.lang]
    Definition Classes
    AnyRef
    Annotations
    @throws( classOf[java.lang.Throwable] )
  17. def flatMap[B](k: (A) ⇒ RowParser[B]): RowParser[B]

    Permalink
  18. final def getClass(): Class[_]

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

    Permalink
    Definition Classes
    AnyRef → Any
  20. final def isInstanceOf[T0]: Boolean

    Permalink
    Definition Classes
    Any
  21. def map[B](f: (A) ⇒ B): RowParser[B]

    Permalink

    Returns a parser that will apply given function f to the result of this first parser.

    Returns a parser that will apply given function f to the result of this first parser. If the current parser is not successful, the new one will return encountered Error.

    f

    Function applied on the successful parser result

    import anorm.{ RowParser, SQL, SqlParser }
    val parser: RowParser[Int] = SqlParser.str("col").map(_.length)
    // Prepares a parser that first get 'col' string value,
    // an then returns the length of that
  22. final def ne(arg0: AnyRef): Boolean

    Permalink
    Definition Classes
    AnyRef
  23. final def notify(): Unit

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

    Permalink
    Definition Classes
    AnyRef
  25. def single: ResultSetParser[A]

    Permalink

    Returns a result set parser expecting exactly one row to parse.

    Returns a result set parser expecting exactly one row to parse.

    val b: Boolean = SQL("SELECT flag FROM Test WHERE id = :id").
      on("id" -> 1).as(scalar[Boolean].single)
    See also

    #singleOpt

  26. def singleOpt: ResultSetParser[Option[A]]

    Permalink

    Returns a result set parser for none or one parsed row.

    Returns a result set parser for none or one parsed row.

    val name: Option[String] =
      SQL("SELECT name FROM Country WHERE lang = :lang")
      .on("lang" -> "notFound").as(scalar[String].singleOpt)
  27. final def synchronized[T0](arg0: ⇒ T0): T0

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

    Permalink
    Definition Classes
    Function1 → AnyRef → Any
  29. final def wait(): Unit

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

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

    Permalink
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  32. def |[B >: A](p: RowParser[B]): RowParser[B]

    Permalink
  33. def ~[B](p: RowParser[B]): RowParser[~[A, B]]

    Permalink

    Combines this parser on the left of the parser p given as argument.

    Combines this parser on the left of the parser p given as argument.

    p

    Parser on the right

    val populations: List[String ~ Int] =
      SQL("SELECT * FROM Country").as((str("name") ~ int("population")).*)
  34. def ~>[B](p: RowParser[B]): RowParser[B]

    Permalink

    Combines this current parser with the one given as argument p, if and only if the current parser can first/on left side successfully parse a row, without keeping these values in parsed result.

    Combines this current parser with the one given as argument p, if and only if the current parser can first/on left side successfully parse a row, without keeping these values in parsed result.

    import anorm.{ SQL, SqlParser }, SqlParser.{ int, str }
    
    val String = SQL("SELECT * FROM test").
      as((int("id") ~> str("val")).single)
    // row has to have an int column 'id' and a string 'val' one,
    // keeping only 'val' in result

Inherited from (Row) ⇒ SqlResult[A]

Inherited from AnyRef

Inherited from Any

Ungrouped