Skip to content

Commit

Permalink
remove zero default
Browse files Browse the repository at this point in the history
  • Loading branch information
tminglei committed Aug 19, 2016
1 parent 95d298e commit 7d4b0dd
Show file tree
Hide file tree
Showing 11 changed files with 1 addition and 27 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ trait PgArgonautSupport extends json.PgJsonExtensions with utils.PgCommonJdbcTyp
pgjson,
(s) => s.parse.toOption.getOrElse(jNull),
(v) => v.nospaces,
zero = jNull,
hasLiteralForm = false
)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,10 +60,6 @@ class PgArgonautSupportSuite extends FunSuite {
JsonTests.filter(_.id === testRec2.id.bind).map(_.json).result.head.map(
r => assert(jArray(List(json1,json2)) === r)
),
// null return
JsonTests.filter(_.json.+>>("a") === "101").map(_.json.+>("d")).result.head.map(
r => assert(jNull === r)
),
// ->>/->
JsonTests.filter(_.json.+>>("a") === "101".bind).map(_.json.+>>("c")).result.head.map(
r => assert("[3,4,5,9]" === r.replace(" ", ""))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ trait PgCirceJsonSupport extends json.PgJsonExtensions with utils.PgCommonJdbcTy
pgjson,
(v) => parse(v).getOrElse(Json.Null),
(v) => v.asJson.spaces2,
zero = Json.Null,
hasLiteralForm = false
)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,10 +56,6 @@ class PgCirceJsonSupportSuite extends FunSuite {
JsonTests.filter(_.id === testRec2.id.bind).map(_.json).result.head.map(
r => assert(Json.array(json1, json2) === r)
),
// null return
JsonTests.filter(_.json.+>>("a") === "101").map(_.json.+>("d")).result.head.map(
r => assert(Json.Empty === r)
),
// ->>/->
JsonTests.filter(_.json.+>>("a") === "101".bind).map(_.json.+>>("c")).result.head.map(
r => assert("[3,4,5,9]" === r.replace(" ", ""))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ trait PgJson4sSupport extends json.PgJsonExtensions with utils.PgCommonJdbcTypes
pgjson,
(s) => jsonMethods.parse(s),
(v) => jsonMethods.compact(jsonMethods.render(v)),
zero = JNull,
hasLiteralForm = false
)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,10 +72,6 @@ class PgJson4sSupportSuite extends FunSuite {
JsonTests.to[List].result.map(
r => assert(List(testRec1, testRec2, testRec3) === r)
),
// null return
JsonTests.filter(_.json.+>>("a") === "101").map(_.json.+>("d")).result.head.map(
r => assert(JNull === r)
),
// ->>/->
JsonTests.filter(_.json.+>>("a") === "101").map(_.json.+>>("c")).result.head.map(
r => assert("[3,4,5,9]" === r.replace(" ", ""))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ trait PgPlayJsonSupport extends json.PgJsonExtensions with utils.PgCommonJdbcTyp
pgjson,
(v) => Json.parse(v),
(v) => Json.stringify(v),
zero = JsNull,
hasLiteralForm = false
)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,10 +79,6 @@ class PgPlayJsonSupportSuite extends FunSuite {
JsonTests.to[List].result.map(
r => assert(List(testRec1, testRec2, testRec3) === r)
),
// null return
JsonTests.filter(_.json.+>>("a") === "101").map(_.json.+>("d")).result.head.map(
r => assert(JsNull === r)
),
// ->>/->
JsonTests.filter(_.json.+>>("a") === "101").map(_.json.+>>("c")).result.head.map(
r => assert("[3,4,5,9]" === r.replace(" ", ""))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ trait PgSprayJsonSupport extends json.PgJsonExtensions with utils.PgCommonJdbcTy
pgjson,
(s) => s.parseJson,
(v) => v.toJson.compactPrint,
zero = JsNull,
hasLiteralForm = false
)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,10 +70,6 @@ class PgSprayJsonSupportSuite extends FunSuite {
JsonTests.filter(_.id === testRec2.id.bind).map(_.jbean).result.head.map(
r => assert(JBean("t1", 5) === r)
),
// null return
JsonTests.filter(_.json.+>>("a") === "101").map(_.json.+>("d")).result.head.map(
r => assert(JsNull === r)
),
// ->>/->
JsonTests.filter(_.json.+>>("a") === "101").map(_.json.+>>("c")).result.head.map(
r => assert("[3,4,5,9]" === r.replace(" ", ""))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,14 @@ trait PgCommonJdbcTypes extends JdbcTypesComponent { driver: PostgresProfile =>
fnFromString: (String => T),
fnToString: (T => String) = ((r: T) => r.toString),
val sqlType: Int = java.sql.Types.OTHER,
zero: T = null.asInstanceOf[T],
override val hasLiteralForm: Boolean = false)(
implicit override val classTag: ClassTag[T]) extends DriverJdbcType[T] {

override def sqlTypeName(sym: Option[FieldSymbol]): String = sqlTypeName

override def getValue(r: ResultSet, idx: Int): T = {
val value = r.getString(idx)
if (r.wasNull) zero else fnFromString(value)
if (r.wasNull) null.asInstanceOf[T] else fnFromString(value)
}

override def setValue(v: T, p: PreparedStatement, idx: Int): Unit = p.setObject(idx, toStr(v), java.sql.Types.OTHER)
Expand Down

0 comments on commit 7d4b0dd

Please sign in to comment.