@@ -15,7 +15,8 @@ import org.joda.time.DateTime
15
15
import play .api .libs .json .{ JsValue , Json }
16
16
import slick .jdbc .JdbcType
17
17
18
- trait HATPostgresProfile extends ExPostgresProfile
18
+ trait HATPostgresProfile
19
+ extends ExPostgresProfile
19
20
with PgArraySupport
20
21
with PgDateSupportJoda
21
22
with PgRangeSupport
@@ -27,9 +28,10 @@ trait HATPostgresProfile extends ExPostgresProfile
27
28
override val api = new HatAPI {}
28
29
override protected lazy val useTransactionForUpsert = false
29
30
30
- trait HatAPI extends super .API
31
+ trait HatAPI
32
+ extends super .API
31
33
with ArrayImplicits
32
- with DateTimeImplicits
34
+ with JodaDateTimeImplicits
33
35
with RangeImplicits
34
36
with HStoreImplicits
35
37
with SearchImplicits
@@ -39,39 +41,40 @@ trait HATPostgresProfile extends ExPostgresProfile
39
41
implicit val playJsonArrayTypeMapper : DriverJdbcType [List [JsValue ]] =
40
42
new AdvancedArrayJdbcType [JsValue ](
41
43
pgjson,
42
- (s) => utils.SimpleArrayUtils .fromString[JsValue ](Json .parse(_))(s).orNull,
43
- (v) => utils.SimpleArrayUtils .mkString[JsValue ](_.toString())(v)).to(_.toList)
44
+ s => utils.SimpleArrayUtils .fromString[JsValue ](Json .parse(_))(s).orNull,
45
+ v => utils.SimpleArrayUtils .mkString[JsValue ](_.toString())(v)).to(_.toList)
44
46
45
47
import scala .language .implicitConversions
46
48
47
- override implicit val playJsonTypeMapper : JdbcType [JsValue ] =
49
+ implicit override val playJsonTypeMapper : JdbcType [JsValue ] =
48
50
new GenericJdbcType [JsValue ](
49
51
pgjson,
50
- (v) => Json .parse(v),
51
- (v) => Json .stringify(v).replace(" \\ u0000" , " " ),
52
+ v => Json .parse(v),
53
+ v => Json .stringify(v).replace(" \\ u0000" , " " ),
52
54
hasLiteralForm = false )
53
55
54
- override implicit def playJsonColumnExtensionMethods (c : Rep [JsValue ]): FixedJsonColumnExtensionMethods [JsValue , JsValue ] = {
56
+ implicit override def playJsonColumnExtensionMethods (
57
+ c : Rep [JsValue ]): FixedJsonColumnExtensionMethods [JsValue , JsValue ] =
55
58
new FixedJsonColumnExtensionMethods [JsValue , JsValue ](c)
56
- }
57
- override implicit def playJsonOptionColumnExtensionMethods ( c : Rep [Option [JsValue ]]): FixedJsonColumnExtensionMethods [JsValue , Option [JsValue ]] = {
59
+ implicit override def playJsonOptionColumnExtensionMethods (
60
+ c : Rep [Option [JsValue ]]): FixedJsonColumnExtensionMethods [JsValue , Option [JsValue ]] =
58
61
new FixedJsonColumnExtensionMethods [JsValue , Option [JsValue ]](c)
59
- }
60
62
61
- class FixedJsonColumnExtensionMethods [JSONType , P1 ](override val c : Rep [ P1 ])(
62
- implicit
63
- tm : JdbcType [ JSONType ]) extends JsonColumnExtensionMethods [JSONType , P1 ](c) {
64
- override def <@: [P2 , R ](c2 : Rep [P2 ])(implicit om : o# arg[JSONType , P2 ]# to[Boolean , R ]) = {
63
+ class FixedJsonColumnExtensionMethods [JSONType , P1 ](
64
+ override val c : Rep [ P1 ])( implicit tm : JdbcType [ JSONType ])
65
+ extends JsonColumnExtensionMethods [JSONType , P1 ](c) {
66
+ override def <@: [P2 , R ](c2 : Rep [P2 ])(implicit om : o# arg[JSONType , P2 ]# to[Boolean , R ]) =
65
67
om.column(jsonLib.ContainsBy , n, c2.toNode)
66
- }
67
68
}
68
69
69
70
val toJson : Rep [String ] => Rep [JsValue ] = SimpleFunction .unary[String , JsValue ](" to_jsonb" )
70
71
def toJsonGeneric [T ]: Rep [T ] => Rep [JsValue ] = SimpleFunction .unary[T , JsValue ](" to_jsonb" )
71
72
def toJsonGenericOptional [T ](c : Rep [T ]) = SimpleFunction [Option [JsValue ]](" to_jsonb" ).apply(Seq (c))
72
73
val toTimestamp : Rep [Double ] => Rep [Timestamp ] = SimpleFunction .unary[Double , Timestamp ](" to_timestamp" )
73
- val datePart : (Rep [String ], Rep [DateTime ]) => Rep [String ] = SimpleFunction .binary[String , DateTime , String ](" date_part" )
74
- val datePartTimestamp : (Rep [String ], Rep [Timestamp ]) => Rep [String ] = SimpleFunction .binary[String , Timestamp , String ](" date_part" )
74
+ val datePart : (Rep [String ], Rep [DateTime ]) => Rep [String ] =
75
+ SimpleFunction .binary[String , DateTime , String ](" date_part" )
76
+ val datePartTimestamp : (Rep [String ], Rep [Timestamp ]) => Rep [String ] =
77
+ SimpleFunction .binary[String , Timestamp , String ](" date_part" )
75
78
}
76
79
77
80
}
0 commit comments