wcdb icon indicating copy to clipboard operation
wcdb copied to clipboard

Error handling

Open 0x1306a94 opened this issue 1 year ago • 3 comments

The language of WCDB

Objective-C WCDB.objc

The version of WCDB

2.1.0

The platform of WCDB

iOS

The installation of WCDB

Cocoapods

What's the issue?

  • The database table has a unique constraint set.
[database traceError:^(WCTError *_Nonnull error) {
        NSString *message = error.message;
        WCTErrorExtendedCode extendedCode = [error extendedCode];
        /*
         * The callback here will be triggered first, and extendedCode is WCTErrorExtendedCodeConstraintUnique.
         */
}];

// Simulate unique constraint data insertion here
[database insertObject:object intoTable:xx];
WCTError *error = [database error];
/*
 * But the extendedCode obtained here is not WCTErrorExtendedCodeConstraintUnique.
 * And this error is also isOk
 */
WCTErrorExtendedCode extendedCode = [error extendedCode];

0x1306a94 avatar Apr 18 '24 06:04 0x1306a94

Get

Qiuwen-chen avatar Apr 18 '24 08:04 Qiuwen-chen

You can use insertOrIgnore or insertOrReplace here.

Qiuwen-chen avatar Apr 19 '24 03:04 Qiuwen-chen

You can use insertOrIgnore or insertOrReplace here.

  • I know this can be solved
  • But this error itself should be a bug

0x1306a94 avatar Apr 19 '24 03:04 0x1306a94

Fixed in v2.1.4

Qiuwen-chen avatar May 07 '24 00:05 Qiuwen-chen