marcboeker / go-duckdb

go-duckdb provides a database/sql driver for the DuckDB database engine.
MIT License
583 stars 96 forks source link

[Appender] Cast float64 to numeric destination type #198

Closed taniabogatsch closed 3 months ago

taniabogatsch commented 3 months ago

Depends on https://github.com/marcboeker/go-duckdb/pull/196.

Adds an implicit cast from the source type float64 to any expected numeric destination (column) type. These changes, and the previous work in https://github.com/marcboeker/go-duckdb/pull/196, enable the appender to append generic interface inputs, also those retrieved from json.Unmarshal.

https://go.dev/blog/json

The json package uses map[string]interface{} and []interface{} values to store arbitrary JSON objects and arrays; it will happily unmarshal any valid JSON blob into a plain interface{} value. The default concrete Go types are: bool for JSON booleans, float64 for JSON numbers, string for JSON strings, and nil for JSON null.