Skip to content

Commit

Permalink
Merge branch 'main' into use_staticlib
Browse files Browse the repository at this point in the history
  • Loading branch information
taniabogatsch committed Jan 14, 2025
2 parents 50b08df + 2b733c5 commit e17fd00
Show file tree
Hide file tree
Showing 10 changed files with 315 additions and 201 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ jobs:
shell: bash
strategy:
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
os: [ubuntu-latest, macos-latest, windows-latest, macos-13]
go: ["1.23"]
fail-fast: false
steps:
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,14 @@ go get github.com/marcboeker/go-duckdb

### Windows

On windows, the correct version of gcc and the neccesary runtime libraries needs to be installed.
On windows, the correct version of gcc and the necessary runtime libraries needs to be installed.
One method to do this is using msys64. To begin, install msys64 using their installer. Once this is done, open a msys64 shell and run

```
pacman -S mingw-w64-ucrt-x86_64-gcc
```

select yes when neccesary, its ok if the shell closes. Then add gcc to the path using whatever method you prefer. In powershell this is `$env:PATH = "C:\msys64\ucrt64\bin:$env:PATH"`. Once this is done, you can compile this package on windows.
select yes when necessary, its ok if the shell closes. Then add gcc to the path using whatever method you prefer. In powershell this is `$env:PATH = "C:\msys64\ucrt64\bin:$env:PATH"`. Once this is done, you can compile this package on windows.

## Usage

Expand Down
18 changes: 9 additions & 9 deletions appender_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -287,9 +287,9 @@ func TestAppenderNested(t *testing.T) {
require.Equal(t, rowsToAppend[i].intList, castList[int32](r.intList))

strRes := fmt.Sprintf("%v", r.nestedIntList)
require.Equal(t, strRes, "[[1 2 3] [4 5 6]]")
require.Equal(t, "[[1 2 3] [4 5 6]]", strRes)
strRes = fmt.Sprintf("%v", r.tripleNestedIntList)
require.Equal(t, strRes, "[[[1 2 3] [4 5 6]] [[7 8 9] [10 11 12]]]")
require.Equal(t, "[[[1 2 3] [4 5 6]] [[7 8 9] [10 11 12]]]", strRes)

require.Equal(t, rowsToAppend[i].simpleStruct, castMapToStruct[simpleStruct](t, r.simpleStruct))
require.Equal(t, rowsToAppend[i].wrappedStruct, castMapToStruct[wrappedStruct](t, r.wrappedStruct))
Expand Down Expand Up @@ -343,7 +343,7 @@ func TestAppenderNullList(t *testing.T) {
strS = fmt.Sprintf("%v", intS)
}

require.Equal(t, strResult[i], strS, fmt.Sprintf("row %d: expected %v, got %v", i, strResult[i], strS))
require.Equal(t, strResult[i], strS, "row %d: expected %v, got %v", i, strResult[i], strS)
i++
}

Expand Down Expand Up @@ -374,7 +374,7 @@ func TestAppenderNullStruct(t *testing.T) {
case 0:
require.NoError(t, err)
case 1:
require.Equal(t, nil, row)
require.Nil(t, row)
}
i++
}
Expand Down Expand Up @@ -425,7 +425,7 @@ func TestAppenderNestedNullStruct(t *testing.T) {
var row any
err = res.Scan(&row)
if i == 1 {
require.Equal(t, nil, row)
require.Nil(t, row)
} else {
require.NoError(t, err)
}
Expand Down Expand Up @@ -461,14 +461,14 @@ func TestAppenderNullIntAndString(t *testing.T) {
)
if i == 0 {
require.NoError(t, err)
require.Equal(t, id, 32)
require.Equal(t, str, "hello")
require.Equal(t, 32, id)
require.Equal(t, "hello", str)
} else if i > 0 && i < 4 {
require.Error(t, err)
} else {
require.NoError(t, err)
require.Equal(t, id, 42)
require.Equal(t, str, "valid again")
require.Equal(t, 42, id)
require.Equal(t, "valid again", str)
}
i++
}
Expand Down
6 changes: 3 additions & 3 deletions duckdb_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -283,7 +283,7 @@ func TestJSON(t *testing.T) {
t.Run("SELECT an empty JSON", func(t *testing.T) {
var res Composite[map[string]any]
require.NoError(t, db.QueryRow(`SELECT '{}'::JSON`).Scan(&res))
require.Equal(t, 0, len(res.Get()))
require.Empty(t, res.Get())
})

t.Run("SELECT a marshalled JSON", func(t *testing.T) {
Expand All @@ -302,7 +302,7 @@ func TestJSON(t *testing.T) {
t.Run("SELECT a JSON array", func(t *testing.T) {
var res Composite[[]any]
require.NoError(t, db.QueryRow(`SELECT json_array('foo', 'bar')`).Scan(&res))
require.Equal(t, 2, len(res.Get()))
require.Len(t, res.Get(), 2)
require.Equal(t, "foo", res.Get()[0])
require.Equal(t, "bar", res.Get()[1])
})
Expand Down Expand Up @@ -525,7 +525,7 @@ func TestTypeNamesAndScanTypes(t *testing.T) {
err = r.Scan(&val)
require.NoError(t, err)
require.Equal(t, test.value, val)
require.Equal(t, r.Next(), false)
require.False(t, r.Next())
})
}
require.NoError(t, db.Close())
Expand Down
7 changes: 3 additions & 4 deletions errors_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -481,10 +481,9 @@ func TestGetDuckDBErrorIs(t *testing.T) {
Msg: "Invalid Input Error: Map keys can not be NULL",
}

require.ErrorIs(t, outOfRangeErr1, outOfRangeErr1)
require.ErrorIs(t, outOfRangeErr1Copy, outOfRangeErr1)
require.ErrorIs(t, &wrappedDuckDBError{outOfRangeErr1Copy}, outOfRangeErr1)
require.Equal(t, false, errors.Is(outOfRangeErr2, outOfRangeErr1))
require.Equal(t, false, errors.Is(invalidInputErr, outOfRangeErr1))
require.Equal(t, false, errors.Is(errors.New(errMsg), outOfRangeErr1))
require.NotErrorIs(t, outOfRangeErr2, outOfRangeErr1)
require.NotErrorIs(t, invalidInputErr, outOfRangeErr1)
require.NotErrorIs(t, errors.New(errMsg), outOfRangeErr1)
}
2 changes: 1 addition & 1 deletion scalarUDF_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -252,7 +252,7 @@ func TestAllTypesScalarUDF(t *testing.T) {
row := db.QueryRow(fmt.Sprintf(`SELECT my_identity(%s)::VARCHAR AS res`, info.input))
require.NoError(t, row.Scan(&res))
if info.TypeInfo.InternalType() != TYPE_UUID {
require.Equal(t, info.output, res, fmt.Sprintf(`output does not match expected output, input: %s`, info.input))
require.Equal(t, info.output, res, `output does not match expected output, input: %s`, info.input)
} else {
require.NotEqual(t, "", res, "uuid empty")
}
Expand Down
Loading

0 comments on commit e17fd00

Please sign in to comment.