Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

Don't log update errors (e.g. SQLITE_CONSTRAINT on duplicate insert) when _logsErrors is NO #129

Open
wants to merge 2 commits into from

2 participants

@marcuswestin

My use case which motivates this patch is being able to INSERT a contact which may already be in the database. If I see an error after a INSERT update, I can safely ignore the error if it was SQLITE_CONSTRAINT. (In this case I don't want it NSLogged as an error, as there can be hundreds of these errors in a row).

Cheers!
Marcus

@nmtitov

Agree, that'd be useful

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Mar 11, 2013
  1. @marcuswestin
Commits on Jun 4, 2013
  1. @marcuswestin
This page is out of date. Refresh to see the latest.
Showing with 3 additions and 3 deletions.
  1. +3 −3 src/FMDatabase.m
View
6 src/FMDatabase.m
@@ -932,8 +932,8 @@ - (BOOL)executeUpdate:(NSString*)sql error:(NSError**)outErr withArgumentsInArra
NSLog(@"Error calling sqlite3_step (%d: %s) SQLITE_MISUSE", rc, sqlite3_errmsg(_db));
NSLog(@"DB Query: %@", sql);
}
- else {
- // wtf?
+ else if (_logsErrors) {
+ // e.g SQLITE_CONSTRAINT error
NSLog(@"Unknown error calling sqlite3_step (%d: %s) eu", rc, sqlite3_errmsg(_db));
NSLog(@"DB Query: %@", sql);
}
@@ -967,7 +967,7 @@ - (BOOL)executeUpdate:(NSString*)sql error:(NSError**)outErr withArgumentsInArra
closeErrorCode = sqlite3_finalize(pStmt);
}
- if (closeErrorCode != SQLITE_OK) {
+ if (closeErrorCode != SQLITE_OK && _logsErrors) {
NSLog(@"Unknown error finalizing or resetting statement (%d: %s)", closeErrorCode, sqlite3_errmsg(_db));
NSLog(@"DB Query: %@", sql);
}
Something went wrong with that request. Please try again.