Comments (6)
Thanks for reporting this. Do you have some sample code that I can use to probably add the missing data type. That would be great. Thanks!
from go-duckdb.
Thanks for the response and sorry for the delay! I actually hope to have a PR opened up next week some time.
from go-duckdb.
No worries, I've already started with a PR. But the serialisation of the Map{"foo": "bar", "bam": "baz"}
to the SQL representation map(['foo', 'bam'], ['bar', 'baz'])
is not that trivial, as a map could contain another map as its key or value. For numericals and strings my implementation already works.
from go-duckdb.
After I have racked my brain about serializing a map to a query parameter, I have checked the DuckDB APIs for prepared statements and have found no way to bind a map to a parameter. After thinking twice about it, I'm unsure what your use case is.
Could you please show me the query you want to use. This would help me to understand the problem better. Thanks!
from go-duckdb.
Hey @marcboeker, I have a motivating example for the same issue except with a slice.
This fails with the error sql: converting argument $1 type: unsupported type []string, a slice of string
.
func TestSliceParameter(t *testing.T) {
db := openDB(t)
defer db.Close()
_, err := db.Exec("CREATE TABLE foo (x text)")
require.NoError(t, err)
_, err = db.Exec("INSERT INTO foo VALUES ('test')")
require.NoError(t, err)
_, err = db.Query("SELECT x FROM foo WHERE x = ANY($1)", []string{"test"})
require.NoError(t, err)
}
from go-duckdb.
Hi @andyyu2004, thanks for the example. As we're internally using the DuckDB parameter bind API, there is currently no function for binding slices.
A dirty hack would be to interpolate the placeholder with multiple placeholders an then iterating over the slice and binding each item separately. But I would highly suggest to avoid this, as it can get ugly quickly.
For these kind of use-cases I have used sqlx in the past. See the example under the "IN queries" section on this page. Maybe you could try this?
from go-duckdb.
Related Issues (20)
- Add CI script to run gofumpt
- hope create a new tag for last update HOT 1
- Build failures on redhat linux HOT 1
- Support missing timestamp types in the appender HOT 1
- Detect incorrect column counts in the appender
- transaction.go:6:5: undefined: conn HOT 9
- Exposing filesystem interface HOT 1
- Make Apache Arrow Optional HOT 2
- Add support for the DATE type in the appender
- Does `go-duckdb` has a glibc version dependency? HOT 2
- Silent primary key violation in the appender HOT 2
- Appending a NULL in UUID[] column panics HOT 1
- found architecture 'arm64', required architecture 'x86_64' on mac os HOT 3
- libduckdb.a, building for macOS-x86_64 but attempting to link with file built for macOS-arm64 HOT 2
- Info: Deploying go-duckdb In A Distroless Docker Container
- DuckDB version mismatch in v1.6.5 release HOT 1
- Auto-load / auto-install in go-duckdb? And packaging JSON? HOT 1
- Cannot run duckdb v1.6.6 . Apache arrow lib broken HOT 1
- macos `go run` works but unable to execute the output of `go build` HOT 3
- Proposal: Support better error messages HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from go-duckdb.