Skip to content

ToField Action typing #265

@defanor

Description

@defanor

Sometimes PostgreSQL gets confused about types if there's no explicit typing; I've noticed it with a non-empty array (PGArray) of enum elements, which gets recognized as text[] instead of user_role[] in my case. Setting types in queries explicitly is a bit cumbersome in some cases, and it would be handy if postgresql-simple facilitated it. For instance, the following works, but it uses Plain for something other than its intended purpose as it's described in the documentation (that is, it's a hack):

instance ToField Role where
  toField r = Many [Escape $ BS8.pack $ show r, Plain ":: user_role"]

Maybe something like a Typed Action String action constructor should be introduced, or the Plain description should be adjusted. It may be out of scope of postgresql-simple, but seems like ToField is the appropriate place for adding type information.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions