Skip to content

citext parameters silently fail #4078

@bbstilson

Description

@bbstilson

I have found these related issues/pull requests

#3212

Description

When querying a citext column, the query will fail to find anything without explicitly casting the parameter to citext. If the types are incompatible, then I would expect the query to not compile. However, text is compatible with citext, so it is surprising that the query silently fails.

Reproduction steps

Given a table:

create table foos (name citext);

insert into foos(name) values ('foo'), ('bar');

this query fails, and by fails i mean does not return a row when it should:

sqlx::query!("select count(*) from foos where name = $1", "Foo")

this query succeeds:

sqlx::query!("select count(*) from foos where name = $1::citext", "Foo")

If I copy and paste the query into other libraries (like psycopg for python) or into psql itself, it works as expected.

SQLx version

0.8.3

Enabled SQLx features

"runtime-tokio-rustls",     "macros",     "postgres",     "json",     "chrono",     "uuid"

Database server and version

Postgres 15

Operating system

Ubuntu 22

Rust version

1.90.0

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions