Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add statement cache and test case #73

Open
wants to merge 19 commits into
base: master
Choose a base branch
from

Conversation

longjianjiang
Copy link

写了个statement的cache, 希望casa看下哪里还有问题。

@casatwy
Copy link
Owner

casatwy commented Jun 28, 2018

我今天生病发烧了,只能明天帮你看了,头晕。

@longjianjiang
Copy link
Author

好的,casa注意身体。

@casatwy
Copy link
Owner

casatwy commented Jun 29, 2018

这个PR我不能合并,因为不能通过完整的测试

2018-06-29 3 31 04

2018-06-29 3 31 15

@casatwy
Copy link
Owner

casatwy commented Jun 29, 2018

这个PR我会保持Open,你可以继续提交更新,使得能够通过完整测试

@longjianjiang
Copy link
Author

好的,我去看下哪里出问题了。

@casatwy
Copy link
Owner

casatwy commented Jul 11, 2018

不行啊,我跑了一下test case,还是挂很多啊。。。

2018-07-11 1 12 14

@longjianjiang
Copy link
Author

还没改完,昨天先提交了一次😂

@casatwy
Copy link
Owner

casatwy commented Jul 11, 2018

👌我以为你已经改完了,那你只管提交没问题的,改完了跟我说一声就行~

@longjianjiang
Copy link
Author

好的,谢谢casa;

jianglongjian and others added 5 commits July 11, 2018 18:24
当sqlString中有汉字时,sqlString.length != [sqlString UTF8String]的字节长度(汉字UTF8编码中占两个字节)。
所以这里应该是(int)[sqlString lengthOfBytesUsingEncoding:NSUTF8StringEncoding],或像前一个版本一样写成-1
sql语句中有汉字时result=SQLITE_ERROR
@longjianjiang
Copy link
Author

casa,我提交了现在可以通过测试了;但是现在运行demo的async test, 有时候没执行完就finish了, 麻烦casa看下。

@casatwy
Copy link
Owner

casatwy commented Jul 16, 2018

你现在的分支有冲突,需要rebase一下

@longjianjiang
Copy link
Author

casa冲突解决了。

@casatwy
Copy link
Owner

casatwy commented Jul 16, 2018

很棒!test case全部通过了!跑async test的时候,控制台报了错误:

======================

<NSThread: 0x6000028b6a00>{number = 1, name = main}

/Users/casa/Playground/CTPersistance/CTPersistance/CTPersistance/QueryCommand/Statement/CTPersistanceSqlStatement.m
-CTPersistanceSqlStatement initWithSqlString:bindValueList:database:error::

error is:
	 file is not a database 

 sqlString is CREATE TABLE IF NOT EXISTS `test` (`timeStamp` INTEGER ,`primaryKey` INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL ,`defaultStr` TEXT DEFAULT '',`age` INTEGER ,`defaultInt` INTEGER DEFAULT 1,`isCelebrity` BOOLEAN ,`defaultBlob` BLOB ,`defaultBool` INTEGER DEFAULT 1,`progress` REAL ,`avatar` BLOB ,`uniqueString` TEXT ,`nilValue` TEXT ,`name` TEXT ,`defaultDouble` REAL DEFAULT 1);

======================

你可以看一下

@longjianjiang
Copy link
Author

好的。

@longjianjiang
Copy link
Author

casa, 跑完test case 运行async test 的时候应该是TestTable 执行queryCommand的时候,在CTPersistenceDatabasedecrypt: 方法

  NSArray <NSString *> *secretKey = [[CTMediator sharedInstance] performTarget:self.target
                                                             action:@"secretKey"
                                                             params:@{kCTPersistanceConfigurationParamsKeyDatabaseName:self.databaseName}
                                                  shouldCacheTarget:NO];
    
    if ([secretKey isKindOfClass:[NSString class]]) {
        NSString *keyString = (NSString *)secretKey;
        if (keyString.length > 0) {
            sqlite3_key(_database, [keyString UTF8String], (int)keyString.length);
        }
        return;
    }

secretKey 为nil, 所以没有执行到sqlite3_key, 数据库处于加密,所以报了 file is not a database 错误。

还请casa 确认下。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants