Is it possible to get the name of a table at runtime? #4796
Replies: 2 comments 7 replies
-
|
This information is currently not exposed in such a way. It would be interesting to learn more about your use-case to understand if we should expose this information or if this is already covered by another API. |
Beta Was this translation helpful? Give feedback.
-
|
Hi - I am facing the same problem, in my use case it is currently primarily for better error reporting. I have some structs associated to the table, and I would like to be able to format an error like |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Backend
SQLite
Diesel version
2.2.12
Diesel Features
sqlite, uuid, returning_clauses_for_sqlite_3_35, chrono
Operating System Version
Ubuntu 25.04 x86_64 GNU/Linux 6.14.0-32-generic
Third party libraries
No response
What do you want to do?
I'm trying to get the name of a table declared using the DSL like in the
getting_started_step_1example statically at runtime.I didn't find anything in the
self::schema::postsmodule so I looked at the expanded code of the example withcargo expand --liband the only string for"posts"I found is an internal one that I'm likely not supposed to be able to access:I already looked at the documentation, the feature flags, the code of
dieseland didn't find any solution.Ideally I'd like to do something like:
And it would print:
Compile time error
No response
What code do you already have?
So that I could get the name of the table with:
Thanks to everyone reading my post.
Beta Was this translation helpful? Give feedback.
All reactions