Skip to content

Commit

Permalink
Merge pull request #1532 from tpolecat/merge-with-master
Browse files Browse the repository at this point in the history
Merge with master
  • Loading branch information
tpolecat authored Aug 30, 2021
2 parents d9c2ed4 + 3b5c15c commit d99ba2b
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 11 deletions.
9 changes: 6 additions & 3 deletions modules/core/src/main/scala/doobie/syntax/string.scala
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ package doobie.syntax
import cats.syntax.all._

import doobie.syntax.SqlInterpolator.SingleFragment
import doobie.util.Put
import doobie.util.{Put, Write}
import doobie.util.fragment.{Elem, Fragment}
import doobie.util.pos.Pos

Expand Down Expand Up @@ -52,9 +52,12 @@ object SqlInterpolator {
object SingleFragment {
val empty = SingleFragment(Fragment.empty)

implicit def fromPut[A](a: A)(implicit put: Put[A]): SingleFragment[A] = SingleFragment(Fragment("?", Elem.Arg(a, put) :: Nil, None))
implicit def fromPutOption[A](a: Option[A])(implicit put: Put[A]): SingleFragment[A] = SingleFragment(Fragment("?", Elem.Opt(a, put) :: Nil, None))
@deprecated("Use fromWrite", since = "0.13.5")
def fromPut[A](a: A)(implicit put: Put[A]): SingleFragment[A] = SingleFragment(Fragment("?", Elem.Arg(a, put) :: Nil, None))
@deprecated("Use fromWrite", since = "0.13.5")
def fromPutOption[A](a: Option[A])(implicit put: Put[A]): SingleFragment[A] = SingleFragment(Fragment("?", Elem.Opt(a, put) :: Nil, None))
implicit def fromFragment(fr: Fragment): SingleFragment[Nothing] = SingleFragment(fr)
implicit def fromWrite[A](a: A)(implicit write: Write[A]): SingleFragment[A] = SingleFragment(write.toFragment(a))
}
}

Expand Down
9 changes: 4 additions & 5 deletions modules/core/src/test/scala/doobie/syntax/StringSuite.scala
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,10 @@ class StringSuite extends munit.FunSuite {
assertEquals(q.sql, "foo bar ?")
}

test("sql interpolator should not support product params") {
Write[(Int, String)]
compileErrors {
""" val a = (1, "two"); sql"foo $a bar baz".query[Int] """
}
test("sql interpolator should support product params") {
val a = (1, "two")
val q = sql"foo bar $a".query[Int]
assertEquals(q.sql, "foo bar ?,?")
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ import fs2.Stream
import io.getquill.NamingStrategy
import io.getquill.context.sql.idiom.SqlIdiom
import io.getquill.context.StreamingContext
import java.sql.{ Connection }
import scala.util.Success
import java.sql.Connection
import scala.util.{ Success, Try }
import doobie.enumerated.AutoGeneratedKeys
import io.getquill.ReturnAction.{ ReturnColumns, ReturnNothing, ReturnRecord }
import io.getquill.ReturnAction
Expand Down Expand Up @@ -149,7 +149,7 @@ trait DoobieContextBase[Dialect <: SqlIdiom, Naming <: NamingStrategy]
override def close(): Unit = ()

// Nothing to do here either.
override def probe(statement: String) = Success(())
override def probe(statement: String): Try[_] = Success(())

// We can't implement this but it won't be called anyway so ¯\_(ツ)_/¯
override protected def withConnection[A](f: Connection => ConnectionIO[A]): ConnectionIO[A] = ???
Expand Down

0 comments on commit d99ba2b

Please sign in to comment.