diff --git a/addons/argonaut/src/main/scala/com/github/tminglei/slickpg/PgArgonautSupport.scala b/addons/argonaut/src/main/scala/com/github/tminglei/slickpg/PgArgonautSupport.scala index 06682205..9116e03c 100644 --- a/addons/argonaut/src/main/scala/com/github/tminglei/slickpg/PgArgonautSupport.scala +++ b/addons/argonaut/src/main/scala/com/github/tminglei/slickpg/PgArgonautSupport.scala @@ -1,6 +1,7 @@ package com.github.tminglei.slickpg -import slick.jdbc.{JdbcType, PositionedResult, PostgresProfile} +import slick.jdbc.{GetResult, JdbcType, PositionedResult, PostgresProfile, SetParameter} + import scala.reflect.classTag trait PgArgonautSupport extends json.PgJsonExtensions with utils.PgCommonJdbcTypes { driver: PostgresProfile => @@ -32,10 +33,10 @@ trait PgArgonautSupport extends json.PgJsonExtensions with utils.PgCommonJdbcTyp hasLiteralForm = false ) - implicit def argonautJsonColumnExtensionMethods(c: Rep[Json]) = { + implicit def argonautJsonColumnExtensionMethods(c: Rep[Json]): JsonColumnExtensionMethods[Json, Json] = { new JsonColumnExtensionMethods[Json, Json](c) } - implicit def argonautJsonOptionColumnExtensionMethods(c: Rep[Option[Json]]) = { + implicit def argonautJsonOptionColumnExtensionMethods(c: Rep[Option[Json]]): JsonColumnExtensionMethods[Json, Option[Json]] = { new JsonColumnExtensionMethods[Json, Option[Json]](c) } } @@ -49,9 +50,9 @@ trait PgArgonautSupport extends json.PgJsonExtensions with utils.PgCommonJdbcTyp } /////////////////////////////////////////////////////////// - implicit val getJson = mkGetResult(_.nextJson()) - implicit val getJsonOption = mkGetResult(_.nextJsonOption()) - implicit val setJson = mkSetParameter[Json](pgjson, _.nospaces) - implicit val setJsonOption = mkOptionSetParameter[Json](pgjson, _.nospaces) + implicit val getJson: GetResult[Json] = mkGetResult(_.nextJson()) + implicit val getJsonOption: GetResult[Option[Json]] = mkGetResult(_.nextJsonOption()) + implicit val setJson: SetParameter[Json] = mkSetParameter[Json](pgjson, _.nospaces) + implicit val setJsonOption: SetParameter[Option[Json]] = mkOptionSetParameter[Json](pgjson, _.nospaces) } } diff --git a/addons/circe-json/src/main/scala/com/github/tminglei/slickpg/PgCirceJsonSupport.scala b/addons/circe-json/src/main/scala/com/github/tminglei/slickpg/PgCirceJsonSupport.scala index 75136333..d7d93067 100644 --- a/addons/circe-json/src/main/scala/com/github/tminglei/slickpg/PgCirceJsonSupport.scala +++ b/addons/circe-json/src/main/scala/com/github/tminglei/slickpg/PgCirceJsonSupport.scala @@ -1,7 +1,8 @@ package com.github.tminglei.slickpg import cats.syntax.either._ -import slick.jdbc.{JdbcType, PositionedResult, PostgresProfile} +import slick.jdbc.{GetResult, JdbcType, PositionedResult, PostgresProfile, SetParameter} + import scala.reflect.classTag trait PgCirceJsonSupport extends json.PgJsonExtensions with utils.PgCommonJdbcTypes { driver: PostgresProfile => @@ -34,11 +35,11 @@ trait PgCirceJsonSupport extends json.PgJsonExtensions with utils.PgCommonJdbcTy hasLiteralForm = false ) - implicit def circeJsonColumnExtensionMethods(c: Rep[Json]) = { + implicit def circeJsonColumnExtensionMethods(c: Rep[Json]): JsonColumnExtensionMethods[Json, Json] = { new JsonColumnExtensionMethods[Json, Json](c) } - implicit def circeJsonOptionColumnExtensionMethods(c: Rep[Option[Json]]) = { + implicit def circeJsonOptionColumnExtensionMethods(c: Rep[Option[Json]]): JsonColumnExtensionMethods[Json, Option[Json]] = { new JsonColumnExtensionMethods[Json, Option[Json]](c) } } @@ -51,9 +52,9 @@ trait PgCirceJsonSupport extends json.PgJsonExtensions with utils.PgCommonJdbcTy def nextJsonOption() = r.nextStringOption().map(parse(_).getOrElse(Json.Null)) } - implicit val getJson = mkGetResult(_.nextJson()) - implicit val getJsonOption = mkGetResult(_.nextJsonOption()) - implicit val setJson = mkSetParameter[Json](pgjson, _.asJson.spaces2) - implicit val setJsonOption = mkOptionSetParameter[Json](pgjson, _.asJson.spaces2) + implicit val getJson: GetResult[Json] = mkGetResult(_.nextJson()) + implicit val getJsonOption: GetResult[Option[Json]] = mkGetResult(_.nextJsonOption()) + implicit val setJson: SetParameter[Json] = mkSetParameter[Json](pgjson, _.asJson.spaces2) + implicit val setJsonOption: SetParameter[Option[Json]] = mkOptionSetParameter[Json](pgjson, _.asJson.spaces2) } } diff --git a/addons/jawn/src/main/scala/com/github/tminglei/slickpg/PgJawnJsonSupport.scala b/addons/jawn/src/main/scala/com/github/tminglei/slickpg/PgJawnJsonSupport.scala index f4e9c021..e87fb082 100644 --- a/addons/jawn/src/main/scala/com/github/tminglei/slickpg/PgJawnJsonSupport.scala +++ b/addons/jawn/src/main/scala/com/github/tminglei/slickpg/PgJawnJsonSupport.scala @@ -1,6 +1,7 @@ package com.github.tminglei.slickpg -import slick.jdbc.{JdbcType, PositionedResult, PostgresProfile} +import slick.jdbc.{GetResult, JdbcType, PositionedResult, PostgresProfile, SetParameter} + import scala.reflect.classTag trait PgJawnJsonSupport extends json.PgJsonExtensions with utils.PgCommonJdbcTypes { driver: PostgresProfile => @@ -32,10 +33,10 @@ trait PgJawnJsonSupport extends json.PgJsonExtensions with utils.PgCommonJdbcTyp hasLiteralForm = false ) - implicit def playJsonColumnExtensionMethods(c: Rep[JValue]) = { + implicit def playJsonColumnExtensionMethods(c: Rep[JValue]): JsonColumnExtensionMethods[JValue, JValue] = { new JsonColumnExtensionMethods[JValue, JValue](c) } - implicit def playJsonOptionColumnExtensionMethods(c: Rep[Option[JValue]]) = { + implicit def playJsonOptionColumnExtensionMethods(c: Rep[Option[JValue]]): JsonColumnExtensionMethods[JValue, Option[JValue]] = { new JsonColumnExtensionMethods[JValue, Option[JValue]](c) } } @@ -49,9 +50,9 @@ trait PgJawnJsonSupport extends json.PgJsonExtensions with utils.PgCommonJdbcTyp } //////////////////////////////////////////////////////////// - implicit val getJson = mkGetResult(_.nextJson()) - implicit val getJsonOption = mkGetResult(_.nextJsonOption()) - implicit val setJson = mkSetParameter[JValue](pgjson, CanonicalRenderer.render) - implicit val setJsonOption = mkOptionSetParameter[JValue](pgjson, CanonicalRenderer.render) + implicit val getJson: GetResult[JValue] = mkGetResult(_.nextJson()) + implicit val getJsonOption: GetResult[Option[JValue]] = mkGetResult(_.nextJsonOption()) + implicit val setJson: SetParameter[JValue] = mkSetParameter[JValue](pgjson, CanonicalRenderer.render) + implicit val setJsonOption: SetParameter[Option[JValue]] = mkOptionSetParameter[JValue](pgjson, CanonicalRenderer.render) } } diff --git a/addons/joda-time/src/main/scala/com/github/tminglei/slickpg/PgDateSupportJoda.scala b/addons/joda-time/src/main/scala/com/github/tminglei/slickpg/PgDateSupportJoda.scala index fd766a00..d15c8277 100644 --- a/addons/joda-time/src/main/scala/com/github/tminglei/slickpg/PgDateSupportJoda.scala +++ b/addons/joda-time/src/main/scala/com/github/tminglei/slickpg/PgDateSupportJoda.scala @@ -3,7 +3,8 @@ package com.github.tminglei.slickpg import org.joda.time._ import org.joda.time.format.{DateTimeFormat, ISODateTimeFormat} import org.postgresql.util.PGInterval -import slick.jdbc.{JdbcType, PositionedResult, PostgresProfile} +import slick.jdbc.{GetResult, JdbcType, PositionedResult, PostgresProfile, SetParameter} + import scala.reflect.classTag trait PgDateSupportJoda extends date.PgDateExtensions with utils.PgCommonJdbcTypes { driver: PostgresProfile => @@ -69,34 +70,34 @@ trait PgDateSupportJoda extends date.PgDateExtensions with utils.PgCommonJdbcTyp hasLiteralForm = false) /// - implicit def jodaDateColumnExtensionMethods(c: Rep[LocalDate]) = + implicit def jodaDateColumnExtensionMethods(c: Rep[LocalDate]): DateColumnExtensionMethods[LocalDate, LocalTime, LocalDateTime, Period, LocalDate] = new DateColumnExtensionMethods[LocalDate, LocalTime, LocalDateTime, Period, LocalDate](c) - implicit def jodaDateOptColumnExtensionMethods(c: Rep[Option[LocalDate]]) = + implicit def jodaDateOptColumnExtensionMethods(c: Rep[Option[LocalDate]]): DateColumnExtensionMethods[LocalDate, LocalTime, LocalDateTime, Period, Option[LocalDate]] = new DateColumnExtensionMethods[LocalDate, LocalTime, LocalDateTime, Period, Option[LocalDate]](c) - implicit def jodaTimeColumnExtensionMethods(c: Rep[LocalTime]) = + implicit def jodaTimeColumnExtensionMethods(c: Rep[LocalTime]): TimeColumnExtensionMethods[LocalDate, LocalTime, LocalDateTime, DateTime, Period, LocalTime] = new TimeColumnExtensionMethods[LocalDate, LocalTime, LocalDateTime, DateTime, Period, LocalTime](c) - implicit def jodaTimeOptColumnExtensionMethods(c: Rep[Option[LocalTime]]) = + implicit def jodaTimeOptColumnExtensionMethods(c: Rep[Option[LocalTime]]): TimeColumnExtensionMethods[LocalDate, LocalTime, LocalDateTime, DateTime, Period, Option[LocalTime]] = new TimeColumnExtensionMethods[LocalDate, LocalTime, LocalDateTime, DateTime, Period, Option[LocalTime]](c) - implicit def jodaTimestampColumnExtensionMethods(c: Rep[LocalDateTime]) = + implicit def jodaTimestampColumnExtensionMethods(c: Rep[LocalDateTime]): TimestampColumnExtensionMethods[LocalDate, LocalTime, LocalDateTime, DateTime, Period, LocalDateTime] = new TimestampColumnExtensionMethods[LocalDate, LocalTime, LocalDateTime, DateTime, Period, LocalDateTime](c) - implicit def jodaTimestampOptColumnExtensionMethods(c: Rep[Option[LocalDateTime]]) = + implicit def jodaTimestampOptColumnExtensionMethods(c: Rep[Option[LocalDateTime]]): TimestampColumnExtensionMethods[LocalDate, LocalTime, LocalDateTime, DateTime, Period, Option[LocalDateTime]] = new TimestampColumnExtensionMethods[LocalDate, LocalTime, LocalDateTime, DateTime, Period, Option[LocalDateTime]](c) - implicit def jodaIntervalColumnExtensionMethods(c: Rep[Period]) = + implicit def jodaIntervalColumnExtensionMethods(c: Rep[Period]): IntervalColumnExtensionMethods[LocalDate, LocalTime, LocalDateTime, Period, Period] = new IntervalColumnExtensionMethods[LocalDate, LocalTime, LocalDateTime, Period, Period](c) - implicit def jodaIntervalOptColumnExtensionMethods(c: Rep[Option[Period]]) = + implicit def jodaIntervalOptColumnExtensionMethods(c: Rep[Option[Period]]): IntervalColumnExtensionMethods[LocalDate, LocalTime, LocalDateTime, Period, Option[Period]] = new IntervalColumnExtensionMethods[LocalDate, LocalTime, LocalDateTime, Period, Option[Period]](c) - implicit def jodaTzTimestampColumnExtensionMethods(c: Rep[DateTime]) = + implicit def jodaTzTimestampColumnExtensionMethods(c: Rep[DateTime]): TimestampColumnExtensionMethods[LocalDate, LocalTime, DateTime, LocalDateTime, Period, DateTime] = new TimestampColumnExtensionMethods[LocalDate, LocalTime, DateTime, LocalDateTime, Period, DateTime](c) - implicit def jodaTzTimestampOptColumnExtensionMethods(c: Rep[Option[DateTime]]) = + implicit def jodaTzTimestampOptColumnExtensionMethods(c: Rep[Option[DateTime]]): TimestampColumnExtensionMethods[LocalDate, LocalTime, DateTime, LocalDateTime, Period, Option[DateTime]] = new TimestampColumnExtensionMethods[LocalDate, LocalTime, DateTime, LocalDateTime, Period, Option[DateTime]](c) - implicit def jodaTimestamp1ColumnExtensionMethods(c: Rep[Instant]) = + implicit def jodaTimestamp1ColumnExtensionMethods(c: Rep[Instant]): TimestampColumnExtensionMethods[LocalDate, LocalTime, Instant, LocalDateTime, Period, Instant] = new TimestampColumnExtensionMethods[LocalDate, LocalTime, Instant, LocalDateTime, Period, Instant](c) - implicit def jodaTimestamp1OptColumnExtensionMethods(c: Rep[Option[Instant]]) = + implicit def jodaTimestamp1OptColumnExtensionMethods(c: Rep[Option[Instant]]): TimestampColumnExtensionMethods[LocalDate, LocalTime, Instant, LocalDateTime, Period, Option[Instant]] = new TimestampColumnExtensionMethods[LocalDate, LocalTime, Instant, LocalDateTime, Period, Option[Instant]](c) } @@ -120,38 +121,38 @@ trait PgDateSupportJoda extends date.PgDateExtensions with utils.PgCommonJdbcTyp } ///////////////////////////////////////////////////////////////////////////// - implicit val getLocalDate = mkGetResult(_.nextLocalDate()) - implicit val getLocalDateOption = mkGetResult(_.nextLocalDateOption()) - implicit val setLocalDate = mkSetParameter[LocalDate]("date", _.toString(jodaDateFormatter), sqlType = Types.DATE) - implicit val setLocalDateOption = mkOptionSetParameter[LocalDate]("date", _.toString(jodaDateFormatter), sqlType = Types.DATE) - - implicit val getLocalTime = mkGetResult(_.nextLocalTime()) - implicit val getLocalTimeOption = mkGetResult(_.nextLocalTimeOption()) - implicit val setLocalTime = mkSetParameter[LocalTime]("time", _.toString(jodaTimeFormatter), sqlType = Types.TIME) - implicit val setLocalTimeOption = mkOptionSetParameter[LocalTime]("time", _.toString(jodaTimeFormatter), sqlType = Types.TIME) - - implicit val getLocalDateTime = mkGetResult(_.nextLocalDateTime()) - implicit val getLocalDateTimeOption = mkGetResult(_.nextLocalDateTimeOption()) - implicit val setLocalDateTime = mkSetParameter[LocalDateTime]("timestamp", _.toString(jodaDateTimeFormatter), sqlType = Types.TIMESTAMP) - implicit val setLocalDateTimeOption = mkOptionSetParameter[LocalDateTime]("timestamp", _.toString(jodaDateTimeFormatter), sqlType = Types.TIMESTAMP) - - implicit val getZonedDateTime = mkGetResult(_.nextZonedDateTime()) - implicit val getZonedDateTimeOption = mkGetResult(_.nextZonedDateTimeOption()) - implicit val setZonedDateTime = mkSetParameter[DateTime]("timestamptz", _.toString(jodaTzDateTimeFormatter), sqlType = Types.TIMESTAMP /*Types.TIMESTAMP_WITH_TIMEZONE*/) - implicit val setZonedDateTimeOption = mkOptionSetParameter[DateTime]("timestamptz", _.toString(jodaTzDateTimeFormatter), sqlType = Types.TIMESTAMP /*Types.TIMESTAMP_WITH_TIMEZONE*/) - - implicit val getInstant = mkGetResult(_.nextInstant()) - implicit val getInstantOption = mkGetResult(_.nextInstantOption()) - implicit val setInstant = mkSetParameter[Instant]("timestamptz", _.toString(jodaTzDateTimeFormatter), sqlType = Types.TIMESTAMP /*Types.TIMESTAMP_WITH_TIMEZONE*/) - implicit val setInstantOption = mkOptionSetParameter[Instant]("timestamptz", _.toString(jodaTzDateTimeFormatter), sqlType = Types.TIMESTAMP /*Types.TIMESTAMP_WITH_TIMEZONE*/) - - implicit val getPeriod = mkGetResult(_.nextPeriod()) - implicit val getPeriodOption = mkGetResult(_.nextPeriodOption()) - implicit val setPeriod = mkSetParameter[Period]("interval") - implicit val setPeriodOption = mkOptionSetParameter[Period]("interval") - - implicit val setDuration = mkSetParameter[Duration]("interval") - implicit val setDurationOption = mkOptionSetParameter[Duration]("interval") + implicit val getLocalDate: GetResult[LocalDate] = mkGetResult(_.nextLocalDate()) + implicit val getLocalDateOption: GetResult[Option[LocalDate]] = mkGetResult(_.nextLocalDateOption()) + implicit val setLocalDate: SetParameter[LocalDate] = mkSetParameter[LocalDate]("date", _.toString(jodaDateFormatter), sqlType = Types.DATE) + implicit val setLocalDateOption: SetParameter[Option[LocalDate]] = mkOptionSetParameter[LocalDate]("date", _.toString(jodaDateFormatter), sqlType = Types.DATE) + + implicit val getLocalTime: GetResult[LocalTime] = mkGetResult(_.nextLocalTime()) + implicit val getLocalTimeOption: GetResult[Option[LocalTime]] = mkGetResult(_.nextLocalTimeOption()) + implicit val setLocalTime: SetParameter[LocalTime] = mkSetParameter[LocalTime]("time", _.toString(jodaTimeFormatter), sqlType = Types.TIME) + implicit val setLocalTimeOption: SetParameter[Option[LocalTime]] = mkOptionSetParameter[LocalTime]("time", _.toString(jodaTimeFormatter), sqlType = Types.TIME) + + implicit val getLocalDateTime: GetResult[LocalDateTime] = mkGetResult(_.nextLocalDateTime()) + implicit val getLocalDateTimeOption: GetResult[Option[LocalDateTime]] = mkGetResult(_.nextLocalDateTimeOption()) + implicit val setLocalDateTime: SetParameter[LocalDateTime] = mkSetParameter[LocalDateTime]("timestamp", _.toString(jodaDateTimeFormatter), sqlType = Types.TIMESTAMP) + implicit val setLocalDateTimeOption: SetParameter[Option[LocalDateTime]] = mkOptionSetParameter[LocalDateTime]("timestamp", _.toString(jodaDateTimeFormatter), sqlType = Types.TIMESTAMP) + + implicit val getZonedDateTime: GetResult[DateTime] = mkGetResult(_.nextZonedDateTime()) + implicit val getZonedDateTimeOption: GetResult[Option[DateTime]] = mkGetResult(_.nextZonedDateTimeOption()) + implicit val setZonedDateTime: SetParameter[DateTime] = mkSetParameter[DateTime]("timestamptz", _.toString(jodaTzDateTimeFormatter), sqlType = Types.TIMESTAMP /*Types.TIMESTAMP_WITH_TIMEZONE*/) + implicit val setZonedDateTimeOption: SetParameter[Option[DateTime]] = mkOptionSetParameter[DateTime]("timestamptz", _.toString(jodaTzDateTimeFormatter), sqlType = Types.TIMESTAMP /*Types.TIMESTAMP_WITH_TIMEZONE*/) + + implicit val getInstant: GetResult[Instant] = mkGetResult(_.nextInstant()) + implicit val getInstantOption: GetResult[Option[Instant]] = mkGetResult(_.nextInstantOption()) + implicit val setInstant: SetParameter[Instant] = mkSetParameter[Instant]("timestamptz", _.toString(jodaTzDateTimeFormatter), sqlType = Types.TIMESTAMP /*Types.TIMESTAMP_WITH_TIMEZONE*/) + implicit val setInstantOption: SetParameter[Option[Instant]] = mkOptionSetParameter[Instant]("timestamptz", _.toString(jodaTzDateTimeFormatter), sqlType = Types.TIMESTAMP /*Types.TIMESTAMP_WITH_TIMEZONE*/) + + implicit val getPeriod: GetResult[Period] = mkGetResult(_.nextPeriod()) + implicit val getPeriodOption: GetResult[Option[Period]] = mkGetResult(_.nextPeriodOption()) + implicit val setPeriod: SetParameter[Period] = mkSetParameter[Period]("interval") + implicit val setPeriodOption: SetParameter[Option[Period]] = mkOptionSetParameter[Period]("interval") + + implicit val setDuration: SetParameter[Duration] = mkSetParameter[Duration]("interval") + implicit val setDurationOption: SetParameter[Option[Duration]] = mkOptionSetParameter[Duration]("interval") } } diff --git a/addons/json4s/src/main/scala/com/github/tminglei/slickpg/PgJson4sSupport.scala b/addons/json4s/src/main/scala/com/github/tminglei/slickpg/PgJson4sSupport.scala index 211c5f8e..6c5e7ce8 100644 --- a/addons/json4s/src/main/scala/com/github/tminglei/slickpg/PgJson4sSupport.scala +++ b/addons/json4s/src/main/scala/com/github/tminglei/slickpg/PgJson4sSupport.scala @@ -1,6 +1,7 @@ package com.github.tminglei.slickpg -import slick.jdbc.{JdbcType, PositionedResult, PostgresProfile} +import slick.jdbc.{GetResult, JdbcType, PositionedResult, PostgresProfile, SetParameter} + import scala.reflect.classTag trait PgJson4sSupport extends json.PgJsonExtensions with utils.PgCommonJdbcTypes { driver: PostgresProfile => @@ -35,10 +36,10 @@ trait PgJson4sSupport extends json.PgJsonExtensions with utils.PgCommonJdbcTypes hasLiteralForm = false ) - implicit def json4sJsonColumnExtensionMethods(c: Rep[JValue]) = { + implicit def json4sJsonColumnExtensionMethods(c: Rep[JValue]): JsonColumnExtensionMethods[JValue, JValue] = { new JsonColumnExtensionMethods[JValue, JValue](c) } - implicit def json4sJsonOptionColumnExtensionMethods(c: Rep[Option[JValue]]) = { + implicit def json4sJsonOptionColumnExtensionMethods(c: Rep[Option[JValue]]): JsonColumnExtensionMethods[JValue, Option[JValue]] = { new JsonColumnExtensionMethods[JValue, Option[JValue]](c) } } @@ -52,9 +53,9 @@ trait PgJson4sSupport extends json.PgJsonExtensions with utils.PgCommonJdbcTypes } ////////////////////////////////////////////////////////// - implicit val getJson = mkGetResult(_.nextJson()) - implicit val getJsonOption = mkGetResult(_.nextJsonOption()) - implicit val setJson = mkSetParameter[JValue](pgjson, (v) => jsonMethods.compact(jsonMethods.render(v))) - implicit val setJsonOption = mkOptionSetParameter[JValue](pgjson, (v) => jsonMethods.compact(jsonMethods.render(v))) + implicit val getJson: GetResult[JValue] = mkGetResult(_.nextJson()) + implicit val getJsonOption: GetResult[Option[JValue]] = mkGetResult(_.nextJsonOption()) + implicit val setJson: SetParameter[JValue] = mkSetParameter[JValue](pgjson, (v) => jsonMethods.compact(jsonMethods.render(v))) + implicit val setJsonOption: SetParameter[Option[JValue]] = mkOptionSetParameter[JValue](pgjson, (v) => jsonMethods.compact(jsonMethods.render(v))) } } diff --git a/addons/jts/src/main/scala/com/github/tminglei/slickpg/PgPostGISSupport.scala b/addons/jts/src/main/scala/com/github/tminglei/slickpg/PgPostGISSupport.scala index 3a6d8540..21a06fdf 100644 --- a/addons/jts/src/main/scala/com/github/tminglei/slickpg/PgPostGISSupport.scala +++ b/addons/jts/src/main/scala/com/github/tminglei/slickpg/PgPostGISSupport.scala @@ -35,9 +35,9 @@ trait PgPostGISSupport extends geom.PgPostGISExtensions { driver: PostgresProfil implicit val geogMultiLineStringTypeMapper: JdbcType[GeogMultiLineString] = new GeographyJdbcType[GeogMultiLineString] /// - implicit def geographyColumnExtensionMethods[G1 <: Geography](c: Rep[G1]) = + implicit def geographyColumnExtensionMethods[G1 <: Geography](c: Rep[G1]): GeographyColumnExtensionMethods[Geography, GeogPoint, GeogLineString, GeogPolygon, GeographyCollection, G1, G1] = new GeographyColumnExtensionMethods[Geography, GeogPoint, GeogLineString, GeogPolygon, GeographyCollection, G1, G1](c) - implicit def geographyOptionColumnExtensionMethods[G1 <: Geography](c: Rep[Option[G1]]) = + implicit def geographyOptionColumnExtensionMethods[G1 <: Geography](c: Rep[Option[G1]]): GeographyColumnExtensionMethods[Geography, GeogPoint, GeogLineString, GeogPolygon, GeographyCollection, G1, Option[G1]] = new GeographyColumnExtensionMethods[Geography, GeogPoint, GeogLineString, GeogPolygon, GeographyCollection, G1, Option[G1]](c) ////// @@ -53,9 +53,9 @@ trait PgPostGISSupport extends geom.PgPostGISExtensions { driver: PostgresProfil implicit val multiLineStringTypeMapper: JdbcType[MultiLineString] = new GeometryJdbcType[MultiLineString] /// - implicit def geometryColumnExtensionMethods[G1 <: Geometry](c: Rep[G1]) = + implicit def geometryColumnExtensionMethods[G1 <: Geometry](c: Rep[G1]): GeometryColumnExtensionMethods[Geometry, Point, LineString, Polygon, GeometryCollection, G1, G1] = new GeometryColumnExtensionMethods[Geometry, Point, LineString, Polygon, GeometryCollection, G1, G1](c) - implicit def geometryOptionColumnExtensionMethods[G1 <: Geometry](c: Rep[Option[G1]]) = + implicit def geometryOptionColumnExtensionMethods[G1 <: Geometry](c: Rep[Option[G1]]): GeometryColumnExtensionMethods[Geometry, Point, LineString, Polygon, GeometryCollection, G1, Option[G1]] = new GeometryColumnExtensionMethods[Geometry, Point, LineString, Polygon, GeometryCollection, G1, Option[G1]](c) } @@ -71,8 +71,8 @@ trait PgPostGISSupport extends geom.PgPostGISExtensions { driver: PostgresProfil } //////////////////////////////////////////////////////////////////////////////// - implicit val getGeometry = mkGetResult(_.nextGeometry[Geometry]()) - implicit val getGeometryOption = mkGetResult(_.nextGeometryOption[Geometry]()) + implicit val getGeometry: GetResult[Geometry] = mkGetResult(_.nextGeometry[Geometry]()) + implicit val getGeometryOption: GetResult[Option[Geometry]] = mkGetResult(_.nextGeometryOption[Geometry]()) implicit object SetGeometry extends SetParameter[Geometry] { def apply(v: Geometry, pp: PositionedParameters) = setGeometry(Option(v), pp) diff --git a/addons/jts_lt/src/main/scala/com/github/tminglei/slickpg/PgPostGISSupport.scala b/addons/jts_lt/src/main/scala/com/github/tminglei/slickpg/PgPostGISSupport.scala index e4ec2b77..d4fca6f6 100644 --- a/addons/jts_lt/src/main/scala/com/github/tminglei/slickpg/PgPostGISSupport.scala +++ b/addons/jts_lt/src/main/scala/com/github/tminglei/slickpg/PgPostGISSupport.scala @@ -35,9 +35,9 @@ trait PgPostGISSupport extends geom.PgPostGISExtensions { driver: PostgresProfil implicit val geogMultiLineStringTypeMapper: JdbcType[GeogMultiLineString] = new GeographyJdbcType[GeogMultiLineString] /// - implicit def geographyColumnExtensionMethods[G1 <: Geography](c: Rep[G1]) = + implicit def geographyColumnExtensionMethods[G1 <: Geography](c: Rep[G1]): GeographyColumnExtensionMethods[Geography, GeogPoint, GeogLineString, GeogPolygon, GeographyCollection, G1, G1] = new GeographyColumnExtensionMethods[Geography, GeogPoint, GeogLineString, GeogPolygon, GeographyCollection, G1, G1](c) - implicit def geographyOptionColumnExtensionMethods[G1 <: Geography](c: Rep[Option[G1]]) = + implicit def geographyOptionColumnExtensionMethods[G1 <: Geography](c: Rep[Option[G1]]): GeographyColumnExtensionMethods[Geography, GeogPoint, GeogLineString, GeogPolygon, GeographyCollection, G1, Option[G1]] = new GeographyColumnExtensionMethods[Geography, GeogPoint, GeogLineString, GeogPolygon, GeographyCollection, G1, Option[G1]](c) ////// @@ -53,9 +53,9 @@ trait PgPostGISSupport extends geom.PgPostGISExtensions { driver: PostgresProfil implicit val multiLineStringTypeMapper: JdbcType[MultiLineString] = new GeometryJdbcType[MultiLineString] /// - implicit def geometryColumnExtensionMethods[G1 <: Geometry](c: Rep[G1]) = + implicit def geometryColumnExtensionMethods[G1 <: Geometry](c: Rep[G1]): GeometryColumnExtensionMethods[Geometry, Point, LineString, Polygon, GeometryCollection, G1, G1] = new GeometryColumnExtensionMethods[Geometry, Point, LineString, Polygon, GeometryCollection, G1, G1](c) - implicit def geometryOptionColumnExtensionMethods[G1 <: Geometry](c: Rep[Option[G1]]) = + implicit def geometryOptionColumnExtensionMethods[G1 <: Geometry](c: Rep[Option[G1]]): GeometryColumnExtensionMethods[Geometry, Point, LineString, Polygon, GeometryCollection, G1, Option[G1]] = new GeometryColumnExtensionMethods[Geometry, Point, LineString, Polygon, GeometryCollection, G1, Option[G1]](c) } @@ -71,8 +71,8 @@ trait PgPostGISSupport extends geom.PgPostGISExtensions { driver: PostgresProfil } //////////////////////////////////////////////////////////////////////////////// - implicit val getGeometry = mkGetResult(_.nextGeometry[Geometry]()) - implicit val getGeometryOption = mkGetResult(_.nextGeometryOption[Geometry]()) + implicit val getGeometry: GetResult[Geometry] = mkGetResult(_.nextGeometry[Geometry]()) + implicit val getGeometryOption: GetResult[Option[Geometry]] = mkGetResult(_.nextGeometryOption[Geometry]()) implicit object SetGeometry extends SetParameter[Geometry] { def apply(v: Geometry, pp: PositionedParameters) = setGeometry(Option(v), pp) diff --git a/addons/play-json/src/main/scala/com/github/tminglei/slickpg/PgPlayJsonSupport.scala b/addons/play-json/src/main/scala/com/github/tminglei/slickpg/PgPlayJsonSupport.scala index 7e17cee4..04dae5d5 100644 --- a/addons/play-json/src/main/scala/com/github/tminglei/slickpg/PgPlayJsonSupport.scala +++ b/addons/play-json/src/main/scala/com/github/tminglei/slickpg/PgPlayJsonSupport.scala @@ -1,6 +1,7 @@ package com.github.tminglei.slickpg -import slick.jdbc.{JdbcType, PositionedResult, PostgresProfile} +import slick.jdbc.{GetResult, JdbcType, PositionedResult, PostgresProfile, SetParameter} + import scala.reflect.classTag trait PgPlayJsonSupport extends json.PgJsonExtensions with utils.PgCommonJdbcTypes { driver: PostgresProfile => @@ -32,10 +33,10 @@ trait PgPlayJsonSupport extends json.PgJsonExtensions with utils.PgCommonJdbcTyp hasLiteralForm = false ) - implicit def playJsonColumnExtensionMethods(c: Rep[JsValue]) = { + implicit def playJsonColumnExtensionMethods(c: Rep[JsValue]): JsonColumnExtensionMethods[JsValue, JsValue] = { new JsonColumnExtensionMethods[JsValue, JsValue](c) } - implicit def playJsonOptionColumnExtensionMethods(c: Rep[Option[JsValue]]) = { + implicit def playJsonOptionColumnExtensionMethods(c: Rep[Option[JsValue]]): JsonColumnExtensionMethods[JsValue, Option[JsValue]] = { new JsonColumnExtensionMethods[JsValue, Option[JsValue]](c) } } @@ -49,9 +50,9 @@ trait PgPlayJsonSupport extends json.PgJsonExtensions with utils.PgCommonJdbcTyp } //////////////////////////////////////////////////////////// - implicit val getJson = mkGetResult(_.nextJson()) - implicit val getJsonOption = mkGetResult(_.nextJsonOption()) - implicit val setJson = mkSetParameter[JsValue](pgjson, Json.stringify) - implicit val setJsonOption = mkOptionSetParameter[JsValue](pgjson, Json.stringify) + implicit val getJson: GetResult[JsValue] = mkGetResult(_.nextJson()) + implicit val getJsonOption: GetResult[Option[JsValue]] = mkGetResult(_.nextJsonOption()) + implicit val setJson: SetParameter[JsValue] = mkSetParameter[JsValue](pgjson, Json.stringify) + implicit val setJsonOption: SetParameter[Option[JsValue]] = mkOptionSetParameter[JsValue](pgjson, Json.stringify) } } diff --git a/addons/spray-json/src/main/scala/com/github/tminglei/slickpg/PgSprayJsonSupport.scala b/addons/spray-json/src/main/scala/com/github/tminglei/slickpg/PgSprayJsonSupport.scala index 811b0a99..827f1594 100644 --- a/addons/spray-json/src/main/scala/com/github/tminglei/slickpg/PgSprayJsonSupport.scala +++ b/addons/spray-json/src/main/scala/com/github/tminglei/slickpg/PgSprayJsonSupport.scala @@ -1,6 +1,7 @@ package com.github.tminglei.slickpg -import slick.jdbc.{JdbcType, PositionedResult, PostgresProfile} +import slick.jdbc.{GetResult, JdbcType, PositionedResult, PostgresProfile, SetParameter} + import scala.reflect.classTag trait PgSprayJsonSupport extends json.PgJsonExtensions with utils.PgCommonJdbcTypes { driver: PostgresProfile => @@ -33,10 +34,10 @@ trait PgSprayJsonSupport extends json.PgJsonExtensions with utils.PgCommonJdbcTy hasLiteralForm = false ) - implicit def sprayJsonColumnExtensionMethods(c: Rep[JsValue]) = { + implicit def sprayJsonColumnExtensionMethods(c: Rep[JsValue]): JsonColumnExtensionMethods[JsValue, JsValue] = { new JsonColumnExtensionMethods[JsValue, JsValue](c) } - implicit def sprayJsonOptionColumnExtensionMethods(c: Rep[Option[JsValue]]) = { + implicit def sprayJsonOptionColumnExtensionMethods(c: Rep[Option[JsValue]]): JsonColumnExtensionMethods[JsValue, Option[JsValue]] = { new JsonColumnExtensionMethods[JsValue, Option[JsValue]](c) } } @@ -50,9 +51,9 @@ trait PgSprayJsonSupport extends json.PgJsonExtensions with utils.PgCommonJdbcTy } /////////////////////////////////////////////////////////// - implicit val getJson = mkGetResult(_.nextJson()) - implicit val getJsonOption = mkGetResult(_.nextJsonOption()) - implicit val setJson = mkSetParameter[JsValue](pgjson, _.toJson.compactPrint) - implicit val setJsonOption = mkOptionSetParameter[JsValue](pgjson, _.toJson.compactPrint) + implicit val getJson: GetResult[JsValue] = mkGetResult(_.nextJson()) + implicit val getJsonOption: GetResult[Option[JsValue]] = mkGetResult(_.nextJsonOption()) + implicit val setJson: SetParameter[JsValue] = mkSetParameter[JsValue](pgjson, _.toJson.compactPrint) + implicit val setJsonOption: SetParameter[Option[JsValue]] = mkOptionSetParameter[JsValue](pgjson, _.toJson.compactPrint) } } 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 a3b98634..16325d0e 100644 --- a/core/src/main/scala/com/github/tminglei/slickpg/ExPostgresProfile.scala +++ b/core/src/main/scala/com/github/tminglei/slickpg/ExPostgresProfile.scala @@ -59,16 +59,16 @@ trait ExPostgresProfile extends JdbcProfile with PostgresProfile with Logging { trait ByteaPlainImplicits { /** NOTE: Array[Byte] maps to `bytea` instead of `byte ARRAY` */ - implicit val getByteArray = new GetResult[Array[Byte]] { + implicit val getByteArray: GetResult[Array[Byte]] = new GetResult[Array[Byte]] { def apply(pr: PositionedResult) = pr.nextBytes() } - implicit val getByteArrayOption = new GetResult[Option[Array[Byte]]] { + implicit val getByteArrayOption: GetResult[Option[Array[Byte]]] = new GetResult[Option[Array[Byte]]] { def apply(pr: PositionedResult) = pr.nextBytesOption() } - implicit val setByteArray = new SetParameter[Array[Byte]] { + implicit val setByteArray: SetParameter[Array[Byte]] = new SetParameter[Array[Byte]] { def apply(v: Array[Byte], pp: PositionedParameters) = pp.setBytes(v) } - implicit val setByteArrayOption = new SetParameter[Option[Array[Byte]]] { + implicit val setByteArrayOption: SetParameter[Option[Array[Byte]]] = new SetParameter[Option[Array[Byte]]] { def apply(v: Option[Array[Byte]], pp: PositionedParameters) = pp.setBytesOption(v) } } @@ -162,7 +162,7 @@ trait ExPostgresProfile extends JdbcProfile with PostgresProfile with Logging { if (!tableHasPrimaryKey) throw new SlickException("InsertOrUpdateAll is not supported on a table without PK.") - override def run(ctx: Backend#Context, sql: Vector[String]) = + override def run(ctx: Backend#JdbcActionContext, sql: Vector[String]) = nativeUpsert(values, sql.head)(ctx.session) protected def nativeUpsert(values: Iterable[U], sql: String)( diff --git a/core/src/main/scala/com/github/tminglei/slickpg/str/PgStringSupport.scala b/core/src/main/scala/com/github/tminglei/slickpg/str/PgStringSupport.scala index 592cf3c9..29194a52 100644 --- a/core/src/main/scala/com/github/tminglei/slickpg/str/PgStringSupport.scala +++ b/core/src/main/scala/com/github/tminglei/slickpg/str/PgStringSupport.scala @@ -10,9 +10,9 @@ trait PgStringSupport extends PgStringExtensions { driver: PostgresProfile => import driver.api._ trait PgStringImplicits { - implicit def pgStringColumnExtensionMethods(c: Rep[String]) = new PgStringColumnExtensionMethods[String](c) - implicit def pgStringOptionColumnExtensionMethods(c: Rep[Option[String]]) = new PgStringColumnExtensionMethods[Option[String]](c) - implicit def pgStringByteaColumnExtensionMethods(c: Rep[Array[Byte]]) = new PgStringByteaColumnExtensionMethods[Array[Byte]](c) - implicit def pgStringByteaOptionColumnExtensionMethods(c: Rep[Option[Array[Byte]]]) = new PgStringByteaColumnExtensionMethods[Option[Array[Byte]]](c) + implicit def pgStringColumnExtensionMethods(c: Rep[String]): PgStringColumnExtensionMethods[String] = new PgStringColumnExtensionMethods[String](c) + implicit def pgStringOptionColumnExtensionMethods(c: Rep[Option[String]]): PgStringColumnExtensionMethods[Option[String]] = new PgStringColumnExtensionMethods[Option[String]](c) + implicit def pgStringByteaColumnExtensionMethods(c: Rep[Array[Byte]]): PgStringByteaColumnExtensionMethods[Array[Byte]] = new PgStringByteaColumnExtensionMethods[Array[Byte]](c) + implicit def pgStringByteaOptionColumnExtensionMethods(c: Rep[Option[Array[Byte]]]): PgStringByteaColumnExtensionMethods[Option[Array[Byte]]] = new PgStringByteaColumnExtensionMethods[Option[Array[Byte]]](c) } } \ No newline at end of file diff --git a/core/src/main/scala/com/github/tminglei/slickpg/trgm/PgTrgmSupport.scala b/core/src/main/scala/com/github/tminglei/slickpg/trgm/PgTrgmSupport.scala index d86b5f09..cc3a956a 100644 --- a/core/src/main/scala/com/github/tminglei/slickpg/trgm/PgTrgmSupport.scala +++ b/core/src/main/scala/com/github/tminglei/slickpg/trgm/PgTrgmSupport.scala @@ -10,7 +10,7 @@ trait PgTrgmSupport extends PgTrgmExtensions { driver: PostgresProfile => import driver.api._ trait PgTrgmImplicits { - implicit def pgTrgmColumnExtensionMethods(c: Rep[String]) = new PgTrgmColumnExtensionMethods[String](c) - implicit def pgTrgmOptionColumnExtensionMethods(c: Rep[Option[String]]) = new PgTrgmColumnExtensionMethods[Option[String]](c) + implicit def pgTrgmColumnExtensionMethods(c: Rep[String]): PgTrgmColumnExtensionMethods[String] = new PgTrgmColumnExtensionMethods[String](c) + implicit def pgTrgmOptionColumnExtensionMethods(c: Rep[Option[String]]): PgTrgmColumnExtensionMethods[Option[String]] = new PgTrgmColumnExtensionMethods[Option[String]](c) } } diff --git a/core/src/main/scala/com/github/tminglei/slickpg/window/PgWindowFuncCore.scala b/core/src/main/scala/com/github/tminglei/slickpg/window/PgWindowFuncCore.scala index 3d1063c1..3beb8c2f 100644 --- a/core/src/main/scala/com/github/tminglei/slickpg/window/PgWindowFuncCore.scala +++ b/core/src/main/scala/com/github/tminglei/slickpg/window/PgWindowFuncCore.scala @@ -1,6 +1,7 @@ package com.github.tminglei.slickpg package window +import com.github.tminglei.slickpg.agg.AggFuncRep import slick.ast._ import slick.lifted.Rep.TypedRep import slick.lifted.{CanBeQueryCondition, Ordered, Rep} @@ -46,7 +47,7 @@ object WindowFunc { def apply[R: TypedType](aggFunc: FunctionSymbol, params: Seq[Node]): WindowFunc[R] = WindowFunc[R](agg.AggFuncParts(aggFunc, params)) - implicit def winFunc2aggFuncRep[R: TypedType](winFunc: WindowFunc[R]) = + implicit def winFunc2aggFuncRep[R: TypedType](winFunc: WindowFunc[R]): AggFuncRep[R] = new agg.AggFuncRep[R](winFunc._parts) } case class WindowFunc[R: TypedType](_parts: agg.AggFuncParts) { diff --git a/src/main/scala/com/github/tminglei/slickpg/PgArraySupport.scala b/src/main/scala/com/github/tminglei/slickpg/PgArraySupport.scala index c45b5d38..35f6b47c 100644 --- a/src/main/scala/com/github/tminglei/slickpg/PgArraySupport.scala +++ b/src/main/scala/com/github/tminglei/slickpg/PgArraySupport.scala @@ -2,7 +2,7 @@ package com.github.tminglei.slickpg import java.util.UUID import java.sql.{Date, Time, Timestamp} -import slick.jdbc.{JdbcType, PositionedResult, PostgresProfile} +import slick.jdbc.{GetResult, JdbcType, PositionedResult, PostgresProfile, SetParameter} import scala.reflect.runtime.{universe => u} import scala.reflect.classTag @@ -45,11 +45,11 @@ trait PgArraySupport extends array.PgArrayExtensions with array.PgArrayJdbcTypes /// implicit def simpleArrayColumnExtensionMethods[B1, SEQ[B1]](c: Rep[SEQ[B1]])( - implicit tm: JdbcType[B1], tm1: JdbcType[SEQ[B1]]) = { + implicit tm: JdbcType[B1], tm1: JdbcType[SEQ[B1]]): ArrayColumnExtensionMethods[B1, SEQ, SEQ[B1]] = { new ArrayColumnExtensionMethods[B1, SEQ, SEQ[B1]](c) } implicit def simpleArrayOptionColumnExtensionMethods[B1, SEQ[B1]](c: Rep[Option[SEQ[B1]]])( - implicit tm: JdbcType[B1], tm1: JdbcType[SEQ[B1]]) = { + implicit tm: JdbcType[B1], tm1: JdbcType[SEQ[B1]]): ArrayColumnExtensionMethods[B1, SEQ, Option[SEQ[B1]]] = { new ArrayColumnExtensionMethods[B1, SEQ, Option[SEQ[B1]]](c) } } @@ -77,59 +77,59 @@ trait PgArraySupport extends array.PgArrayExtensions with array.PgArrayJdbcTypes } ////////////////////////////////////////////////////////////////////////// - implicit val getUUIDArray = mkGetResult(_.nextArray[UUID]()) - implicit val getUUIDArrayOption = mkGetResult(_.nextArrayOption[UUID]()) - implicit val setUUIDArray = mkArraySetParameter[UUID]("uuid") - implicit val setUUIDArrayOption = mkArrayOptionSetParameter[UUID]("uuid") + implicit val getUUIDArray: GetResult[Seq[UUID]] = mkGetResult(_.nextArray[UUID]()) + implicit val getUUIDArrayOption: GetResult[Option[Seq[UUID]]] = mkGetResult(_.nextArrayOption[UUID]()) + implicit val setUUIDArray: SetParameter[Seq[UUID]] = mkArraySetParameter[UUID]("uuid") + implicit val setUUIDArrayOption: SetParameter[Option[Seq[UUID]]] = mkArrayOptionSetParameter[UUID]("uuid") /// - implicit val getStringArray = mkGetResult(_.nextArray[String]()) - implicit val getStringArrayOption = mkGetResult(_.nextArrayOption[String]()) - implicit val setStringArray = mkArraySetParameter[String]("text") - implicit val setStringArrayOption = mkArrayOptionSetParameter[String]("text") + implicit val getStringArray: GetResult[Seq[String]] = mkGetResult(_.nextArray[String]()) + implicit val getStringArrayOption: GetResult[Option[Seq[String]]] = mkGetResult(_.nextArrayOption[String]()) + implicit val setStringArray: SetParameter[Seq[String]] = mkArraySetParameter[String]("text") + implicit val setStringArrayOption: SetParameter[Option[Seq[String]]] = mkArrayOptionSetParameter[String]("text") /// - implicit val getLongArray = mkGetResult(_.nextArray[Long]()) - implicit val getLongArrayOption = mkGetResult(_.nextArrayOption[Long]()) - implicit val setLongArray = mkArraySetParameter[Long]("int8") - implicit val setLongArrayOption = mkArrayOptionSetParameter[Long]("int8") + implicit val getLongArray: GetResult[Seq[Long]] = mkGetResult(_.nextArray[Long]()) + implicit val getLongArrayOption: GetResult[Option[Seq[Long]]] = mkGetResult(_.nextArrayOption[Long]()) + implicit val setLongArray: SetParameter[Seq[Long]] = mkArraySetParameter[Long]("int8") + implicit val setLongArrayOption: SetParameter[Option[Seq[Long]]] = mkArrayOptionSetParameter[Long]("int8") /// - implicit val getIntArray = mkGetResult(_.nextArray[Int]()) - implicit val getIntArrayOption = mkGetResult(_.nextArrayOption[Int]()) - implicit val setIntArray = mkArraySetParameter[Int]("int4") - implicit val setIntArrayOption = mkArrayOptionSetParameter[Int]("int4") + implicit val getIntArray: GetResult[Seq[Int]] = mkGetResult(_.nextArray[Int]()) + implicit val getIntArrayOption: GetResult[Option[Seq[Int]]] = mkGetResult(_.nextArrayOption[Int]()) + implicit val setIntArray: SetParameter[Seq[Int]] = mkArraySetParameter[Int]("int4") + implicit val setIntArrayOption: SetParameter[Option[Seq[Int]]] = mkArrayOptionSetParameter[Int]("int4") /// - implicit val getShortArray = mkGetResult(_.nextArray[Short]()) - implicit val getShortArrayOption = mkGetResult(_.nextArrayOption[Short]()) - implicit val setShortArray = mkArraySetParameter[Short]("int2") - implicit val setShortArrayOption = mkArrayOptionSetParameter[Short]("int2") + implicit val getShortArray: GetResult[Seq[Short]] = mkGetResult(_.nextArray[Short]()) + implicit val getShortArrayOption: GetResult[Option[Seq[Short]]] = mkGetResult(_.nextArrayOption[Short]()) + implicit val setShortArray: SetParameter[Seq[Short]] = mkArraySetParameter[Short]("int2") + implicit val setShortArrayOption: SetParameter[Option[Seq[Short]]] = mkArrayOptionSetParameter[Short]("int2") /// - implicit val getFloatArray = mkGetResult(_.nextArray[Float]()) - implicit val getFloatArrayOption = mkGetResult(_.nextArrayOption[Float]()) - implicit val setFloatArray = mkArraySetParameter[Float]("float4") - implicit val setFloatArrayOption = mkArrayOptionSetParameter[Float]("float4") + implicit val getFloatArray: GetResult[Seq[Float]] = mkGetResult(_.nextArray[Float]()) + implicit val getFloatArrayOption: GetResult[Option[Seq[Float]]] = mkGetResult(_.nextArrayOption[Float]()) + implicit val setFloatArray: SetParameter[Seq[Float]] = mkArraySetParameter[Float]("float4") + implicit val setFloatArrayOption: SetParameter[Option[Seq[Float]]] = mkArrayOptionSetParameter[Float]("float4") /// - implicit val getDoubleArray = mkGetResult(_.nextArray[Double]()) - implicit val getDoubleArrayOption = mkGetResult(_.nextArrayOption[Double]()) - implicit val setDoubleArray = mkArraySetParameter[Double]("float8") - implicit val setDoubleArrayOption = mkArrayOptionSetParameter[Double]("float8") + implicit val getDoubleArray: GetResult[Seq[Double]] = mkGetResult(_.nextArray[Double]()) + implicit val getDoubleArrayOption: GetResult[Option[Seq[Double]]] = mkGetResult(_.nextArrayOption[Double]()) + implicit val setDoubleArray: SetParameter[Seq[Double]] = mkArraySetParameter[Double]("float8") + implicit val setDoubleArrayOption: SetParameter[Option[Seq[Double]]] = mkArrayOptionSetParameter[Double]("float8") /// - implicit val getBoolArray = mkGetResult(_.nextArray[Boolean]()) - implicit val getBoolArrayOption = mkGetResult(_.nextArrayOption[Boolean]()) - implicit val setBoolArray = mkArraySetParameter[Boolean]("bool") - implicit val setBoolArrayOption = mkArrayOptionSetParameter[Boolean]("bool") + implicit val getBoolArray: GetResult[Seq[Boolean]] = mkGetResult(_.nextArray[Boolean]()) + implicit val getBoolArrayOption: GetResult[Option[Seq[Boolean]]] = mkGetResult(_.nextArrayOption[Boolean]()) + implicit val setBoolArray: SetParameter[Seq[Boolean]] = mkArraySetParameter[Boolean]("bool") + implicit val setBoolArrayOption: SetParameter[Option[Seq[Boolean]]] = mkArrayOptionSetParameter[Boolean]("bool") /// - implicit val getDateArray = mkGetResult(_.nextArray[Date]()) - implicit val getDateArrayOption = mkGetResult(_.nextArrayOption[Date]()) - implicit val setDateArray = mkArraySetParameter[Date]("date") - implicit val setDateArrayOption = mkArrayOptionSetParameter[Date]("date") + implicit val getDateArray: GetResult[Seq[Date]] = mkGetResult(_.nextArray[Date]()) + implicit val getDateArrayOption: GetResult[Option[Seq[Date]]] = mkGetResult(_.nextArrayOption[Date]()) + implicit val setDateArray: SetParameter[Seq[Date]] = mkArraySetParameter[Date]("date") + implicit val setDateArrayOption: SetParameter[Option[Seq[Date]]] = mkArrayOptionSetParameter[Date]("date") /// - implicit val getTimeArray = mkGetResult(_.nextArray[Time]()) - implicit val getTimeArrayOption = mkGetResult(_.nextArrayOption[Time]()) - implicit val setTimeArray = mkArraySetParameter[Time]("time") - implicit val setTimeArrayOption = mkArrayOptionSetParameter[Time]("time") + implicit val getTimeArray: GetResult[Seq[Time]] = mkGetResult(_.nextArray[Time]()) + implicit val getTimeArrayOption: GetResult[Option[Seq[Time]]] = mkGetResult(_.nextArrayOption[Time]()) + implicit val setTimeArray: SetParameter[Seq[Time]] = mkArraySetParameter[Time]("time") + implicit val setTimeArrayOption: SetParameter[Option[Seq[Time]]] = mkArrayOptionSetParameter[Time]("time") /// - implicit val getTimestampArray = mkGetResult(_.nextArray[Timestamp]()) - implicit val getTimestampArrayOption = mkGetResult(_.nextArrayOption[Timestamp]()) - implicit val setTimestampArray = mkArraySetParameter[Timestamp]("timestamp") - implicit val setTimestampArrayOption = mkArrayOptionSetParameter[Timestamp]("timestamp") + implicit val getTimestampArray: GetResult[Seq[Timestamp]] = mkGetResult(_.nextArray[Timestamp]()) + implicit val getTimestampArrayOption: GetResult[Option[Seq[Timestamp]]] = mkGetResult(_.nextArrayOption[Timestamp]()) + implicit val setTimestampArray: SetParameter[Seq[Timestamp]] = mkArraySetParameter[Timestamp]("timestamp") + implicit val setTimestampArrayOption: SetParameter[Option[Seq[Timestamp]]] = mkArrayOptionSetParameter[Timestamp]("timestamp") } } diff --git a/src/main/scala/com/github/tminglei/slickpg/PgDate2Support.scala b/src/main/scala/com/github/tminglei/slickpg/PgDate2Support.scala index 9fd9cfc2..271a7965 100644 --- a/src/main/scala/com/github/tminglei/slickpg/PgDate2Support.scala +++ b/src/main/scala/com/github/tminglei/slickpg/PgDate2Support.scala @@ -3,9 +3,8 @@ package com.github.tminglei.slickpg import java.time._ import java.time.format.{DateTimeFormatter, DateTimeFormatterBuilder} import java.time.temporal.ChronoField - import org.postgresql.util.PGInterval -import slick.jdbc.{JdbcType, PositionedResult, PostgresProfile} +import slick.jdbc.{GetResult, JdbcType, PositionedResult, PostgresProfile, SetParameter} import scala.reflect.{ClassTag, classTag} @@ -125,49 +124,49 @@ trait PgDate2Support extends date.PgDateExtensions with utils.PgCommonJdbcTypes implicit val date2ZoneIdMapper: JdbcType[ZoneId] = new GenericJdbcType[ZoneId]("text", ZoneId.of(_), _.getId, hasLiteralForm=false) /// - implicit def date2DateColumnExtensionMethods(c: Rep[LocalDate])(implicit tm: JdbcType[INTERVAL]) = + implicit def date2DateColumnExtensionMethods(c: Rep[LocalDate])(implicit tm: JdbcType[INTERVAL]): DateColumnExtensionMethods[LocalDate, LocalTime, LocalDateTime, INTERVAL, LocalDate] = new DateColumnExtensionMethods[LocalDate, LocalTime, LocalDateTime, INTERVAL, LocalDate](c) - implicit def date2DateOptColumnExtensionMethods(c: Rep[Option[LocalDate]])(implicit tm: JdbcType[INTERVAL]) = + implicit def date2DateOptColumnExtensionMethods(c: Rep[Option[LocalDate]])(implicit tm: JdbcType[INTERVAL]): DateColumnExtensionMethods[LocalDate, LocalTime, LocalDateTime, INTERVAL, Option[LocalDate]] = new DateColumnExtensionMethods[LocalDate, LocalTime, LocalDateTime, INTERVAL, Option[LocalDate]](c) - implicit def date2TimeColumnExtensionMethods(c: Rep[LocalTime])(implicit tm: JdbcType[INTERVAL]) = + implicit def date2TimeColumnExtensionMethods(c: Rep[LocalTime])(implicit tm: JdbcType[INTERVAL]): TimeColumnExtensionMethods[LocalDate, LocalTime, LocalDateTime, OffsetTime, INTERVAL, LocalTime] = new TimeColumnExtensionMethods[LocalDate, LocalTime, LocalDateTime, OffsetTime, INTERVAL, LocalTime](c) - implicit def date2TimeOptColumnExtensionMethods(c: Rep[Option[LocalTime]])(implicit tm: JdbcType[INTERVAL]) = + implicit def date2TimeOptColumnExtensionMethods(c: Rep[Option[LocalTime]])(implicit tm: JdbcType[INTERVAL]): TimeColumnExtensionMethods[LocalDate, LocalTime, LocalDateTime, OffsetTime, INTERVAL, Option[LocalTime]] = new TimeColumnExtensionMethods[LocalDate, LocalTime, LocalDateTime, OffsetTime, INTERVAL, Option[LocalTime]](c) - implicit def date2TimestampColumnExtensionMethods(c: Rep[LocalDateTime])(implicit tm: JdbcType[INTERVAL]) = + implicit def date2TimestampColumnExtensionMethods(c: Rep[LocalDateTime])(implicit tm: JdbcType[INTERVAL]): TimestampColumnExtensionMethods[LocalDate, LocalTime, LocalDateTime, OffsetDateTime, INTERVAL, LocalDateTime] = new TimestampColumnExtensionMethods[LocalDate, LocalTime, LocalDateTime, OffsetDateTime, INTERVAL, LocalDateTime](c) - implicit def date2TimestampOptColumnExtensionMethods(c: Rep[Option[LocalDateTime]])(implicit tm: JdbcType[INTERVAL]) = + implicit def date2TimestampOptColumnExtensionMethods(c: Rep[Option[LocalDateTime]])(implicit tm: JdbcType[INTERVAL]): TimestampColumnExtensionMethods[LocalDate, LocalTime, LocalDateTime, OffsetDateTime, INTERVAL, Option[LocalDateTime]] = new TimestampColumnExtensionMethods[LocalDate, LocalTime, LocalDateTime, OffsetDateTime, INTERVAL, Option[LocalDateTime]](c) - implicit def date2Timestamp1ColumnExtensionMethods(c: Rep[Instant])(implicit tm: JdbcType[INTERVAL]) = + implicit def date2Timestamp1ColumnExtensionMethods(c: Rep[Instant])(implicit tm: JdbcType[INTERVAL]): TimestampColumnExtensionMethods[LocalDate, LocalTime, Instant, OffsetDateTime, INTERVAL, Instant] = new TimestampColumnExtensionMethods[LocalDate, LocalTime, Instant, OffsetDateTime, INTERVAL, Instant](c) - implicit def date2Timestamp1OptColumnExtensionMethods(c: Rep[Option[Instant]])(implicit tm: JdbcType[INTERVAL]) = + implicit def date2Timestamp1OptColumnExtensionMethods(c: Rep[Option[Instant]])(implicit tm: JdbcType[INTERVAL]): TimestampColumnExtensionMethods[LocalDate, LocalTime, Instant, OffsetDateTime, INTERVAL, Option[Instant]] = new TimestampColumnExtensionMethods[LocalDate, LocalTime, Instant, OffsetDateTime, INTERVAL, Option[Instant]](c) - implicit def date2IntervalColumnExtensionMethods(c: Rep[Period]) = + implicit def date2IntervalColumnExtensionMethods(c: Rep[Period]): IntervalColumnExtensionMethods[LocalDate, LocalTime, LocalDateTime, Period, Period] = new IntervalColumnExtensionMethods[LocalDate, LocalTime, LocalDateTime, Period, Period](c) - implicit def date2IntervalOptColumnExtensionMethods(c: Rep[Option[Period]]) = + implicit def date2IntervalOptColumnExtensionMethods(c: Rep[Option[Period]]): IntervalColumnExtensionMethods[LocalDate, LocalTime, LocalDateTime, Period, Option[Period]] = new IntervalColumnExtensionMethods[LocalDate, LocalTime, LocalDateTime, Period, Option[Period]](c) - implicit def date2Interval1ColumnExtensionMethods(c: Rep[Duration]) = + implicit def date2Interval1ColumnExtensionMethods(c: Rep[Duration]): IntervalColumnExtensionMethods[LocalDate, LocalTime, LocalDateTime, Duration, Duration] = new IntervalColumnExtensionMethods[LocalDate, LocalTime, LocalDateTime, Duration, Duration](c) - implicit def date2Interval1OptColumnExtensionMethods(c: Rep[Option[Duration]]) = + implicit def date2Interval1OptColumnExtensionMethods(c: Rep[Option[Duration]]): IntervalColumnExtensionMethods[LocalDate, LocalTime, LocalDateTime, Duration, Option[Duration]] = new IntervalColumnExtensionMethods[LocalDate, LocalTime, LocalDateTime, Duration, Option[Duration]](c) - implicit def date2TzTimeColumnExtensionMethods(c: Rep[OffsetTime])(implicit tm: JdbcType[INTERVAL]) = + implicit def date2TzTimeColumnExtensionMethods(c: Rep[OffsetTime])(implicit tm: JdbcType[INTERVAL]): TimestampColumnExtensionMethods[LocalDate, OffsetTime, OffsetDateTime, LocalDateTime, INTERVAL, OffsetTime] = new TimestampColumnExtensionMethods[LocalDate, OffsetTime, OffsetDateTime, LocalDateTime, INTERVAL, OffsetTime](c) - implicit def date2TzTimeOptColumnExtensionMethods(c: Rep[Option[OffsetTime]])(implicit tm: JdbcType[INTERVAL]) = + implicit def date2TzTimeOptColumnExtensionMethods(c: Rep[Option[OffsetTime]])(implicit tm: JdbcType[INTERVAL]): TimestampColumnExtensionMethods[LocalDate, OffsetTime, OffsetDateTime, LocalDateTime, INTERVAL, Option[OffsetTime]] = new TimestampColumnExtensionMethods[LocalDate, OffsetTime, OffsetDateTime, LocalDateTime, INTERVAL, Option[OffsetTime]](c) - implicit def date2TzTimestampColumnExtensionMethods(c: Rep[OffsetDateTime])(implicit tm: JdbcType[INTERVAL]) = + implicit def date2TzTimestampColumnExtensionMethods(c: Rep[OffsetDateTime])(implicit tm: JdbcType[INTERVAL]): TimestampColumnExtensionMethods[LocalDate, OffsetTime, OffsetDateTime, LocalDateTime, INTERVAL, OffsetDateTime] = new TimestampColumnExtensionMethods[LocalDate, OffsetTime, OffsetDateTime, LocalDateTime, INTERVAL, OffsetDateTime](c) - implicit def date2TzTimestampOptColumnExtensionMethods(c: Rep[Option[OffsetDateTime]])(implicit tm: JdbcType[INTERVAL]) = + implicit def date2TzTimestampOptColumnExtensionMethods(c: Rep[Option[OffsetDateTime]])(implicit tm: JdbcType[INTERVAL]): TimestampColumnExtensionMethods[LocalDate, OffsetTime, OffsetDateTime, LocalDateTime, INTERVAL, Option[OffsetDateTime]] = new TimestampColumnExtensionMethods[LocalDate, OffsetTime, OffsetDateTime, LocalDateTime, INTERVAL, Option[OffsetDateTime]](c) - implicit def date2TzTimestamp1ColumnExtensionMethods(c: Rep[ZonedDateTime])(implicit tm: JdbcType[INTERVAL]) = + implicit def date2TzTimestamp1ColumnExtensionMethods(c: Rep[ZonedDateTime])(implicit tm: JdbcType[INTERVAL]): TimestampColumnExtensionMethods[LocalDate, OffsetTime, ZonedDateTime, LocalDateTime, INTERVAL, ZonedDateTime] = new TimestampColumnExtensionMethods[LocalDate, OffsetTime, ZonedDateTime, LocalDateTime, INTERVAL, ZonedDateTime](c) - implicit def date2TzTimestamp1OptColumnExtensionMethods(c: Rep[Option[ZonedDateTime]])(implicit tm: JdbcType[INTERVAL]) = + implicit def date2TzTimestamp1OptColumnExtensionMethods(c: Rep[Option[ZonedDateTime]])(implicit tm: JdbcType[INTERVAL]): TimestampColumnExtensionMethods[LocalDate, OffsetTime, ZonedDateTime, LocalDateTime, INTERVAL, Option[ZonedDateTime]] = new TimestampColumnExtensionMethods[LocalDate, OffsetTime, ZonedDateTime, LocalDateTime, INTERVAL, Option[ZonedDateTime]](c) /// helper classes to INTERVAL column @@ -214,55 +213,55 @@ trait PgDate2Support extends date.PgDateExtensions with utils.PgCommonJdbcTypes } ///////////////////////////////////////////////////////////////////////////// - implicit val getLocalDate = mkGetResult(_.nextLocalDate()) - implicit val getLocalDateOption = mkGetResult(_.nextLocalDateOption()) - implicit val setLocalDate = mkSetParameter[LocalDate]("date", toDateOrInfinity, sqlType = Types.DATE) - implicit val setLocalDateOption = mkOptionSetParameter[LocalDate]("date", toDateOrInfinity, sqlType = Types.DATE) - - implicit val getLocalTime = mkGetResult(_.nextLocalTime()) - implicit val getLocalTimeOption = mkGetResult(_.nextLocalTimeOption()) - implicit val setLocalTime = mkSetParameter[LocalTime]("time", _.format(date2TimeFormatter), sqlType = Types.TIME) - implicit val setLocalTimeOption = mkOptionSetParameter[LocalTime]("time", _.format(date2TimeFormatter), sqlType = Types.TIME) - - implicit val getLocalDateTime = mkGetResult(_.nextLocalDateTime()) - implicit val getLocalDateTimeOption = mkGetResult(_.nextLocalDateTimeOption()) - implicit val setLocalDateTime = mkSetParameter[LocalDateTime]("timestamp", toDateTimeOrInfinity, sqlType = Types.TIMESTAMP) - implicit val setLocalDateTimeOption = mkOptionSetParameter[LocalDateTime]("timestamp", toDateTimeOrInfinity, sqlType = Types.TIMESTAMP) - - implicit val getOffsetTime = mkGetResult(_.nextOffsetTime()) - implicit val getOffsetTimeOption = mkGetResult(_.nextOffsetTimeOption()) - implicit val setOffsetTime = mkSetParameter[OffsetTime]("timetz", _.format(date2TzTimeFormatter), sqlType = Types.TIME /*Types.TIME_WITH_TIMEZONE*/) - implicit val setOffsetTimeOption = mkOptionSetParameter[OffsetTime]("timetz", _.format(date2TzTimeFormatter), sqlType = Types.TIME /*Types.TIME_WITH_TIMEZONE*/) - - implicit val getOffsetDateTime = mkGetResult(_.nextOffsetDateTime()) - implicit val getOffsetDateTimeOption = mkGetResult(_.nextOffsetDateTimeOption()) - implicit val setOffsetDateTime = mkSetParameter[OffsetDateTime]("timestamptz", toOffsetDateTimeOrInfinity, sqlType = Types.TIMESTAMP /*Types.TIMESTAMP_WITH_TIMEZONE*/) - implicit val setOffsetDateTimeOption = mkOptionSetParameter[OffsetDateTime]("timestamptz", toOffsetDateTimeOrInfinity, sqlType = Types.TIMESTAMP /*Types.TIMESTAMP_WITH_TIMEZONE*/) - - implicit val getZonedDateTime = mkGetResult(_.nextZonedDateTime()) - implicit val getZonedDateTimeOption = mkGetResult(_.nextZonedDateTimeOption()) - implicit val setZonedDateTime = mkSetParameter[ZonedDateTime]("timestamptz", toZonedDateTimeOrInfinity, sqlType = Types.TIMESTAMP /*Types.TIMESTAMP_WITH_TIMEZONE*/) - implicit val setZonedDateTimeOption = mkOptionSetParameter[ZonedDateTime]("timestamptz", toZonedDateTimeOrInfinity, sqlType = Types.TIMESTAMP /*Types.TIMESTAMP_WITH_TIMEZONE*/) - - implicit val getInstant = mkGetResult(_.nextInstant()) - implicit val getInstantOption = mkGetResult(_.nextInstantOption()) - implicit val setInstant = mkSetParameter[Instant]("timestamp", toInstantOrInfinity, sqlType = Types.TIMESTAMP) - implicit val setInstantOption = mkOptionSetParameter[Instant]("timestamp", toInstantOrInfinity, sqlType = Types.TIMESTAMP) - - implicit val getPeriod = mkGetResult(_.nextPeriod()) - implicit val getPeriodOption = mkGetResult(_.nextPeriodOption()) - implicit val setPeriod = mkSetParameter[Period]("interval") - implicit val setPeriodOption = mkOptionSetParameter[Period]("interval") - - implicit val getDuration = mkGetResult(_.nextDuration()) - implicit val getDurationOption = mkGetResult(_.nextDurationOption()) - implicit val setDuration = mkSetParameter[Duration]("interval") - implicit val setDurationOption = mkOptionSetParameter[Duration]("interval") - - implicit val getZoneId = mkGetResult(_.nextZoneId()) - implicit val getZoneIdOption = mkGetResult(_.nextZoneIdOption()) - implicit val setZoneId = mkSetParameter[ZoneId]("text", sqlType = Types.VARCHAR) - implicit val setZoneIdOption = mkOptionSetParameter[ZoneId]("text", sqlType = Types.VARCHAR) + implicit val getLocalDate: GetResult[LocalDate] = mkGetResult(_.nextLocalDate()) + implicit val getLocalDateOption: GetResult[Option[LocalDate]] = mkGetResult(_.nextLocalDateOption()) + implicit val setLocalDate: SetParameter[LocalDate] = mkSetParameter[LocalDate]("date", toDateOrInfinity, sqlType = Types.DATE) + implicit val setLocalDateOption: SetParameter[Option[LocalDate]] = mkOptionSetParameter[LocalDate]("date", toDateOrInfinity, sqlType = Types.DATE) + + implicit val getLocalTime: GetResult[LocalTime] = mkGetResult(_.nextLocalTime()) + implicit val getLocalTimeOption: GetResult[Option[LocalTime]] = mkGetResult(_.nextLocalTimeOption()) + implicit val setLocalTime: SetParameter[LocalTime] = mkSetParameter[LocalTime]("time", _.format(date2TimeFormatter), sqlType = Types.TIME) + implicit val setLocalTimeOption: SetParameter[Option[LocalTime]] = mkOptionSetParameter[LocalTime]("time", _.format(date2TimeFormatter), sqlType = Types.TIME) + + implicit val getLocalDateTime: GetResult[LocalDateTime] = mkGetResult(_.nextLocalDateTime()) + implicit val getLocalDateTimeOption: GetResult[Option[LocalDateTime]] = mkGetResult(_.nextLocalDateTimeOption()) + implicit val setLocalDateTime: SetParameter[LocalDateTime] = mkSetParameter[LocalDateTime]("timestamp", toDateTimeOrInfinity, sqlType = Types.TIMESTAMP) + implicit val setLocalDateTimeOption: SetParameter[Option[LocalDateTime]] = mkOptionSetParameter[LocalDateTime]("timestamp", toDateTimeOrInfinity, sqlType = Types.TIMESTAMP) + + implicit val getOffsetTime: GetResult[OffsetTime] = mkGetResult(_.nextOffsetTime()) + implicit val getOffsetTimeOption: GetResult[Option[OffsetTime]] = mkGetResult(_.nextOffsetTimeOption()) + implicit val setOffsetTime: SetParameter[OffsetTime] = mkSetParameter[OffsetTime]("timetz", _.format(date2TzTimeFormatter), sqlType = Types.TIME /*Types.TIME_WITH_TIMEZONE*/) + implicit val setOffsetTimeOption: SetParameter[Option[OffsetTime]] = mkOptionSetParameter[OffsetTime]("timetz", _.format(date2TzTimeFormatter), sqlType = Types.TIME /*Types.TIME_WITH_TIMEZONE*/) + + implicit val getOffsetDateTime: GetResult[OffsetDateTime] = mkGetResult(_.nextOffsetDateTime()) + implicit val getOffsetDateTimeOption: GetResult[Option[OffsetDateTime]] = mkGetResult(_.nextOffsetDateTimeOption()) + implicit val setOffsetDateTime: SetParameter[OffsetDateTime] = mkSetParameter[OffsetDateTime]("timestamptz", toOffsetDateTimeOrInfinity, sqlType = Types.TIMESTAMP /*Types.TIMESTAMP_WITH_TIMEZONE*/) + implicit val setOffsetDateTimeOption: SetParameter[Option[OffsetDateTime]] = mkOptionSetParameter[OffsetDateTime]("timestamptz", toOffsetDateTimeOrInfinity, sqlType = Types.TIMESTAMP /*Types.TIMESTAMP_WITH_TIMEZONE*/) + + implicit val getZonedDateTime: GetResult[ZonedDateTime] = mkGetResult(_.nextZonedDateTime()) + implicit val getZonedDateTimeOption: GetResult[Option[ZonedDateTime]] = mkGetResult(_.nextZonedDateTimeOption()) + implicit val setZonedDateTime: SetParameter[ZonedDateTime] = mkSetParameter[ZonedDateTime]("timestamptz", toZonedDateTimeOrInfinity, sqlType = Types.TIMESTAMP /*Types.TIMESTAMP_WITH_TIMEZONE*/) + implicit val setZonedDateTimeOption: SetParameter[Option[ZonedDateTime]] = mkOptionSetParameter[ZonedDateTime]("timestamptz", toZonedDateTimeOrInfinity, sqlType = Types.TIMESTAMP /*Types.TIMESTAMP_WITH_TIMEZONE*/) + + implicit val getInstant: GetResult[Instant] = mkGetResult(_.nextInstant()) + implicit val getInstantOption: GetResult[Option[Instant]] = mkGetResult(_.nextInstantOption()) + implicit val setInstant: SetParameter[Instant] = mkSetParameter[Instant]("timestamp", toInstantOrInfinity, sqlType = Types.TIMESTAMP) + implicit val setInstantOption: SetParameter[Option[Instant]] = mkOptionSetParameter[Instant]("timestamp", toInstantOrInfinity, sqlType = Types.TIMESTAMP) + + implicit val getPeriod: GetResult[Period] = mkGetResult(_.nextPeriod()) + implicit val getPeriodOption: GetResult[Option[Period]] = mkGetResult(_.nextPeriodOption()) + implicit val setPeriod: SetParameter[Period] = mkSetParameter[Period]("interval") + implicit val setPeriodOption: SetParameter[Option[Period]] = mkOptionSetParameter[Period]("interval") + + implicit val getDuration: GetResult[Duration] = mkGetResult(_.nextDuration()) + implicit val getDurationOption: GetResult[Option[Duration]] = mkGetResult(_.nextDurationOption()) + implicit val setDuration: SetParameter[Duration] = mkSetParameter[Duration]("interval") + implicit val setDurationOption: SetParameter[Option[Duration]] = mkOptionSetParameter[Duration]("interval") + + implicit val getZoneId: GetResult[ZoneId] = mkGetResult(_.nextZoneId()) + implicit val getZoneIdOption: GetResult[Option[ZoneId]] = mkGetResult(_.nextZoneIdOption()) + implicit val setZoneId: SetParameter[ZoneId] = mkSetParameter[ZoneId]("text", sqlType = Types.VARCHAR) + implicit val setZoneIdOption: SetParameter[Option[ZoneId]] = mkOptionSetParameter[ZoneId]("text", sqlType = Types.VARCHAR) } } diff --git a/src/main/scala/com/github/tminglei/slickpg/PgDateSupport.scala b/src/main/scala/com/github/tminglei/slickpg/PgDateSupport.scala index 1c982506..e8d57e9e 100644 --- a/src/main/scala/com/github/tminglei/slickpg/PgDateSupport.scala +++ b/src/main/scala/com/github/tminglei/slickpg/PgDateSupport.scala @@ -16,29 +16,29 @@ trait PgDateSupport extends date.PgDateExtensions with utils.PgCommonJdbcTypes w implicit val simpleTimestampTZTypeMapper: JdbcType[Calendar] = new GenericDateJdbcType[Calendar]("timestamptz", java.sql.Types.TIMESTAMP_WITH_TIMEZONE) /// - implicit def simpleDateColumnExtensionMethods(c: Rep[Date]) = + implicit def simpleDateColumnExtensionMethods(c: Rep[Date]): DateColumnExtensionMethods[Date, Time, Timestamp, Interval, Date] = new DateColumnExtensionMethods[Date, Time, Timestamp, Interval, Date](c) - implicit def simpleDateOptColumnExtensionMethods(c: Rep[Option[Date]]) = + implicit def simpleDateOptColumnExtensionMethods(c: Rep[Option[Date]]): DateColumnExtensionMethods[Date, Time, Timestamp, Interval, Option[Date]] = new DateColumnExtensionMethods[Date, Time, Timestamp, Interval, Option[Date]](c) - implicit def simpleTimeColumnExtensionMethods(c: Rep[Time]) = + implicit def simpleTimeColumnExtensionMethods(c: Rep[Time]): TimeColumnExtensionMethods[Date, Time, Timestamp, Time, Interval, Time] = new TimeColumnExtensionMethods[Date, Time, Timestamp, Time, Interval, Time](c) - implicit def simpleTimeOptColumnExtensionMethods(c: Rep[Option[Time]]) = + implicit def simpleTimeOptColumnExtensionMethods(c: Rep[Option[Time]]): TimeColumnExtensionMethods[Date, Time, Timestamp, Time, Interval, Option[Time]] = new TimeColumnExtensionMethods[Date, Time, Timestamp, Time, Interval, Option[Time]](c) - implicit def simpleTimestampColumnExtensionMethods(c: Rep[Timestamp]) = + implicit def simpleTimestampColumnExtensionMethods(c: Rep[Timestamp]): TimestampColumnExtensionMethods[Date, Time, Timestamp, Calendar, Interval, Timestamp] = new TimestampColumnExtensionMethods[Date, Time, Timestamp, Calendar, Interval, Timestamp](c) - implicit def simpleTimestampOptColumnExtensionMethods(c: Rep[Option[Timestamp]]) = + implicit def simpleTimestampOptColumnExtensionMethods(c: Rep[Option[Timestamp]]): TimestampColumnExtensionMethods[Date, Time, Timestamp, Calendar, Interval, Option[Timestamp]] = new TimestampColumnExtensionMethods[Date, Time, Timestamp, Calendar, Interval, Option[Timestamp]](c) - implicit def simpleIntervalColumnExtensionMethods(c: Rep[Interval]) = + implicit def simpleIntervalColumnExtensionMethods(c: Rep[Interval]): IntervalColumnExtensionMethods[Date, Time, Timestamp, Interval, Interval] = new IntervalColumnExtensionMethods[Date, Time, Timestamp, Interval, Interval](c) - implicit def simpleIntervalOptColumnExtensionMethods(c: Rep[Option[Interval]]) = + implicit def simpleIntervalOptColumnExtensionMethods(c: Rep[Option[Interval]]): IntervalColumnExtensionMethods[Date, Time, Timestamp, Interval, Option[Interval]] = new IntervalColumnExtensionMethods[Date, Time, Timestamp, Interval, Option[Interval]](c) - implicit def simpleTimestampTZColumnExtensionMethods(c: Rep[Calendar]) = + implicit def simpleTimestampTZColumnExtensionMethods(c: Rep[Calendar]): TimestampColumnExtensionMethods[Date, Time, Calendar, Calendar, Interval, Calendar] = new TimestampColumnExtensionMethods[Date, Time, Calendar, Calendar, Interval, Calendar](c) - implicit def simpleTimestampTZOptColumnExtensionMethods(c: Rep[Option[Calendar]]) = + implicit def simpleTimestampTZOptColumnExtensionMethods(c: Rep[Option[Calendar]]): TimestampColumnExtensionMethods[Date, Time, Calendar, Calendar, Interval, Option[Calendar]] = new TimestampColumnExtensionMethods[Date, Time, Calendar, Calendar, Interval, Option[Calendar]](c) } } diff --git a/src/main/scala/com/github/tminglei/slickpg/PgHStoreSupport.scala b/src/main/scala/com/github/tminglei/slickpg/PgHStoreSupport.scala index a0a472ef..bf2155b4 100644 --- a/src/main/scala/com/github/tminglei/slickpg/PgHStoreSupport.scala +++ b/src/main/scala/com/github/tminglei/slickpg/PgHStoreSupport.scala @@ -2,9 +2,7 @@ package com.github.tminglei.slickpg import scala.jdk.CollectionConverters._ import scala.reflect.classTag - -import slick.jdbc.{JdbcType, PositionedResult, PostgresProfile} - +import slick.jdbc.{GetResult, JdbcType, PositionedResult, PostgresProfile, SetParameter} import org.postgresql.util.HStoreConverter @@ -30,10 +28,10 @@ trait PgHStoreSupport extends hstore.PgHStoreExtensions with utils.PgCommonJdbcT hasLiteralForm = false ) - implicit def simpleHStoreColumnExtensionMethods(c: Rep[Map[String, String]])(implicit tm: JdbcType[List[String]]) = { + implicit def simpleHStoreColumnExtensionMethods(c: Rep[Map[String, String]])(implicit tm: JdbcType[List[String]]): HStoreColumnExtensionMethods[Map[String, String]] = { new HStoreColumnExtensionMethods[Map[String, String]](c) } - implicit def simpleHStoreOptionColumnExtensionMethods(c: Rep[Option[Map[String,String]]])(implicit tm: JdbcType[List[String]]) = { + implicit def simpleHStoreOptionColumnExtensionMethods(c: Rep[Option[Map[String,String]]])(implicit tm: JdbcType[List[String]]): HStoreColumnExtensionMethods[Option[Map[String, String]]] = { new HStoreColumnExtensionMethods[Option[Map[String, String]]](c) } } @@ -50,11 +48,11 @@ trait PgHStoreSupport extends hstore.PgHStoreExtensions with utils.PgCommonJdbcT } //////////////////////////////////////////////////////////////////////// - implicit val getHStore = mkGetResult(_.nextHStore()) - implicit val getHStoreOption = mkGetResult(_.nextHStoreOption()) - implicit val setHStore = mkSetParameter[Map[String, String]]("hstore", + implicit val getHStore: GetResult[Map[String, String]] = mkGetResult(_.nextHStore()) + implicit val getHStoreOption: GetResult[Option[Map[String, String]]] = mkGetResult(_.nextHStoreOption()) + implicit val setHStore: SetParameter[Map[String, String]] = mkSetParameter[Map[String, String]]("hstore", (v) => HStoreConverter.toString(v.asJava)) - implicit val setHStoreOption = mkOptionSetParameter[Map[String, String]]("hstore", + implicit val setHStoreOption: SetParameter[Option[Map[String, String]]] = mkOptionSetParameter[Map[String, String]]("hstore", (v) => HStoreConverter.toString(v.asJava)) } } diff --git a/src/main/scala/com/github/tminglei/slickpg/PgJsonSupport.scala b/src/main/scala/com/github/tminglei/slickpg/PgJsonSupport.scala index 648425c1..8e626f3e 100644 --- a/src/main/scala/com/github/tminglei/slickpg/PgJsonSupport.scala +++ b/src/main/scala/com/github/tminglei/slickpg/PgJsonSupport.scala @@ -1,7 +1,8 @@ package com.github.tminglei.slickpg import com.github.tminglei.slickpg.utils.JsonUtils -import slick.jdbc.{JdbcType, PositionedResult, PostgresProfile} +import slick.jdbc.{GetResult, JdbcType, PositionedResult, PostgresProfile, SetParameter} + import scala.reflect.classTag /** simple json string wrapper */ @@ -37,10 +38,10 @@ trait PgJsonSupport extends json.PgJsonExtensions with utils.PgCommonJdbcTypes { hasLiteralForm = false ) - implicit def simpleJsonColumnExtensionMethods(c: Rep[JsonString]) = { + implicit def simpleJsonColumnExtensionMethods(c: Rep[JsonString]): JsonColumnExtensionMethods[JsonString, JsonString] = { new JsonColumnExtensionMethods[JsonString, JsonString](c) } - implicit def simpleJsonOptionColumnExtensionMethods(c: Rep[Option[JsonString]]) = { + implicit def simpleJsonOptionColumnExtensionMethods(c: Rep[Option[JsonString]]): JsonColumnExtensionMethods[JsonString, Option[JsonString]] = { new JsonColumnExtensionMethods[JsonString, Option[JsonString]](c) } } @@ -50,13 +51,13 @@ trait PgJsonSupport extends json.PgJsonExtensions with utils.PgCommonJdbcTypes { implicit class PgJsonPositionedResult(r: PositionedResult) { def nextJson() = nextJsonOption().orNull - def nextJsonOption() = r.nextStringOption().map(JsonString) + def nextJsonOption() = r.nextStringOption().map(JsonString.apply) } ////////////////////////////////////////////////////////////// - implicit val getJson = mkGetResult(_.nextJson()) - implicit val getJsonOption = mkGetResult(_.nextJsonOption()) - implicit val setJson = mkSetParameter[JsonString](pgjson, _.value) - implicit val setJsonOption = mkOptionSetParameter[JsonString](pgjson, _.value) + implicit val getJson: GetResult[JsonString] = mkGetResult(_.nextJson()) + implicit val getJsonOption: GetResult[Option[JsonString]] = mkGetResult(_.nextJsonOption()) + implicit val setJson: SetParameter[JsonString] = mkSetParameter[JsonString](pgjson, _.value) + implicit val setJsonOption: SetParameter[Option[JsonString]] = mkOptionSetParameter[JsonString](pgjson, _.value) } } diff --git a/src/main/scala/com/github/tminglei/slickpg/PgLTreeSupport.scala b/src/main/scala/com/github/tminglei/slickpg/PgLTreeSupport.scala index b00c0e44..37c00309 100644 --- a/src/main/scala/com/github/tminglei/slickpg/PgLTreeSupport.scala +++ b/src/main/scala/com/github/tminglei/slickpg/PgLTreeSupport.scala @@ -1,6 +1,7 @@ package com.github.tminglei.slickpg -import slick.jdbc.{JdbcType, PositionedResult, PostgresProfile} +import slick.jdbc.{GetResult, JdbcType, PositionedResult, PostgresProfile, SetParameter} + import scala.reflect.classTag /** simple ltree wrapper */ @@ -43,17 +44,17 @@ trait PgLTreeSupport extends ltree.PgLTreeExtensions with utils.PgCommonJdbcType hasLiteralForm = true ).to(_.toList) - implicit def simpleLTreeColumnExtensionMethods(c: Rep[LTree]) = { + implicit def simpleLTreeColumnExtensionMethods(c: Rep[LTree]): LTreeColumnExtensionMethods[LTree, LTree] = { new LTreeColumnExtensionMethods[LTree, LTree](c) } - implicit def simpleLTreeOptionColumnExtensionMethods(c: Rep[Option[LTree]]) = { + implicit def simpleLTreeOptionColumnExtensionMethods(c: Rep[Option[LTree]]): LTreeColumnExtensionMethods[LTree, Option[LTree]] = { new LTreeColumnExtensionMethods[LTree, Option[LTree]](c) } - implicit def simpleLTreeListColumnExtensionMethods(c: Rep[List[LTree]]) = { + implicit def simpleLTreeListColumnExtensionMethods(c: Rep[List[LTree]]): LTreeListColumnExtensionMethods[LTree, List[LTree]] = { new LTreeListColumnExtensionMethods[LTree, List[LTree]](c) } - implicit def simpleLTreeListOptionColumnExtensionMethods(c: Rep[Option[List[LTree]]]) = { + implicit def simpleLTreeListOptionColumnExtensionMethods(c: Rep[Option[List[LTree]]]): LTreeListColumnExtensionMethods[LTree, Option[List[LTree]]] = { new LTreeListColumnExtensionMethods[LTree, Option[List[LTree]]](c) } } @@ -72,12 +73,12 @@ trait PgLTreeSupport extends ltree.PgLTreeExtensions with utils.PgCommonJdbcType } /////////////////////////////////////////////////////////// - implicit val getLTree = mkGetResult(_.nextLTree()) - implicit val getLTreeOption = mkGetResult(_.nextLTreeOption()) - implicit val setLTree = mkSetParameter[LTree]("ltree") - implicit val setLTreeOption = mkOptionSetParameter[LTree]("ltree") + implicit val getLTree: GetResult[LTree] = mkGetResult(_.nextLTree()) + implicit val getLTreeOption: GetResult[Option[LTree]] = mkGetResult(_.nextLTreeOption()) + implicit val setLTree: SetParameter[LTree] = mkSetParameter[LTree]("ltree") + implicit val setLTreeOption: SetParameter[Option[LTree]] = mkOptionSetParameter[LTree]("ltree") /// - implicit val setLTreeArray = mkArraySetParameter[LTree]("ltree") - implicit val setLTreeArrayOption = mkArrayOptionSetParameter[LTree]("ltree") + implicit val setLTreeArray: SetParameter[Seq[LTree]] = mkArraySetParameter[LTree]("ltree") + implicit val setLTreeArrayOption: SetParameter[Option[Seq[LTree]]] = mkArrayOptionSetParameter[LTree]("ltree") } } diff --git a/src/main/scala/com/github/tminglei/slickpg/PgNetSupport.scala b/src/main/scala/com/github/tminglei/slickpg/PgNetSupport.scala index 1ddcc4e6..399071df 100644 --- a/src/main/scala/com/github/tminglei/slickpg/PgNetSupport.scala +++ b/src/main/scala/com/github/tminglei/slickpg/PgNetSupport.scala @@ -1,6 +1,7 @@ package com.github.tminglei.slickpg -import slick.jdbc.{JdbcType, PositionedResult, PostgresProfile} +import slick.jdbc.{GetResult, JdbcType, PositionedResult, PostgresProfile, SetParameter} + import scala.reflect.classTag /** simple inet string wrapper */ @@ -49,17 +50,17 @@ trait PgNetSupport extends net.PgNetExtensions with utils.PgCommonJdbcTypes { dr hasLiteralForm = false ) - implicit def simpleInetColumnExtensionMethods(c: Rep[InetString]) = { + implicit def simpleInetColumnExtensionMethods(c: Rep[InetString]): InetColumnExtensionMethods[InetString, InetString] = { new InetColumnExtensionMethods[InetString, InetString](c) } - implicit def simpleInetOptionColumnExtensionMethods(c: Rep[Option[InetString]]) = { + implicit def simpleInetOptionColumnExtensionMethods(c: Rep[Option[InetString]]): InetColumnExtensionMethods[InetString, Option[InetString]] = { new InetColumnExtensionMethods[InetString, Option[InetString]](c) } - implicit def simpleMacAddrColumnExtensionMethods(c: Rep[MacAddrString]) = { + implicit def simpleMacAddrColumnExtensionMethods(c: Rep[MacAddrString]): MacAddrColumnExtensionMethods[MacAddrString, MacAddrString] = { new MacAddrColumnExtensionMethods[MacAddrString, MacAddrString](c) } - implicit def simpleMacAddrOptionColumnExtensionMethods(c: Rep[Option[MacAddrString]]) = { + implicit def simpleMacAddrOptionColumnExtensionMethods(c: Rep[Option[MacAddrString]]): MacAddrColumnExtensionMethods[MacAddrString, Option[MacAddrString]] = { new MacAddrColumnExtensionMethods[MacAddrString, Option[MacAddrString]](c) } } @@ -75,20 +76,20 @@ trait PgNetSupport extends net.PgNetExtensions with utils.PgCommonJdbcTypes { dr implicit class PgNetPositionedResult(r: PositionedResult) { def nextIPAddr() = nextIPAddrOption().orNull - def nextIPAddrOption() = r.nextStringOption().map(InetString) + def nextIPAddrOption() = r.nextStringOption().map(InetString.apply) def nextMacAddr() = nextMacAddrOption().orNull - def nextMacAddrOption() = r.nextStringOption().map(MacAddrString) + def nextMacAddrOption() = r.nextStringOption().map(MacAddrString.apply) } ///////////////////////////////////////////////////////////////// - implicit val getIPAddr = mkGetResult(_.nextIPAddr()) - implicit val getIPAddrOption = mkGetResult(_.nextIPAddrOption()) - implicit val setIPAddr = mkSetParameter[InetString]("inet", _.value) - implicit val setIPAddrOption = mkOptionSetParameter[InetString]("inet", _.value) + implicit val getIPAddr: GetResult[InetString] = mkGetResult(_.nextIPAddr()) + implicit val getIPAddrOption: GetResult[Option[InetString]] = mkGetResult(_.nextIPAddrOption()) + implicit val setIPAddr: SetParameter[InetString] = mkSetParameter[InetString]("inet", _.value) + implicit val setIPAddrOption: SetParameter[Option[InetString]] = mkOptionSetParameter[InetString]("inet", _.value) - implicit val getMacAddr = mkGetResult(_.nextMacAddr()) - implicit val getMacAddrOption = mkGetResult(_.nextMacAddrOption()) - implicit val setMacAddr = mkSetParameter[MacAddrString]("macaddr", _.value) - implicit val setMacAddrOption = mkOptionSetParameter[MacAddrString]("macaddr", _.value) + implicit val getMacAddr: GetResult[MacAddrString] = mkGetResult(_.nextMacAddr()) + implicit val getMacAddrOption: GetResult[Option[MacAddrString]] = mkGetResult(_.nextMacAddrOption()) + implicit val setMacAddr: SetParameter[MacAddrString] = mkSetParameter[MacAddrString]("macaddr", _.value) + implicit val setMacAddrOption: SetParameter[Option[MacAddrString]] = mkOptionSetParameter[MacAddrString]("macaddr", _.value) } } diff --git a/src/main/scala/com/github/tminglei/slickpg/PgRangeSupport.scala b/src/main/scala/com/github/tminglei/slickpg/PgRangeSupport.scala index fec50017..c5b35ab7 100644 --- a/src/main/scala/com/github/tminglei/slickpg/PgRangeSupport.scala +++ b/src/main/scala/com/github/tminglei/slickpg/PgRangeSupport.scala @@ -2,8 +2,7 @@ package com.github.tminglei.slickpg import java.sql.{Date, Timestamp} import java.time.{LocalDate, LocalDateTime, OffsetDateTime} - -import slick.jdbc.{JdbcType, PositionedResult, PostgresProfile} +import slick.jdbc.{GetResult, JdbcType, PositionedResult, PostgresProfile, SetParameter} import scala.reflect.classTag @@ -76,11 +75,11 @@ trait PgRangeSupport extends range.PgRangeExtensions with utils.PgCommonJdbcType implicit val simpleLocalDateRangeTypeMapper: JdbcType[Range[LocalDate]] = new GenericJdbcType[Range[LocalDate]]("daterange", mkRangeFn(fromDateOrInfinity)) implicit def simpleRangeColumnExtensionMethods[B0](c: Rep[Range[B0]])( - implicit tm: JdbcType[B0], tm1: JdbcType[Range[B0]]) = { + implicit tm: JdbcType[B0], tm1: JdbcType[Range[B0]]): RangeColumnExtensionMethods[Range[B0], B0, Range[B0]] = { new RangeColumnExtensionMethods[Range[B0], B0, Range[B0]](c) } implicit def simpleRangeOptionColumnExtensionMethods[B0](c: Rep[Option[Range[B0]]])( - implicit tm: JdbcType[B0], tm1: JdbcType[Range[B0]]) = { + implicit tm: JdbcType[B0], tm1: JdbcType[Range[B0]]): RangeColumnExtensionMethods[Range[B0], B0, Option[Range[B0]]] = { new RangeColumnExtensionMethods[Range[B0], B0, Option[Range[B0]]](c) } } @@ -120,45 +119,45 @@ trait PgRangeSupport extends range.PgRangeExtensions with utils.PgCommonJdbcType } //////////////////////////////////////////////////////////////////// - implicit val getIntRange = mkGetResult(_.nextIntRange()) - implicit val getIntRangeOption = mkGetResult(_.nextIntRangeOption()) - implicit val setIntRange = mkSetParameter[Range[Int]]("int4range") - implicit val setIntRangeOption = mkOptionSetParameter[Range[Int]]("int4range") - - implicit val getLongRange = mkGetResult(_.nextLongRange()) - implicit val getLongRangeOption = mkGetResult(_.nextLongRangeOption()) - implicit val setLongRange = mkSetParameter[Range[Long]]("int8range") - implicit val setLongRangeOption = mkOptionSetParameter[Range[Long]]("int8range") - - implicit val getFloatRange = mkGetResult(_.nextFloatRange()) - implicit val getFloatRangeOption = mkGetResult(_.nextFloatRangeOption()) - implicit val setFloatRange = mkSetParameter[Range[Float]]("numrange") - implicit val setFloatRangeOption = mkOptionSetParameter[Range[Float]]("numrange") - - implicit val getTimestampRange = mkGetResult(_.nextTimestampRange()) - implicit val getTimestampRangeOption = mkGetResult(_.nextTimestampRangeOption()) - implicit val setTimestampRange = mkSetParameter[Range[Timestamp]]("tsrange") - implicit val setTimestampRangeOption = mkOptionSetParameter[Range[Timestamp]]("tsrange") - - implicit val getDateRange = mkGetResult(_.nextDateRange()) - implicit val getDateRangeOption = mkGetResult(_.nextDateRangeOption()) - implicit val setDateRange = mkSetParameter[Range[Date]]("daterange") - implicit val setDateRangeOption = mkOptionSetParameter[Range[Date]]("daterange") - - implicit val getLocalDateTimeRange = mkGetResult(_.nextLocalDateTimeRange()) - implicit val getLocalDateTimeRangeOption = mkGetResult(_.nextLocalDateTimeRangeOption()) - implicit val setLocalDateTimeRange = mkSetParameter[Range[LocalDateTime]]("tsrange") - implicit val setLocalDateTimeRangeOption = mkOptionSetParameter[Range[LocalDateTime]]("tsrange") - - implicit val getOffsetDateTimeRange = mkGetResult(_.nextOffsetDateTimeRange()) - implicit val getOffsetDateTimeRangeOption = mkGetResult(_.nextOffsetDateTimeRangeOption()) - implicit val setOffsetDateTimeRange = mkSetParameter[Range[OffsetDateTime]]("tsrange") - implicit val setOffsetDateTimeRangeOption = mkOptionSetParameter[Range[OffsetDateTime]]("tsrange") - - implicit val getLocalDateRange = mkGetResult(_.nextLocalDateRange()) - implicit val getLocalDateRangeOption = mkGetResult(_.nextLocalDateRangeOption()) - implicit val setLocalDateRange = mkSetParameter[Range[LocalDate]]("daterange") - implicit val setLocalDateRangeOption = mkOptionSetParameter[Range[LocalDate]]("daterange") + implicit val getIntRange: GetResult[Range[Int]] = mkGetResult(_.nextIntRange()) + implicit val getIntRangeOption: GetResult[Option[Range[Int]]] = mkGetResult(_.nextIntRangeOption()) + implicit val setIntRange: SetParameter[Range[Int]] = mkSetParameter[Range[Int]]("int4range") + implicit val setIntRangeOption: SetParameter[Option[Range[Int]]] = mkOptionSetParameter[Range[Int]]("int4range") + + implicit val getLongRange: GetResult[Range[Long]] = mkGetResult(_.nextLongRange()) + implicit val getLongRangeOption: GetResult[Option[Range[Long]]] = mkGetResult(_.nextLongRangeOption()) + implicit val setLongRange: SetParameter[Range[Long]] = mkSetParameter[Range[Long]]("int8range") + implicit val setLongRangeOption: SetParameter[Option[Range[Long]]] = mkOptionSetParameter[Range[Long]]("int8range") + + implicit val getFloatRange: GetResult[Range[Float]] = mkGetResult(_.nextFloatRange()) + implicit val getFloatRangeOption: GetResult[Option[Range[Float]]] = mkGetResult(_.nextFloatRangeOption()) + implicit val setFloatRange: SetParameter[Range[Float]] = mkSetParameter[Range[Float]]("numrange") + implicit val setFloatRangeOption: SetParameter[Option[Range[Float]]] = mkOptionSetParameter[Range[Float]]("numrange") + + implicit val getTimestampRange: GetResult[Range[Timestamp]] = mkGetResult(_.nextTimestampRange()) + implicit val getTimestampRangeOption: GetResult[Option[Range[Timestamp]]] = mkGetResult(_.nextTimestampRangeOption()) + implicit val setTimestampRange: SetParameter[Range[Timestamp]] = mkSetParameter[Range[Timestamp]]("tsrange") + implicit val setTimestampRangeOption: SetParameter[Option[Range[Timestamp]]] = mkOptionSetParameter[Range[Timestamp]]("tsrange") + + implicit val getDateRange: GetResult[Range[Date]] = mkGetResult(_.nextDateRange()) + implicit val getDateRangeOption: GetResult[Option[Range[Date]]] = mkGetResult(_.nextDateRangeOption()) + implicit val setDateRange: SetParameter[Range[Date]] = mkSetParameter[Range[Date]]("daterange") + implicit val setDateRangeOption: SetParameter[Option[Range[Date]]] = mkOptionSetParameter[Range[Date]]("daterange") + + implicit val getLocalDateTimeRange: GetResult[Range[LocalDateTime]] = mkGetResult(_.nextLocalDateTimeRange()) + implicit val getLocalDateTimeRangeOption: GetResult[Option[Range[LocalDateTime]]] = mkGetResult(_.nextLocalDateTimeRangeOption()) + implicit val setLocalDateTimeRange: SetParameter[Range[LocalDateTime]] = mkSetParameter[Range[LocalDateTime]]("tsrange") + implicit val setLocalDateTimeRangeOption: SetParameter[Option[Range[LocalDateTime]]] = mkOptionSetParameter[Range[LocalDateTime]]("tsrange") + + implicit val getOffsetDateTimeRange: GetResult[Range[OffsetDateTime]] = mkGetResult(_.nextOffsetDateTimeRange()) + implicit val getOffsetDateTimeRangeOption: GetResult[Option[Range[OffsetDateTime]]] = mkGetResult(_.nextOffsetDateTimeRangeOption()) + implicit val setOffsetDateTimeRange: SetParameter[Range[OffsetDateTime]] = mkSetParameter[Range[OffsetDateTime]]("tsrange") + implicit val setOffsetDateTimeRangeOption: SetParameter[Option[Range[OffsetDateTime]]] = mkOptionSetParameter[Range[OffsetDateTime]]("tsrange") + + implicit val getLocalDateRange: GetResult[Range[LocalDate]] = mkGetResult(_.nextLocalDateRange()) + implicit val getLocalDateRangeOption: GetResult[Option[Range[LocalDate]]] = mkGetResult(_.nextLocalDateRangeOption()) + implicit val setLocalDateRange: SetParameter[Range[LocalDate]] = mkSetParameter[Range[LocalDate]]("daterange") + implicit val setLocalDateRangeOption: SetParameter[Option[Range[LocalDate]]] = mkOptionSetParameter[Range[LocalDate]]("daterange") } } diff --git a/src/main/scala/com/github/tminglei/slickpg/PgSearchSupport.scala b/src/main/scala/com/github/tminglei/slickpg/PgSearchSupport.scala index b343b521..ef97a136 100644 --- a/src/main/scala/com/github/tminglei/slickpg/PgSearchSupport.scala +++ b/src/main/scala/com/github/tminglei/slickpg/PgSearchSupport.scala @@ -1,6 +1,7 @@ package com.github.tminglei.slickpg -import slick.jdbc.{JdbcType, PositionedResult, PostgresProfile} +import slick.jdbc.{GetResult, JdbcType, PositionedResult, PostgresProfile, SetParameter} + import scala.reflect.classTag /** simple tsvector/tsquery string wrapper */ @@ -24,19 +25,19 @@ trait PgSearchSupport extends search.PgSearchExtensions with utils.PgCommonJdbcT trait SearchImplicits extends SimpleSearchImplicits trait SimpleSearchImplicits extends SearchCodeGenSupport { - implicit val simpleTsVectorTypeMapper: JdbcType[TsVector] = new GenericJdbcType[TsVector]("tsvector", TsVector, _.value) - implicit val simpleTsQueryTypeMapper: JdbcType[TsQuery] = new GenericJdbcType[TsQuery]("tsquery", TsQuery, _.value) + implicit val simpleTsVectorTypeMapper: JdbcType[TsVector] = new GenericJdbcType[TsVector]("tsvector", TsVector.apply, _.value) + implicit val simpleTsQueryTypeMapper: JdbcType[TsQuery] = new GenericJdbcType[TsQuery]("tsquery", TsQuery.apply, _.value) - implicit def simpleTsVectorColumnExtensionMethods(c: Rep[TsVector]) = { + implicit def simpleTsVectorColumnExtensionMethods(c: Rep[TsVector]): TsVectorColumnExtensionMethods[TsVector, TsQuery, TsVector] = { new TsVectorColumnExtensionMethods[TsVector, TsQuery, TsVector](c) } - implicit def simpleTsVectorOptionColumnExtensionMethods(c: Rep[Option[TsVector]]) = { + implicit def simpleTsVectorOptionColumnExtensionMethods(c: Rep[Option[TsVector]]): TsVectorColumnExtensionMethods[TsVector, TsQuery, Option[TsVector]] = { new TsVectorColumnExtensionMethods[TsVector, TsQuery, Option[TsVector]](c) } - implicit def simpleTsQueryColumnExtensionMethods(c: Rep[TsQuery]) = { + implicit def simpleTsQueryColumnExtensionMethods(c: Rep[TsQuery]): TsQueryColumnExtensionMethods[TsVector, TsQuery, TsQuery] = { new TsQueryColumnExtensionMethods[TsVector, TsQuery, TsQuery](c) } - implicit def simpleTsQueryOptionColumnExtensionMethods(c: Rep[Option[TsQuery]]) = { + implicit def simpleTsQueryOptionColumnExtensionMethods(c: Rep[Option[TsQuery]]): TsQueryColumnExtensionMethods[TsVector, TsQuery, Option[TsQuery]] = { new TsQueryColumnExtensionMethods[TsVector, TsQuery, Option[TsQuery]](c) } } @@ -46,20 +47,20 @@ trait PgSearchSupport extends search.PgSearchExtensions with utils.PgCommonJdbcT implicit class PgSearchPositionedResult(r: PositionedResult) { def nextTsVector() = nextTsVectorOption().orNull - def nextTsVectorOption() = r.nextStringOption().map(TsVector) + def nextTsVectorOption() = r.nextStringOption().map(TsVector.apply) def nextTsQuery() = nextTsQueryOption().orNull - def nextTsQueryOption() = r.nextStringOption().map(TsQuery) + def nextTsQueryOption() = r.nextStringOption().map(TsQuery.apply) } //////////////////////////////////////////////////////////////// - implicit val getTsVector = mkGetResult(_.nextTsVector()) - implicit val getTsVectorOption = mkGetResult(_.nextTsVectorOption()) - implicit val setTsVector = mkSetParameter[TsVector]("tsvector", _.value) - implicit val setTsVectorOption = mkOptionSetParameter[TsVector]("tsvector", _.value) + implicit val getTsVector: GetResult[TsVector] = mkGetResult(_.nextTsVector()) + implicit val getTsVectorOption: GetResult[Option[TsVector]] = mkGetResult(_.nextTsVectorOption()) + implicit val setTsVector: SetParameter[TsVector] = mkSetParameter[TsVector]("tsvector", _.value) + implicit val setTsVectorOption: SetParameter[Option[TsVector]] = mkOptionSetParameter[TsVector]("tsvector", _.value) - implicit val getTsQuery = mkGetResult(_.nextTsQuery()) - implicit val getTsQueryOption = mkGetResult(_.nextTsQueryOption()) - implicit val setTsQuery = mkSetParameter[TsQuery]("tsquery", _.value) - implicit val setTsQueryOption = mkOptionSetParameter[TsQuery]("tsquery", _.value) + implicit val getTsQuery: GetResult[TsQuery] = mkGetResult(_.nextTsQuery()) + implicit val getTsQueryOption: GetResult[Option[TsQuery]] = mkGetResult(_.nextTsQueryOption()) + implicit val setTsQuery: SetParameter[TsQuery] = mkSetParameter[TsQuery]("tsquery", _.value) + implicit val setTsQueryOption: SetParameter[Option[TsQuery]] = mkOptionSetParameter[TsQuery]("tsquery", _.value) } }