Giter Site home page Giter Site logo

Comments (9)

casatwy avatar casatwy commented on July 29, 2024 1

我正在改这部分,改起来其实比你说的要复杂。我已经改好了,正在发1.3.1

from ctpersistance.

casatwy avatar casatwy commented on July 29, 2024

嗯,这其实是一个很复杂的问题,如果给所有主键都包一个引号,当主键为数字时又会出错,我需要解析一下主键类型再拼sql才行

发自我的 iPhone

在 2015年11月26日,22:12,monsterTesla [email protected] 写道:

错误信息的一部分“WHERE primaryKey = 987D5D73-4E98-49D5-A095-19610A3E8EEB
Error Message is: unrecognized token: "987D5D73"”

应该是“- (NSString *)stringWithSQLParams:(NSDictionary *)params”这个方法在拼接参数的使用没有把主键值用“''”单引号包起来的原因。
改成""... WHERE primaryKey = '987D5D73-4E98-49D5-A095-19610A3E8EEB' ”就好了


Reply to this email directly or view it on GitHub.

from ctpersistance.

jessedog avatar jessedog commented on July 29, 2024

嗯,应该不只是主键,用其他键来查询应该也有这个问题。也许可以通过params里面的value类型来判断是否需要加引号

from ctpersistance.

Vincentzzg avatar Vincentzzg commented on July 29, 2024

这个问题还没解决吗?查找的时候也是一样,如果value在表中是TEXT类型,就查不出来,少了单引号''

  • (NSArray <NSObject > *)findAllWithKeyName:(NSString *)keyname value:(id)value error:(NSError *)error;

from ctpersistance.

casatwy avatar casatwy commented on July 29, 2024

主键目前强制要求是NSNumber,但是使用(NSArray > *)findAllWithKeyName:(NSString *)keyname value:(id)value error:(NSError *)error;这个函数去查找value为string的值已经OK了,昨天发布的1.3.0解决的就是这个问题。

from ctpersistance.

Vincentzzg avatar Vincentzzg commented on July 29, 2024

刚刚测试了1.3.0问题还在:
Query Error:
Origin Query is : SELECT * FROM 'pluginInfo' WHERE packagename = com.hikvision.moa.unlockuser
Error Message is: near ".": syntax error

1、这一串是我的value,报错了。
2、即便value是一串常规字符串,比如@”abc“,我刚刚插入的,用工具能查到,但是就是查不出数据,改成@"'abc'"之后就能查到了
3、还有就是不是应该所有的where条件里面条件值如果是text类型都应该要带单引号''的吗,我数据库不熟,但是其他的update、delete同样存在text类型的数据操作失效的问题

楼主可以测试下看

from ctpersistance.

Vincentzzg avatar Vincentzzg commented on July 29, 2024

刚才又看了一下,这个要改的话应该是在NSString+SQL.h文件的

  • (NSString *)stringWithSQLParams:(NSDictionary *)params;
    这个函数里面,在拼接字符串的时候,先判断value的类型,如果是NSString,加''
    NSString *value = @"";
    if ([params[key] isKindOfClass:[NSString class]]) {
    value = [NSString stringWithFormat:@"'%@'", params[key]];
    } else {
    value = [NSString stringWithFormat:@"%@", params[key]];
    }

不知道考虑的是否全面,你看下这样可以不

from ctpersistance.

casatwy avatar casatwy commented on July 29, 2024

1.3.1已经发好了,相关测试用例是1008和1009

from ctpersistance.

Vincentzzg avatar Vincentzzg commented on July 29, 2024

OK

from ctpersistance.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.