Skip to content

Commit

Permalink
Merge pull request #337 from taniabogatsch/array-fix
Browse files Browse the repository at this point in the history
Add explicit ARRAY type test
  • Loading branch information
taniabogatsch authored Dec 20, 2024
2 parents 9dd01c5 + acb7a65 commit 0614b2d
Showing 1 changed file with 27 additions and 0 deletions.
27 changes: 27 additions & 0 deletions types_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -886,6 +886,33 @@ func TestInterval(t *testing.T) {
require.NoError(t, db.Close())
}

func TestArray(t *testing.T) {
t.Parallel()

db, err := sql.Open("duckdb", "")
require.NoError(t, err)

_, err = db.Exec(`CREATE TABLE needle (vec FLOAT[3])`)
require.NoError(t, err)

_, err = db.Exec(`INSERT INTO needle VALUES (array[5, 5, 5])`)
require.NoError(t, err)

res, err := db.Query(`SELECT vec FROM needle`)
require.NoError(t, err)

for res.Next() {
var vec Composite[[3]float64]
err = res.Scan(&vec)
require.NoError(t, err)
require.NoError(t, res.Err())
require.Equal(t, [3]float64{5, 5, 5}, vec.Get())
}

require.NoError(t, res.Close())
require.NoError(t, db.Close())
}

func TestJSONType(t *testing.T) {
t.Parallel()
db := openDB(t)
Expand Down

0 comments on commit 0614b2d

Please sign in to comment.