我有一个简单的玩家实体:
__tablename__ = 'player'
_id = Column('id', SmallInteger, primary_key=True)
_nickName = Column('nick_name', String)
def __init__(self, nickName):
self._nickName = nickName
@property
def id(self):
return self._id
@property
def nickName(self):
return self._nickName.decode(encoding='UTF-8')
@nickName.setter
def nickName(self, nickName):
self._nickName = nickName
当我做:
players = session.query(Player).filter(Player.nickName=='foo')
我打印了players
我得到的var:
SELECT player.id AS player_id, player.nick_name AS player_nick_name
FROM player
WHERE false
显然,当我.first()
在会话查询末尾添加时,结果是None
. 我已经尝试过filter_by()
并得到相同的结果。
欢迎任何帮助。