-
Notifications
You must be signed in to change notification settings - Fork 22
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
Return rows with column names as HashMap Text Value #5
Comments
This is doable with the current interface. 👍 |
I'm trying to do it myself. But I'm stumped with C to haskell string conversions. I added columnName to Column record:
In describeColumn i'm trying to get the name of the column:
But that gives me SQLWCHAR. How do i convert it to haskell Text or String? |
Be aware that |
ok, a little progress. I tried And it produced a string that starts with a field name bu then continues with a large string of prefilled zeroes like this: "min_time\NUL00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000" Notice that there's a null terminator there. How would I deal with tat? |
After that, I think it's fine if we make a breaking API change:
|
Success! Thank you very much for helping me.
For my case I simply cloned query and fetchStatementRows into queryMaps and fetchStatementMaps Perhaps as the next step I could tackle unifying them all as you suggested. Also if we are open to API redesign at this early stage what do you think about dropping your Value and adopting SqlValue from HDBC package? |
👍
I'm not attached to
What about the constructors of |
Value and SqlValue have almost the same structure. SqlValue has SqlNull that allows to drop Maybe and has automatic way to convert to maybes if needed. https://hackage.haskell.org/package/HDBC-2.4.0.2/docs/Database-HDBC-SqlValue.html But yes, there are more constructors for SqlValue than what you have. |
Also Value clashes with Aeson. |
Hmm, we do not need to provide an implementation for every Constructor in the SqlValue. Only the ones that we are interested in. |
OK, good, then we can deal with |
Yeah, HDBC still uses String instead of Text in SqlValue. |
It would be good to be able to create a Map Text Value instead of a list or tuple of values as a row.
For large queries with many columns it is quite cumbersome to use positioning instead of column name.
Also for a drop in replacement of old HDBC-odbc code, column names are needed, since I exclusively use Maps instead of lists as rows.
The text was updated successfully, but these errors were encountered: