Skip to content

Commit

Permalink
#407 - build slick/slick-pg 2.10 to scala 2.12
Browse files Browse the repository at this point in the history
  • Loading branch information
tminglei committed May 19, 2018
1 parent 374e047 commit f48dc04
Show file tree
Hide file tree
Showing 16 changed files with 94 additions and 73 deletions.
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ Slick-pg
- composite type (`basic`)


** _tested on `PostgreSQL` `v9.4` with `Slick` `v2.1.0`._
** _tested on `PostgreSQL` `v9.6` with `Slick` `v2.1.0`._


Usage
Expand Down Expand Up @@ -124,16 +124,16 @@ Install
-------
To use `slick-pg` in [sbt](http://www.scala-sbt.org/ "slick-sbt") project, add the following to your project file:
```scala
libraryDependencies += "com.github.tminglei" %% "slick-pg" % "0.8.2"
libraryDependencies += "com.github.tminglei" %% "slick-pg" % "0.8.6"
```


Or, in [maven](http://maven.apache.org/ "maven") project, you can add `slick-pg` to your `pom.xml` like this:
```xml
<dependency>
<groupId>com.github.tminglei</groupId>
<artifactId>slick-pg_2.10</artifactId>
<version>0.8.2</version>
<artifactId>slick-pg_2.12</artifactId>
<version>0.8.6</version>
</dependency>
```

Expand Down
20 changes: 10 additions & 10 deletions project/Build.scala
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@ object SlickPgBuild extends Build {
organizationName := "slick-pg",
organization := "com.github.tminglei",
name := "slick-pg",
version := "0.8.5",
version := "0.8.6",

scalaVersion := "2.11.5",
crossScalaVersions := Seq("2.11.5", "2.10.4"),
scalaVersion := "2.12.6",
crossScalaVersions := Seq("2.12.6", "2.11.12", "2.10.7"),
scalacOptions ++= Seq("-deprecation", "-feature",
"-language:implicitConversions",
"-language:reflectiveCalls",
Expand Down Expand Up @@ -61,7 +61,7 @@ object SlickPgBuild extends Build {
def mainDependencies(scalaVersion: String) = {
val extractedLibs = CrossVersion.partialVersion(scalaVersion) match {
case Some((2, scalaMajor)) if scalaMajor >= 11 =>
Seq("org.scala-lang.modules" %% "scala-parser-combinators" % "1.0.1" % "provided")
Seq("org.scala-lang.modules" %% "scala-parser-combinators" % "1.1.0" % "provided")
case _ =>
Seq()
}
Expand All @@ -82,21 +82,21 @@ object SlickPgBuild extends Build {
)
)

val json4sVersion = "3.2.10"
val json4sVersion = "3.2.11"
lazy val slickPgProject = Project(id = "slick-pg", base = file("."),
settings = Defaults.coreDefaultSettings ++ commonSettings ++ Seq(
name := "slick-pg",
description := "Slick extensions for PostgreSQL",
libraryDependencies := mainDependencies(scalaVersion.value) ++ Seq(
"joda-time" % "joda-time" % "2.4" % "provided",
"org.joda" % "joda-convert" % "1.7" % "provided",
"joda-time" % "joda-time" % "2.9.9" % "provided",
"org.joda" % "joda-convert" % "2.0.1" % "provided",
"org.threeten" % "threetenbp" % "1.0" % "provided",
"org.json4s" %% "json4s-ast" % json4sVersion % "provided",
"org.json4s" %% "json4s-core" % json4sVersion % "provided",
"org.json4s" %% "json4s-native" % json4sVersion % "test",
"com.typesafe.play" %% "play-json" % "2.3.0" % "provided",
"io.spray" %% "spray-json" % "1.3.1" % "provided",
"io.argonaut" %% "argonaut" % "6.0.4" % "provided",
"com.typesafe.play" %% "play-json" % "2.6.9" % "provided",
"io.spray" %% "spray-json" % "1.3.4" % "provided",
"io.argonaut" %% "argonaut" % "6.2.1" % "provided",
"com.vividsolutions" % "jts" % "1.13" % "provided"
)
)
Expand Down
2 changes: 1 addition & 1 deletion project/build.properties
Original file line number Diff line number Diff line change
@@ -1 +1 @@
sbt.version=0.13.5
sbt.version=0.13.16
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ trait PgArgonautSupport extends json.PgJsonExtensions with utils.PgCommonJdbcTyp
implicit val argonautJsonTypeMapper =
new GenericJdbcType[Json](
pgjson,
(s) => s.parse.toOption.getOrElse(jNull),
(s) => s.parseOption.getOrElse(jNull),
(v) => v.nospaces,
hasLiteralForm = false
)
Expand All @@ -35,7 +35,7 @@ trait PgArgonautSupport extends json.PgJsonExtensions with utils.PgCommonJdbcTyp

implicit class PgJsonPositionedResult(r: PositionedResult) {
def nextJson() = nextJsonOption().getOrElse(jNull)
def nextJsonOption() = r.nextStringOption().flatMap(_.parse.toOption)
def nextJsonOption() = r.nextStringOption().flatMap(_.parseOption)
}

implicit object SetJson extends SetParameter[Json] {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ class PgArraySupportTest {
case class Institution(value: Long)
case class MarketFinancialProduct(value: String)

object MyPostgresDriver1 extends PostgresDriver with PgArraySupport {
trait MyPostgresDriver1 extends PostgresDriver with PgArraySupport {
override lazy val Implicit = new Implicits with ArrayImplicits with MyArrayImplicitsPlus {}
override val simple = new SimpleQL with ArrayImplicits with MyArrayImplicitsPlus {}

Expand All @@ -34,6 +34,7 @@ class PgArraySupportTest {
fromString(identity)(_).orNull, mkString(identity))
}
}
object MyPostgresDriver1 extends MyPostgresDriver1

//////////////////////////////////////////////////////////////////////////
import MyPostgresDriver1.simple._
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ object PgCompositeSupportTest {
) extends Struct

//-------------------------------------------------------------
object MyPostgresDriver1 extends PostgresDriver with PgCompositeSupport with PgArraySupport with utils.PgCommonJdbcTypes {
trait MyPostgresDriver1 extends PostgresDriver with PgCompositeSupport with PgArraySupport with utils.PgCommonJdbcTypes {
override lazy val Implicit = new Implicits with ArrayImplicits with CompositeImplicits {}
override val simple = new SimpleQL with ArrayImplicits with CompositeImplicits {}

Expand Down Expand Up @@ -87,6 +87,7 @@ object PgCompositeSupportTest {
implicit val composite3ArrayOptSetParameter = createCompositeOptionArraySetParameter[Composite3]("composite3")
}
}
object MyPostgresDriver1 extends MyPostgresDriver1
}

///
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ class PgEnumSupportTest {
import WeekDays._
import Rainbows._

object MyPostgresDriver1 extends PostgresDriver with PgEnumSupport {
trait MyPostgresDriver1 extends PostgresDriver with PgEnumSupport {
override lazy val Implicit = new Implicits with MyEnumImplicits {}
override val simple = new SimpleQL with MyEnumImplicits {}

Expand All @@ -34,6 +34,7 @@ class PgEnumSupportTest {
implicit val rainbowOptionColumnExtensionMethodsBuilder = createEnumOptionColumnExtensionMethodsBuilder(Rainbows)
}
}
object MyPostgresDriver1 extends MyPostgresDriver1

////////////////////////////////////////////////////////////////////
import MyPostgresDriver1.simple._
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,18 +9,21 @@ import scala.util.Try
class PgArgonautSupportTest {
import scala.slick.driver.PostgresDriver

object MyPostgresDriver extends PostgresDriver
trait MyPostgresDriver extends PostgresDriver
with PgArgonautSupport
with array.PgArrayJdbcTypes {
override val pgjson = "jsonb"

override lazy val Implicit = new Implicits with JsonImplicits
override val simple = new Implicits with SimpleQL with JsonImplicits {
override lazy val Implicit = new Implicits with JsonImplicits {}
override val simple = new Simple {}

trait Simple extends Implicits with SimpleQL with JsonImplicits {
implicit val strListTypeMapper = new SimpleArrayJdbcType[String]("text").to(_.toList)
}

val plainImplicits = new Implicits with ArgonautJsonPlainImplicits
val plainImplicits = new Implicits with ArgonautJsonPlainImplicits {}
}
object MyPostgresDriver extends MyPostgresDriver

///
import MyPostgresDriver.simple._
Expand All @@ -39,9 +42,9 @@ class PgArgonautSupportTest {

//------------------------------------------------------------------------------

val testRec1 = JsonBean(33L, """ { "a":101, "b":"aaa", "c":[3,4,5,9] } """.parse.toOption.getOrElse(jNull))
val testRec2 = JsonBean(35L, """ [ {"a":"v1","b":2}, {"a":"v5","b":3} ] """.parse.toOption.getOrElse(jNull))
val testRec3 = JsonBean(37L, """ ["a", "b"] """.parse.toOption.getOrElse(jNull))
val testRec1 = JsonBean(33L, """ { "a":101, "b":"aaa", "c":[3,4,5,9] } """.parseOption.getOrElse(jNull))
val testRec2 = JsonBean(35L, """ [ {"a":"v1","b":2}, {"a":"v5","b":3} ] """.parseOption.getOrElse(jNull))
val testRec3 = JsonBean(37L, """ ["a", "b"] """.parseOption.getOrElse(jNull))

@Test
def testJsonFunctions(): Unit = {
Expand All @@ -51,8 +54,8 @@ class PgArgonautSupportTest {

JsonTests forceInsertAll (testRec1, testRec2, testRec3)

val json1 = """ {"a":"v1","b":2} """.parse.toOption.getOrElse(jNull)
val json2 = """ {"a":"v5","b":3} """.parse.toOption.getOrElse(jNull)
val json1 = """ {"a":"v1","b":2} """.parseOption.getOrElse(jNull)
val json2 = """ {"a":"v5","b":3} """.parseOption.getOrElse(jNull)

val q0 = JsonTests.filter(_.id === testRec2.id.bind).map(_.json)
println(s"[argonaut] sql0 = ${q0.selectStatement}")
Expand Down Expand Up @@ -103,11 +106,11 @@ class PgArgonautSupportTest {
println(s"[argonaut] 'objectKeys' sql = ${q51.selectStatement}")
assertEquals("a", q51.first)

val q6 = JsonTests.filter(_.json @> """ {"b":"aaa"} """.parse.toOption.getOrElse(jNull)).map(_.id)
val q6 = JsonTests.filter(_.json @> """ {"b":"aaa"} """.parseOption.getOrElse(jNull)).map(_.id)
println(s"[argonaut] '@>' sql = ${q6.selectStatement}")
assertEquals(33L, q6.first)

val q7 = JsonTests.filter(""" {"b":"aaa"} """.parse.toOption.getOrElse(jNull) <@: _.json).map(_.id)
val q7 = JsonTests.filter(""" {"b":"aaa"} """.parseOption.getOrElse(jNull) <@: _.json).map(_.id)
println(s"[argonaut] '<@' sql = ${q7.selectStatement}")
assertEquals(33L, q7.first)

Expand Down Expand Up @@ -141,7 +144,7 @@ class PgArgonautSupportTest {
Try { JsonTests.ddl drop }
Try { JsonTests.ddl create }

val jsonBean = JsonBean(37L, """ { "a":101, "b":"aaa", "c":[3,4,5,9] } """.parse.toOption.getOrElse(jNull))
val jsonBean = JsonBean(37L, """ { "a":101, "b":"aaa", "c":[3,4,5,9] } """.parseOption.getOrElse(jNull))

(Q.u + "insert into \"JsonTest4\" values(" +? jsonBean.id + ", " +? jsonBean.json + ")").execute

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,16 @@ import scala.util.Try
class PgDate2SupportTest {
import scala.slick.driver.PostgresDriver

object MyPostgresDriver extends PostgresDriver
trait MyPostgresDriver extends PostgresDriver
with PgDate2Support {

override lazy val Implicit = new Implicits with DateTimeImplicits
override val simple = new Implicits with SimpleQL with DateTimeImplicits
override lazy val Implicit = new Implicits with DateTimeImplicits {}
override val simple = new Implicits with SimpleQL with DateTimeImplicits {}

///
val plainImplicits = new Implicits with Date2DateTimePlainImplicits
val plainImplicits = new Implicits with Date2DateTimePlainImplicits {}
}
object MyPostgresDriver extends MyPostgresDriver

///
import MyPostgresDriver.simple._
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,16 @@ import scala.util.Try
class PgDate2bpSupportTest {
import scala.slick.driver.PostgresDriver

object MyPostgresDriver extends PostgresDriver
trait MyPostgresDriver extends PostgresDriver
with PgDateSupport2bp {

override lazy val Implicit = new Implicits with DateTimeImplicits
override val simple = new Implicits with SimpleQL with DateTimeImplicits
override lazy val Implicit = new Implicits with DateTimeImplicits {}
override val simple = new Implicits with SimpleQL with DateTimeImplicits {}

///
val plainImplicits = new Implicits with BpDateTimePlainImplicits
val plainImplicits = new Implicits with BpDateTimePlainImplicits {}
}
object MyPostgresDriver extends MyPostgresDriver

///
import MyPostgresDriver.simple._
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,16 @@ import scala.util.Try
class PgDateSupportJodaTest {
import scala.slick.driver.PostgresDriver

object MyPostgresDriver extends PostgresDriver
trait MyPostgresDriver extends PostgresDriver
with PgDateSupportJoda {

override lazy val Implicit = new Implicits with DateTimeImplicits
override val simple = new Implicits with SimpleQL with DateTimeImplicits
override lazy val Implicit = new Implicits with DateTimeImplicits {}
override val simple = new Implicits with SimpleQL with DateTimeImplicits {}

///
val plainImplicits = new Implicits with JodaDateTimePlainImplicits
val plainImplicits = new Implicits with JodaDateTimePlainImplicits {}
}
object MyPostgresDriver extends MyPostgresDriver

///
import MyPostgresDriver.simple._
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,21 +9,24 @@ import scala.util.Try
class PgJson4sSupportTest {
import scala.slick.driver.PostgresDriver

object MyPostgresDriver extends PostgresDriver
trait MyPostgresDriver extends PostgresDriver
with PgJson4sSupport
with array.PgArrayJdbcTypes {
/// for json support
override val pgjson = "jsonb"
type DOCType = text.Document
override val jsonMethods = org.json4s.native.JsonMethods

override lazy val Implicit = new Implicits with JsonImplicits
override val simple = new Implicits with SimpleQL with JsonImplicits {
override lazy val Implicit = new Implicits with JsonImplicits {}
override val simple = new Simple {}

trait Simple extends Implicits with SimpleQL with JsonImplicits {
implicit val strListTypeMapper = new SimpleArrayJdbcType[String]("text").to(_.toList)
}

val plainImplicits = new Implicits with Json4sJsonPlainImplicits
val plainImplicits = new Implicits with Json4sJsonPlainImplicits {}
}
object MyPostgresDriver extends MyPostgresDriver

///
import MyPostgresDriver.simple._
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,18 +9,21 @@ import scala.util.Try
class PgPlayJsonSupportTest {
import scala.slick.driver.PostgresDriver

object MyPostgresDriver extends PostgresDriver
trait MyPostgresDriver extends PostgresDriver
with PgPlayJsonSupport
with array.PgArrayJdbcTypes {
override val pgjson = "jsonb"

override lazy val Implicit = new Implicits with JsonImplicits
override val simple = new Implicits with SimpleQL with JsonImplicits {
override lazy val Implicit = new Implicits with JsonImplicits {}
override val simple = new Simple {}

trait Simple extends Implicits with SimpleQL with JsonImplicits {
implicit val strListTypeMapper = new SimpleArrayJdbcType[String]("text").to(_.toList)
}

val plainImplicits = new Implicits with PlayJsonPlainImplicits
val plainImplicits = new Implicits with PlayJsonPlainImplicits {}
}
object MyPostgresDriver extends MyPostgresDriver

///
import MyPostgresDriver.simple._
Expand Down
Loading

0 comments on commit f48dc04

Please sign in to comment.