How should I find out dynamically which rust type to map a column into? #2837
Unanswered
dhbradshaw
asked this question in
Q&A
Replies: 1 comment 1 reply
-
I'm also trying to solve this problem. The only idea I have is enumerating the column type info from postgres, which gets complicated very fast (especially if you have user defined types like we do). There might be something in using It's possible sqlx might not be a good choice for this use-case given its goal of being type safe. quaint might be a better option. |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I'm trying to write code that will work with returned rows when I don't know what the query that generated that row or the database associated with that row looked like in advance.
The first idea I have on how to do this is to try to map column values into an enum with variants for the different possible types.
But when I try to get type information to match on it feels like I'm fighting sqlx. The column's type_info doesn't expose id() anymore. It also doesn't let you get types to match on.
So far my best ideas are to match on the debug string or the oid! But both feel like hacks, making me thing that I'm working against sqlx rather than with it. Is there a better route to take here?
Beta Was this translation helpful? Give feedback.
All reactions