繁体   English   中英

带有NOT LIKE查询的SQLAlchemy CAST

[英]SQLAlchemy CAST with NOT LIKE query

SQLAlchemy的新手,在构造查询以将列的数据类型从一列转换为另一列并随后执行NOT LIKE查询时遇到一些问题。

这是我目前拥有的:

not_like_result = MrTS.query.filter(cast(MrTS.rules, String), not_(MrTS.rules.like(search_keyword))).all()

据我了解,这是因为上面的代码由于逗号而在中间插入了AND,而我只希望不喜欢。 只是不确定如何正确地将其链接在一起。

你可以试试这个

not_like_result = session.query(MrTS).filter(cast(MrTS.rules, String()).notlike(search_keyword)) 

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM