Migrated from halcyonnouveau/clorinde#107, originally reported by @TimDiekmann on 2025-05-30.
I have a situation, where I represent a Rust enum as string in Postgres. Let's call that enum Action (e.g. Action::View, Action::update etc.). To avoid recreating the type in Postgres with each added action, it's simply stored as text in the database. So to for example insert a new action to the database, it requires a query like this:
--! insert_policy_action
INSERT INTO action (
action_name
) VALUES (
:action_name
);
This creates a binding of actionName: impl StringSql, but what I actually want to pass is Action here. (the type implements ToSql and FromSql).
Is it possible to achieve this? If not, is it possible to extend the annotations so we can specify the concrete type, such as
--! insert_policy_action (action_name: Action)
The Action type would be either created by clorinde or it could be provided by the type mapping (as in halcyonnouveau#105)
I have a situation, where I represent a Rust enum as string in Postgres. Let's call that enum
Action(e.g.Action::View,Action::updateetc.). To avoid recreating the type in Postgres with each added action, it's simply stored as text in the database. So to for example insert a new action to the database, it requires a query like this:This creates a binding of
actionName: impl StringSql, but what I actually want to pass isActionhere. (the type implementsToSqlandFromSql).Is it possible to achieve this? If not, is it possible to extend the annotations so we can specify the concrete type, such as
--! insert_policy_action (action_name: Action)The
Actiontype would be either created byclorindeor it could be provided by the type mapping (as in halcyonnouveau#105)