V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
Tornado Documentation
http://www.v2ex.com/tornado/
Tornado on GitHub
https://github.com/facebook/tornado/
Tornado Gists
http://tornadogists.org/
zzxworld
V2EX  ›  Tornado

Warning: Truncated incorrect DOUBLE value

  •  
  •   zzxworld · 2012-09-28 09:33:13 +08:00 · 6002 次点击
    这是一个创建于 4218 天前的主题,其中的信息可能已经有所发展或是发生改变。
    代码:
    tagsId = [1,2,3]
    self.db.query("""select good_id from goods_tags where tag_id in(%s)""", ','.join([str(tid) for tid in tagsId]) )

    错误警告:
    Warning: Truncated incorrect DOUBLE value: '1,2,3'

    蛋疼的解决方法:
    self.db.query("""select good_id from goods_tags where tag_id in(%s)""" % ','.join([str(tid) for tid in tagsId]) )

    所以怀疑是使用%s被mysqldb给转换后给in查询参数了引号所致。请问各位在tornado中有没有碰到这种问题?是怎么解决的?
    1 条回复    2014-12-17 10:33:51 +08:00
    nodexy
        1
    nodexy  
       2014-12-17 10:33:51 +08:00
    主要原因是你where语句中设置查询条件的field ,所给出的值类型要与mysql里的类型一致,否则就会保持据类似 Warning: Truncated incorrect DOUBLE value: ... 这样的错误,我也遇到了。

    我是有一个字段 grade 为 char 型,查询的时候用 where grade=1 就报这个错,但是改成 grade='1' 就oK了。
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   1054 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 25ms · UTC 19:05 · PVG 03:05 · LAX 12:05 · JFK 15:05
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.