luan-nvg / csharp-sqlite

Automatically exported from code.google.com/p/csharp-sqlite
Other
0 stars 0 forks source link

DataTable from ExecuteQuery contains only string datatype. #45

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
What steps will reproduce the problem?
1. Create Table
2. Insert some data
3. Use the ExecuteQuery and check the datatypes

What is the expected output? What do you see instead?

DataTable from ExecuteQuery contains only string datatype.
I have been testing your implemetnation of SQLite. One thing I discovered 
is that only the datatype string is rutned in the table returning from 
ExecuteQuery. Is this a correct behaviour?

For example if I want to run a cast in the query, cast(col1 as int) the 
returning table still renders col1 as string.

Is this behaviour by design?

What version of the product are you using? On what operating system?
3.6.17

Please provide any additional information below.

Original issue reported on code.google.com by aliakbar...@gmail.com on 21 Jan 2010 at 3:15

GoogleCodeExporter commented 8 years ago
ExecuteQuery is part of the SQLiteDatabase class in the Benchmark sample.

It is not part of the C# implementation, simply a sample.

Any volunteers to extend the functionality of this class?

Original comment by noah.hart@gmail.com on 21 Jan 2010 at 3:29

GoogleCodeExporter commented 8 years ago
The problem seems to be the function csSQLite.sqlite3_column_type, it only 
returns
the type SQLITE_NULL (5).

Original comment by seeseekey on 21 Jan 2010 at 4:50

GoogleCodeExporter commented 8 years ago

Original comment by noah.hart@gmail.com on 21 Jan 2010 at 8:37

GoogleCodeExporter commented 8 years ago
column_type is returned correctly under version 3.6.22;  
Please update to latest version and retest;

Note: column_type will be SQLITE_NULL if no rows are returned.

Original comment by noah.hart@gmail.com on 26 Jan 2010 at 2:19

GoogleCodeExporter commented 8 years ago
I had test the newest version and can reproduce the error again. I had attach a
modified benchmark.cs which i used to reproduce the error.

Original comment by seeseekey on 26 Jan 2010 at 3:13

Attachments:

GoogleCodeExporter commented 8 years ago
Added Column type to returned DataTable in SQLiteDatabase class

Original comment by noah.hart@gmail.com on 26 Jan 2010 at 4:19

GoogleCodeExporter commented 8 years ago
[deleted comment]
GoogleCodeExporter commented 8 years ago
The change of column data type cannot be done after table has been populated. 
The 
implemented change table.Columns[i].DataType = typeof(String);
Genereates the following error.

"Cannot change DataType of a column once it has data"

Reading and setting the schema could be defined as a separate method which is 
run 
before the readrows process is done.

By the way will the change also work for in query casts like:

CAST(columnName as Integer) as Alias1?

I have done some testing and it seems as if data type string (5) is returned 
regardless. 

Original comment by aliakbar...@gmail.com on 28 Jan 2010 at 1:27