【发布时间】:2016-10-10 08:19:21
【问题描述】:
我在使用 Oracle 11g 后端的 SQLAlchemy 查询字符串时遇到了一个奇怪的问题。首先,类定义(对于Oracle,对于Postgres 相同减去Sequence):
class Item(Base):
__tablename__ = 'item'
id = Column(Integer, Sequence('id_seq'), primary_key=True)
...
review = Column(Unicode(2000), index=True)
使用 Postgres 后端进行基本查询没有问题:
In [1]: len(DBSession.query(Item).filter(Item.review != '').limit(100).all())
Out[1]: 100
但是,对于 Oracle 11g:
In [31]: len(DBSession.query(Item).filter(Item.review != '').limit(100).all())
Out[31]: 0
空 Unicode 字符串过滤在 Oracle 中也不起作用:
In [32]: len(DBSession.query(Item).filter(Item.review != u'').limit(100).all())
Out[32]: 0
为什么这么基本的东西不能与 Oracle 一起使用?我该如何解决这个问题?
【问题讨论】:
标签: python oracle postgresql oracle11g sqlalchemy