-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Could not retrieve the column types from the rows of db.Query #682
Comments
Column types cannot be retrieved until you've called |
I moved the Thanks! |
What do you mean by "when the result is null"? |
In this example: |
Ah, I see. SQLite is dynamically typed, so the type information is tied to individual values as opposed to result columns. In fact the type of a column can be different from one row to the next. Be sure to keep this in mind with whatever you're doing. |
Thank you for the additional information. |
How did you deal with it? @eaglebush |
Assuming the query called all the columns to return, I had to define the structure manually in a struct and used its field index to identify what column would the |
I was making a wrapper around a query and I came to the point of retrieving the column types to know what type a row field should be cast to, but I cannot get field types from a db.Query result. Here is a test function taken from the sqlite3_test.go file to reproduce:
I have inserted code in the function to check if I can retrieve the column types from the test result. When I retrieved the ScanType from the column, it raises an error. In debug mode, I see the value of the scanType is void.
Is this how it should be used or are there any work around?
Environment:
OS: Windows 7 SP1 64 bit
GO version: go1.11.1 windows/amd64
C Compiler: TDM-GCC Compiler Suite for Windows MinGW-w64 64/32-bit Edition
The text was updated successfully, but these errors were encountered: