V2EX = way to explore
V2EX 是一个关于分享和探索的地方
Sign Up Now
For Existing Member  Sign In
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 · Sep 28, 2012 · 6886 views
    This topic created in 4967 days ago, the information mentioned may be changed or developed.
    代码:
    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 replies    2014-12-17 10:33:51 +08:00
    nodexy
        1
    nodexy  
       Dec 17, 2014
    主要原因是你where语句中设置查询条件的field ,所给出的值类型要与mysql里的类型一致,否则就会保持据类似 Warning: Truncated incorrect DOUBLE value: ... 这样的错误,我也遇到了。

    我是有一个字段 grade 为 char 型,查询的时候用 where grade=1 就报这个错,但是改成 grade='1' 就oK了。
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   2532 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 33ms · UTC 10:57 · PVG 18:57 · LAX 03:57 · JFK 06:57
    ♥ Do have faith in what you're doing.