Using `where x = $1::TEXT[]` breaks type checking
Version
1.24.0
What happened?
Compliation successful with invalid WHERE condition. In the following query creator_code is not a valid column (should be url_code). When using the in ($1::TEXT[]) condition it breaks the check and successfully compiles only for the query to throw errors at query time.
Relevant log output
No response
Database schema
No response
SQL queries
select user_id, url_code
from creators
where creator_code in ($1::TEXT[])
;
Configuration
No response
Playground URL
No response
What operating system are you using?
macos
What database engines are you using?
postgres
What type of code are you generating?
Go
fwiw I intended to do where url_code = any($1::TEXT[]) originally and stumbled over this, also get the error expected $1::STRING[] to be of type string, found type string[] (SQLSTATE 22023) when the column fix is applied.
This is indeed a bug with the standard built-in analyzer. I have confirmed the correct behavior (an error saying the creator_code column doesn't exist) when using the database-backed analyzer which is perhaps a plausible workaround for some users.