8000 Workaround for string issue · IBlogLab/postgresql-async@de01a77 · GitHub
[go: up one dir, main page]

Skip to content

Commit de01a77

Browse files
committed
Workaround for string issue
1 parent 37c85b6 commit de01a77

File tree

1 file changed

+31
-21
lines changed

1 file changed

+31
-21
lines changed

postgresql-async/src/test/scala/com/github/mauricio/async/db/postgresql/PreparedStatementSpec.scala

Lines changed: 31 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -217,31 +217,41 @@ class PreparedStatementSpec extends Specification with DatabaseTestHelper {
217217

218218
"support handling JSON type" in {
219219

220-
pending("travis-ci PG doesn't have the JSON type")
220+
if ( System.getenv("TRAVIS") == null ) {
221+
withHandler {
222+
handler =>
223+
val create = """create temp table people
224+
|(
225+
|id bigserial primary key,
226+
|addresses json,
227+
|phones json
228+
|);""".stripMargin
229+
230+
val insert = "INSERT INTO people (addresses, phones) VALUES (?,?) RETURNING id"
231+
val select = "SELECT * FROM people"
232+
val addresses = """[ {"Home" : {"city" : "Tahoe", "state" : "CA"}} ]"""
233+
val phones = """[ "925-575-0415", "916-321-2233" ]"""
234+
235+
executeDdl(handler, create)
236+
executePreparedStatement(handler, insert, Array(addresses, phones) )
237+
val result = executePreparedStatement(handler, select).rows.get
238+
239+
result(0)("addresses") === addresses
240+
result(0)("phones") === phones
241+
}
242+
success
243+
} else {
244+
pending
245+
}
246+
}
221247

248+
"support select bind value" in {
222249
withHandler {
223250
handler =>
224-
val create = """create temp table people
225-
|(
226-
|id bigserial primary key,
227-
|addresses json,
228-
|phones json
229-
|);""".stripMargin
230-
231-
val insert = "INSERT INTO people (addresses, phones) VALUES (?,?) RETURNING id"
232-
val select = "SELECT * FROM people"
233-
val addresses = """[ {"Home" : {"city" : "Tahoe", "state" : "CA"}} ]"""
234-
val phones = """[ "925-575-0415", "916-321-2233" ]"""
235-
236-
executeDdl(handler, create)
237-
executePreparedStatement(handler, insert, Array(addresses, phones) )
238-
val result = executePreparedStatement(handler, select).rows.get
239-
240-
result(0)("addresses") === addresses
241-
result(0)("phones") === phones
242-
251+
val string = "someString"
252+
val result = executePreparedStatement(handler, "SELECT CAST(? AS VARCHAR)", Array(string)).rows.get
253+
result(0)(0) == string
243254
}
244-
245255
}
246256

247257
}

0 commit comments

Comments
 (0)
0