1

I'm using dbaccess for my project. In my project, one dbobject's commit is not working. My dbobject is Message like:

#import <DBAccess/DBAccess.h>

@interface MessageObject : DBObject

@property (strong) NSString *to;
@property (strong) NSString *from;
@property (strong) NSString *message;
@property (strong) NSString *_id;
@property int messageType;
@property long long messageSentTime;

@end

#import "MessageObject.h"

@implementation MessageObject
@dynamic to, from, message, _id;
@dynamic messageType;
@dynamic messageSentTime;
@end

For this object, when I commit, commit is not working. For all other object's commit is working. Can anyone help me? Thanks in adv.

4

1 回答 1

1

在DBDelegate上实现错误方法可能是值得的。

- (void)databaseError:(DBError *)error {
    NSLog(@"error >> %@\nsql >> %@", error.errorMessage, error.sqlQuery);
}

这将告诉您“FROM”是 SQLite 中的保留字,并且您已将其用作列名。

当前生成的错误如下。

(lldb) **po error.errorMessage**
near "from": syntax error

(lldb) **po error.sqlQuery**
SELECT MessageObject.from as from, MessageObject._id as _id, MessageObject.Id as Id, MessageObject.messageSentTime as messageSentTime, MessageObject.message as message, MessageObject.to as to, MessageObject.messageType as messageType FROM MessageObject 

现在,也就是说,我认为我们可以通过更改我们在选择查询中命名字段的方式来轻松修复它,但是现在您可以更改属性名称。在任何未来版本中,我们将修复此问题以阻止此错误发生。

谢谢

于 2015-04-29T06:50:14.983 回答