Daniele Varrazzo <daniele.varrazzo@gmail.com> writes:
> The operator `IS NULL` doesn't work if the argument has unknown type.
> conn.execute("select %s is null", ['foo']).fetchone()
> IndeterminateDatatype: could not determine data type of parameter $1
Yeah.
> It doesn't seem necessary to specify a type for an argument if it only
> has to be compared with null: nullness is independent from the type
> and is even specified, in the query parameters, in a separate array
> from the parameter values.
True, the IS NULL operator itself doesn't care about the data type,
but that doesn't mean that noplace else in the system does.
As an example, if we silently resolved the type as "text" as you seem
to wish, and then the client sends a non-null integer in binary format,
we'll likely end up throwing a bad-encoding error.
Maybe that's not a big problem, I dunno. But we can't just not
resolve the type, we have to pick something.
regards, tom lane