ShenanigansS
Windmill8mo ago
14 replies
Shenanigans

[SOLVED] Casting to Enums and custom types - PostgreSQL

Hello,

I am encountering the following error when I try to upsert on a PostgreSQL record where one of my arguments is an enum type. I assumed I would be able to use a string directly from my script arguments, but that does not seem to be the case.

Error:
{
    "error": {
        "name": "ExecutionErr",
        "message": "execution error:\nError: error serializing parameter 4: cannot convert between the Rust type `alloc::string::String` and the Postgres type `currency`: cannot convert between the Rust type `alloc::string::String` and the Postgres type `currency` @pg_executor.rs:129:24"
    }
}


I have also tried casting via

INSERT INTO myTable (currency) VALUES (
  ...
  ($5::currency)::TEXT
  ...


But I encounter the following error:
{
    "error": {
        "name": "ExecutionErr",
        "message": "execution error:\nError: db error: ERROR: column \"currency\" is of type currency but expression is of type text\nHINT: You will need to rewrite or cast the expression.: ERROR: column \"currency\" is of type currency but expression is of type text\nHINT: You will need to rewrite or cast the expression. @pg_executor.rs:129:24"
    }
}


Windmill Version: Windmill EE v1.491.5-27-gdfd8c4cd2
Was this page helpful?