postgresql变量null或null语法错误
我使用psycopg2
,并且输入变化具有看起来像这样的条件:
WHERE %(variable)s is null or some_column in %(variable)s
问题是,当变量
为null时,我会得到语法错误:
psycopg2.errors.SyntaxError: syntax error at or near "NULL"`
(NULL is null or (some_column IN NULL)) and
^
当然,该条件不应由于null为null
已经是正确的,但是语法不通过。无论如何要解决此问题而不创建额外的变量?
I use psycopg2
and have input varaiables with a where condition that looks like this:
WHERE %(variable)s is null or some_column in %(variable)s
The problem is that when variable
is null I get a syntax error:
psycopg2.errors.SyntaxError: syntax error at or near "NULL"`
(NULL is null or (some_column IN NULL)) and
^
That condition should of course not be evaluated since null is null
is true already, but the syntax does not pass. Anyway to fix this without creating an extra variable?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论