diff --git a/stdlib/sql_test.go b/stdlib/sql_test.go index e15c9744..83a7d949 100644 --- a/stdlib/sql_test.go +++ b/stdlib/sql_test.go @@ -440,6 +440,10 @@ func TestConnQueryJSONIntoByteSlice(t *testing.T) { db := openDB(t) defer closeDB(t, db) + if !serverHasJSON(t, db) { + t.Skip("Skipping due to server's lack of JSON type") + } + _, err := db.Exec(` create temporary table docs( body json not null @@ -476,6 +480,10 @@ func TestConnExecInsertByteSliceIntoJSON(t *testing.T) { db := openDB(t) defer closeDB(t, db) + if !serverHasJSON(t, db) { + t.Skip("Skipping due to server's lack of JSON type") + } + _, err := db.Exec(` create temporary table docs( body json not null @@ -510,6 +518,15 @@ func TestConnExecInsertByteSliceIntoJSON(t *testing.T) { ensureConnValid(t, db) } +func serverHasJSON(t *testing.T, db *sql.DB) bool { + var hasJSON bool + err := db.QueryRow(`select true from pg_type where typname='json'`).Scan(&hasJSON) + if err != nil { + t.Fatalf("db.QueryRow unexpectedly failed: %v", err) + } + return hasJSON +} + func TestTransactionLifeCycle(t *testing.T) { db := openDB(t) defer closeDB(t, db)