diff --git a/build.sbt b/build.sbt index b8c87163..606b709e 100644 --- a/build.sbt +++ b/build.sbt @@ -69,7 +69,7 @@ def mainDependencies(scalaVersion: String) = { } Seq ( "org.scala-lang" % "scala-reflect" % scalaVersion, - "com.typesafe.slick" %% "slick" % "3.5.0-M2", + "com.typesafe.slick" %% "slick" % "3.5.0-M3", "org.postgresql" % "postgresql" % "42.6.0", "org.scala-lang.modules" %% "scala-collection-compat" % "2.9.0", "org.slf4j" % "slf4j-simple" % "2.0.7" % "provided", diff --git a/core/src/main/scala/com/github/tminglei/slickpg/ExPostgresProfile.scala b/core/src/main/scala/com/github/tminglei/slickpg/ExPostgresProfile.scala index 79fad696..a3b98634 100644 --- a/core/src/main/scala/com/github/tminglei/slickpg/ExPostgresProfile.scala +++ b/core/src/main/scala/com/github/tminglei/slickpg/ExPostgresProfile.scala @@ -78,14 +78,14 @@ trait ExPostgresProfile extends JdbcProfile with PostgresProfile with Logging { *************************************************************************/ class ExtPostgresQueryBuilder(tree: Node, state: CompilerState) extends PostgresQueryBuilder(tree, state) { - import slick.util.MacroSupport.macroSupportInterpolation - override def expr(n: Node, skipParens: Boolean = false) = n match { + import slick.util.QueryInterpolator.queryInterpolator + override def expr(n: Node): Unit = n match { case agg.AggFuncExpr(func, params, orderBy, filter, distinct, forOrdered) => if (func == Library.CountAll) b"${func.name}" else { b"${func.name}(" if (distinct) b"distinct " - b.sep(params, ",")(expr(_, true)) + b.sep(params, ",")(expr(_, skipParens = true)) if (orderBy.nonEmpty && !forOrdered) buildOrderByClause(orderBy) b")" } @@ -94,14 +94,14 @@ trait ExPostgresProfile extends JdbcProfile with PostgresProfile with Logging { case window.WindowFuncExpr(aggFuncExpr, partitionBy, orderBy, frameDef) => expr(aggFuncExpr) b" over (" - if(partitionBy.nonEmpty) { b" partition by "; b.sep(partitionBy, ",")(expr(_, true)) } + if(partitionBy.nonEmpty) { b" partition by "; b.sep(partitionBy, ",")(expr(_, skipParens = true)) } if(orderBy.nonEmpty) buildOrderByClause(orderBy) - frameDef.map { + frameDef.foreach { case (mode, start, Some(end)) => b" $mode between $start and $end" case (mode, start, None) => b" $mode $start" } b")" - case _ => super.expr(n, skipParens) + case _ => super.expr(n) } } diff --git a/src/test/scala/com/github/tminglei/slickpg/PgTsqlSupportSuite.scala b/src/test/scala/com/github/tminglei/slickpg/PgTsqlSupportSuite.scala deleted file mode 100644 index a1691512..00000000 --- a/src/test/scala/com/github/tminglei/slickpg/PgTsqlSupportSuite.scala +++ /dev/null @@ -1,48 +0,0 @@ -package com.github.tminglei.slickpg - -import java.util.UUID - -import org.scalatest.funsuite.AnyFunSuite -import slick.basic.StaticDatabaseConfig - -/* - * NOTE: to check it, we need move `MyPostgresDriver.scala` from test folder to main folder - */ -//@StaticDatabaseConfig("file:src/test/resources/application.conf#tsql") -class PgTsqlSupportSuite extends AnyFunSuite { - - test("tsql support - simple") { - pending -// import MyPostgresProfile.plainAPI._ -// -// /* -// CREATE TABLE tsql_test_simple -// ( -// id bigint NOT NULL, -// json jsonb, -// path ltree, -// CONSTRAINT tsql_test_simple_pkey PRIMARY KEY (id) -// ) -// */ -// // Will SUCCEED -// val sql: DBIO[Seq[(Long, JsonString, LTree)]] = tsql"select * from tsql_test_simple" -// -// /* -// CREATE TABLE tsql_test -// ( -// id bigint NOT NULL, -// uuid_arr uuid[] NOT NULL, -// map hstore NOT NULL, -// json jsonb NOT NULL, -// path ltree NOT NULL, -// float_range numrange NOT NULL, -// long_arr bigint[], -// CONSTRAINT tsql_test_pkey PRIMARY KEY (id) -// ) -// */ -// // Will FAIL, because of: could not find implicit value for parameter e: slick.jdbc.GetResult[(Long, Seq[A], scala.collection.immutable.Map[A,B], com.github.tminglei.slickpg.JsonString, com.github.tminglei.slickpg.LTree, com.github.tminglei.slickpg.Range[T], Seq[A])] -// // NOTE: `pg type map to scala type with type parameter` was not supported by `slick` -//// val sql2: DBIO[Seq[(Long, Seq[UUID], Map[String, String], JsonString, LTree, Range[Float], Seq[Long])]] = -//// tsql"select * from tsql_test" - } -}