Skip to content

Commit

Permalink
added and/or operators for Sql data type
Browse files Browse the repository at this point in the history
  • Loading branch information
yisraelU committed Feb 15, 2022
1 parent cbc9d7a commit e2da8e6
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions core/src/main/scala/zio/jdbc/Sql.scala
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
*/
package zio.jdbc

import zio.jdbc.Sql.intersperse
import zio.{ Chunk, ChunkBuilder }

/**
Expand Down Expand Up @@ -93,7 +94,14 @@ final class Sql[+A](

def withDecode[B](f: ZResultSet => B): Sql[B] =
Sql(segments, f)

def and(right: SqlFragment*)(implicit ev: A <:< ZResultSet): SqlFragment =
self ++ intersperse(Sql.and, right)

def or(right: SqlFragment*)(implicit ev: A <:< ZResultSet): SqlFragment =
self ++ intersperse(Sql.or, right)
}

object Sql {
val empty: SqlFragment = Sql(Chunk.empty, identity(_))

Expand Down Expand Up @@ -128,4 +136,9 @@ object Sql {
private[jdbc] val rparen = sql""")"""
private[jdbc] val comma = sql""","""
private[jdbc] val nullLiteral = sql"""NULL"""
private[jdbc] val and = sql"""AND"""
private[jdbc] val or = sql"""OR"""
private[jdbc] val not = sql"""NOT"""
private[jdbc] val in = sql"""IN"""

}

0 comments on commit e2da8e6

Please sign in to comment.