Explorar o código

Deprecated columnExists:columnName: in favor of columnExists:inTableWithName:

ccgus %!s(int64=13) %!d(string=hai) anos
pai
achega
eef884233f
Modificáronse 4 ficheiros con 18 adicións e 7 borrados
  1. 4 1
      CHANGES_AND_TODO_LIST.txt
  2. 5 1
      src/FMDatabaseAdditions.h
  3. 6 3
      src/FMDatabaseAdditions.m
  4. 3 2
      src/fmdb.m

+ 4 - 1
CHANGES_AND_TODO_LIST.txt

@@ -3,7 +3,10 @@ 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.
 
-
+2012.05.25:
+    Deprecated columnExists:columnName: in favor of columnExists:inTableWithName:
+    Remembered to update the changes notes.  I've been forgetting to do this recently.
+    
 2012.03.22:
     Deprecated resultDict and replaced it with resultDictionary on FMResultSet.  Slight change in behavior as well- resultDictionary will return case sensitive keys.
     Fixed a problem with getTableSchema: not working with table names that start with a number.

+ 5 - 1
src/FMDatabaseAdditions.h

@@ -26,8 +26,12 @@
 - (BOOL)tableExists:(NSString*)tableName;
 - (FMResultSet*)getSchema;
 - (FMResultSet*)getTableSchema:(NSString*)tableName;
-- (BOOL)columnExists:(NSString*)tableName columnName:(NSString*)columnName;
+
+- (BOOL)columnExists:(NSString*)columnName inTableWithName:(NSString*)tableName;
 
 - (BOOL)validateSQL:(NSString*)sql error:(NSError**)error;
 
+// deprecated - use columnExists:inTableWithName: instead.
+- (BOOL)columnExists:(NSString*)tableName columnName:(NSString*)columnName __attribute__ ((deprecated));
+
 @end

+ 6 - 3
src/FMDatabaseAdditions.m

@@ -94,8 +94,7 @@ - (FMResultSet*)getTableSchema:(NSString*)tableName {
     return rs;
 }
 
-
-- (BOOL)columnExists:(NSString*)tableName columnName:(NSString*)columnName {
+- (BOOL)columnExists:(NSString*)columnName inTableWithName:(NSString*)tableName {
     
     BOOL returnBool = NO;
     
@@ -106,7 +105,7 @@ - (BOOL)columnExists:(NSString*)tableName columnName:(NSString*)columnName {
     
     //check if column is present in table schema
     while ([rs next]) {
-        if ([[[rs stringForColumn:@"name"] lowercaseString] isEqualToString: columnName]) {
+        if ([[[rs stringForColumn:@"name"] lowercaseString] isEqualToString:columnName]) {
             returnBool = YES;
             break;
         }
@@ -118,6 +117,10 @@ - (BOOL)columnExists:(NSString*)tableName columnName:(NSString*)columnName {
     return returnBool;
 }
 
+- (BOOL)columnExists:(NSString*)tableName columnName:(NSString*)columnName __attribute__ ((deprecated)) {
+    return [self columnExists:columnName inTableWithName:tableName];
+}
+
 - (BOOL)validateSQL:(NSString*)sql error:(NSError**)error {
     sqlite3_stmt *pStmt = NULL;
     BOOL validationSucceeded = YES;

+ 3 - 2
src/fmdb.m

@@ -345,8 +345,9 @@ int main (int argc, const char * argv[]) {
     }
     
     
-    
-    
+    FMDBQuickCheck([db columnExists:@"a" inTableWithName:@"nulltest"]);
+    FMDBQuickCheck([db columnExists:@"b" inTableWithName:@"nulltest"]);
+    FMDBQuickCheck(![db columnExists:@"c" inTableWithName:@"nulltest"]);
     
     
     // null dates