google-code-export / nutz

Automatically exported from code.google.com/p/nutz
Apache License 2.0
1 stars 1 forks source link

38 Cnd中包含in语句出错 #484

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
!Nutz SQL Error: 'UPDATE bc_book SET priority=? ,UPDATE_USER_ID=?   WHERE 
bookId IN (?) AND type=? AND  NOT priority=?

很明显in不能用?传参……

Original issue reported on code.google.com by fjayb...@gmail.com on 18 May 2011 at 4:18

GoogleCodeExporter commented 9 years ago
而且貌似bookId没有解析成正确数据库字段

依旧是这个方法:

    public int update(Class<?> classOfT, Chain chain, Condition cnd) {
        EntityOperator opt = _opt(classOfT);
        opt.addUpdate(chain, cnd);
        opt.exec();
        return opt.getUpdateCount();
    }

Original comment by fjayb...@gmail.com on 18 May 2011 at 4:20

GoogleCodeExporter commented 9 years ago
如果不是in
貌似可以正确解析成数据库字段……

Original comment by fjayb...@gmail.com on 18 May 2011 at 4:24

GoogleCodeExporter commented 9 years ago
奇怪,我加了一个 JUnit,没有重现这个问题:
参见 r2090

你看看我的这个测试代码有什么问题不?

*org.nutz.dao.test.normal.UpdateTest*
{{{
@Test
public void test_update_chain_and_cnd_by_in() {
    dao.create(Pet.class, true);
    Pet pet = Pet.create("xb");
    pet.setNickName("XB");
    dao.insert(pet);

    dao.update( Pet.class,
                Chain.make("name", "xiaobai"),
                Cnd.where("nickName", "in", Lang.array("XB")));
    pet = dao.fetch(Pet.class, "xiaobai");
    assertEquals("XB", pet.getNickName());
}
}}}

Original comment by zozoh...@gmail.com on 18 May 2011 at 6:23

GoogleCodeExporter commented 9 years ago
是不是使用的数据库是oracle从而造成该问题的出现啊(oralce��
�话in的参数个数过多的话会造成sql异常,而该异常是从jdbc报�
��来的。参数个数的临界值我忘了具体的数字,大概是250个。
。。)

Original comment by ywjno....@gmail.com on 8 Jun 2011 at 1:56

GoogleCodeExporter commented 9 years ago
我猜是他直接传了个String
   "(1,2,3,4,5)"

Original comment by wendal1985@gmail.com on 21 Jun 2011 at 5:08

GoogleCodeExporter commented 9 years ago

Original comment by wendal1985@gmail.com on 6 Sep 2011 at 7:02