Giorgi / DuckDB.NET

Bindings and ADO.NET Provider for DuckDB
https://duckdb.net
MIT License
356 stars 62 forks source link

Unrecognised Type (Text) #15

Closed travis-leith closed 2 years ago

travis-leith commented 2 years ago

Using the latest version of the repo, and changing the sample code to the following

command.CommandText = "CREATE TABLE integers(foo text, bar INTEGER);";
var executeNonQuery = command.ExecuteNonQuery();

command.CommandText = "INSERT INTO integers VALUES ('3', 4), ('5', 6), ('7', NULL);";

and PrintQueryResults changed to

if (queryResult.GetFieldType(ordinal) == typeof(string))
                    {
                        var sval = queryResult.GetString(ordinal);
                        Console.Write(sval);
                    }
                    else
                    {
                        var val = queryResult.GetInt32(ordinal);
                        Console.Write(val);
                    }

I get the unrecognized type error.

But if I change the DuckDBType enum to

DuckdbTypeVarchar = 17

then it works. This error existed on the previous version but the latest version of DuckDB.Net was released before I was finished investigating. Note that on the previous version the required value to get it work was 20, not 17. Does this mean that extra types should be inserted in the enum to get it up to at least 17?

Giorgi commented 2 years ago

The DuckDBType enum is missign some members.

travis-leith commented 2 years ago

How can I go about find which enum members are missing? Are they listed anywhere in the duckdb repo?

Giorgi commented 2 years ago

https://duckdb.org/docs/api/c/types

Giorgi commented 2 years ago

Fixed by 73171681cefc0a605ddd5895656b9e900d170381