Skip to content

Is it possible to customize the parameter types? #287

@LouisGariepy

Description

@LouisGariepy

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)

Metadata

Metadata

Assignees

No one assigned

    Labels

    codegenAn issue regarding code generation, or the generated code itself.featureNew feature or requestparserImprovements or bugfixes to the sql parser.

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions