Parcourir la source

Notes and renames.

August Mueller il y a 11 ans
Parent
commit
941bfdd7b5
4 fichiers modifiés avec 16 ajouts et 11 suppressions
  1. 5 0
      CHANGES_AND_TODO_LIST.txt
  2. 3 3
      Tests/FMDatabaseTests.m
  3. 5 5
      src/fmdb/FMDatabase.h
  4. 3 3
      src/fmdb/FMDatabase.m

+ 5 - 0
CHANGES_AND_TODO_LIST.txt

@@ -3,6 +3,11 @@ Zip, nada, zilch.  Got any ideas?
 
 If you would like to contribute some code- awesome!  I just ask that you make it conform to the coding conventions already set in here, and to add a couple of tests for your new code to fmdb.m.  And of course, the code should be of general use to more than just a couple of folks.  Send your patches to gus@flyingmeat.com.
 
+2014.04.23
+    New executeStatements: method, which will take a single UTF-8 string with multiple statements in it.  This is great for batch updates.  There is also a executeStatements:withResultBlock: version which takes a callback block which will be used for any statements which return rows in the bulk statement.  Thanks to Rob Ryan for contributing code for this.
+
+    Deprecated update:withErrorAndBindings: in favor of executeUpdate:withErrorAndBindings:
+
 2014.04.09
     Added back in busy handler code after a brief hiatus (check out the 2013.12.10 notes).  But now doing so with sqlite3_busy_handler instead of while loops in the various execution places.
     Added some new optional classes that will help with doing batch updates  - check out FMSQLStatementSplitter.h for more info.  Thanks to Julius Scott for the patches.

+ 3 - 3
Tests/FMDatabaseTests.m

@@ -843,7 +843,7 @@ - (void)testBulkSQL
                      "insert into bulktest2 (y) values ('YYY');"
                      "insert into bulktest3 (z) values ('ZZZ');";
 
-    success = [self.db executeBulkSQL:sql];
+    success = [self.db executeStatements:sql];
 
     XCTAssertTrue(success, @"bulk create");
 
@@ -851,7 +851,7 @@ - (void)testBulkSQL
            "select count(*) as count from bulktest2;"
            "select count(*) as count from bulktest3;";
 
-    success = [self.db executeBulkSQL:sql block:^int(NSDictionary *dictionary) {
+    success = [self.db executeStatements:sql withResultBlock:^int(NSDictionary *dictionary) {
         NSInteger count = [dictionary[@"count"] integerValue];
         XCTAssertEqual(count, 1, @"expected one record for dictionary %@", dictionary);
         return 0;
@@ -863,7 +863,7 @@ - (void)testBulkSQL
            "drop table bulktest2;"
            "drop table bulktest3;";
 
-    success = [self.db executeBulkSQL:sql];
+    success = [self.db executeStatements:sql];
 
     XCTAssertTrue(success, @"bulk drop");
 }

+ 5 - 5
src/fmdb/FMDatabase.h

@@ -39,7 +39,7 @@
 #endif
 
 
-typedef int(^FMDBExecuteBulkSQLCallbackBlock)(NSDictionary *resultsDictionary);
+typedef int(^FMDBExecuteStatementsCallbackBlock)(NSDictionary *resultsDictionary);
 
 
 /** A SQLite ([http://sqlite.org/](http://sqlite.org/)) Objective-C wrapper.
@@ -384,12 +384,12 @@ typedef int(^FMDBExecuteBulkSQLCallbackBlock)(NSDictionary *resultsDictionary);
  
  @return      `YES` upon success; `NO` upon failure. If failed, you can call `<lastError>`, `<lastErrorCode>`, or `<lastErrorMessage>` for diagnostic information regarding the failure.
 
- @see executeBulkSQL:block:
+ @see executeStatements:withResultBlock:
  @see [sqlite3_exec()](http://sqlite.org/c3ref/exec.html)
 
  */
 
-- (BOOL)executeBulkSQL:(NSString *)sql;
+- (BOOL)executeStatements:(NSString *)sql;
 
 /** Execute multiple SQL statements with callback handler
  
@@ -404,12 +404,12 @@ typedef int(^FMDBExecuteBulkSQLCallbackBlock)(NSDictionary *resultsDictionary);
  @return          `YES` upon success; `NO` upon failure. If failed, you can call `<lastError>`,
                   `<lastErrorCode>`, or `<lastErrorMessage>` for diagnostic information regarding the failure.
  
- @see executeBulkSQL:
+ @see executeStatements:
  @see [sqlite3_exec()](http://sqlite.org/c3ref/exec.html)
 
  */
 
-- (BOOL)executeBulkSQL:(NSString *)sql block:(FMDBExecuteBulkSQLCallbackBlock)block;
+- (BOOL)executeStatements:(NSString *)sql withResultBlock:(FMDBExecuteStatementsCallbackBlock)block;
 
 /** Last insert rowid
  

+ 3 - 3
src/fmdb/FMDatabase.m

@@ -1113,11 +1113,11 @@ int FMDBExecuteBulkSQLCallback(void *theBlockAsVoid, int columns, char **values,
     return execCallbackBlock(dictionary);
 }
 
-- (BOOL)executeBulkSQL:(NSString *)sql {
-    return [self executeBulkSQL:sql block:nil];
+- (BOOL)executeStatements:(NSString *)sql {
+    return [self executeStatements:sql withResultBlock:nil];
 }
 
-- (BOOL)executeBulkSQL:(NSString *)sql block:(FMDBExecuteBulkSQLCallbackBlock)block {
+- (BOOL)executeStatements:(NSString *)sql withResultBlock:(FMDBExecuteStatementsCallbackBlock)block {
     
     int rc;
     char *errmsg = nil;