Skip to content

Conversation

@mikeburgh
Copy link

A first pass at closing #67

I changed the way column names are resolved so they don't get resolved for each row, however for some reason the column_type method only works when in the query row method, so I had to still do a lookup for the type there, but it now only does it once.

@mikeburgh
Copy link
Author

Giving this one a bump.. I was going to do some more for the interupt and exec commands, but wanted to see if you had any issues with this first..

@tndrle
Copy link
Owner

tndrle commented Jun 1, 2024

Hi, thanks for the PR and sorry for the late reply. I didn't have too much time recently. I hope I can look into it soon. Looks promising though, even with docs and tests already :)

@mikeburgh
Copy link
Author

I know how that goes!

I will work on interrupt and the exec method over the next week or so and send the PRs when ready.

@tndrle
Copy link
Owner

tndrle commented Jun 2, 2024

I added PR #74 for querying rows as arrays. I prefer extending the existing methods like get() and all() with an asArray option instead of adding a new raw() method. This seems a little more consistent to me, design-wise.

Column metadata is not yet included in the PR, but it will probably be a separate method, like in better's API.

@mikeburgh
Copy link
Author

Looks, good I will try and follow that model with exec method; not sure if it will have the column metadata available since it won’t use prepared statements

@tndrle
Copy link
Owner

tndrle commented Jun 3, 2024

About the column meta data: there is sqlite3_column_decltype() and sqlite3_column_type(). You use the latter and assume the first row's column types apply to all returned rows, correct? Better-sqlite uses the former, I think, which would have been also be my first guess. The actual type can be different from the declared type, so it depends on what you want to do with the type information. What are your thoughts on this?

@mikeburgh
Copy link
Author

Correct, I assume first row matches the rest... and it was only through working with this, that I discovered SQLite's approach to datatypes is, well flexible and actually can change between rows for the same column.

My issues with declared type is that it will be null in the case of computed columns, so you don't get any type information at all for those.

Maybe the best solution is use declared type, and if it's null use the column_type ?

My use case is to basically hint the datatype for display purposes, editing data, but I still check individual values (it's being used in https://dbcode.io)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants