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.
It might be worth you implementing the error method on DBDelegate.
- (void)databaseError:(DBError *)error {
NSLog(@"error >> %@\nsql >> %@", error.errorMessage, error.sqlQuery);
}
That will show you that "FROM" is a reserved word in SQLite and you have used it as a column name.
The current error that is generated is as follows.
(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
Now, that said, I think we can fix it pretty easily by changing how we name the fields in the selection queries, but for now you could change the property name. In any future versions we will fix this problem to stop this error occurring.
Thanks