Browse Source

Fixed a problem with getTableSchema: not working with table names that start with a number.

August Mueller 14 years ago
parent
commit
a887a6ff21
3 changed files with 16 additions and 1 deletions
  1. 6 0
      CHANGES_AND_TODO_LIST.txt
  2. 1 1
      src/FMDatabaseAdditions.m
  3. 9 0
      src/fmdb.m

+ 6 - 0
CHANGES_AND_TODO_LIST.txt

@@ -3,6 +3,12 @@ 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.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.
+
+
 2012.02.10:
     Changed up FMDatabasePool so that you can't "pop" it from a pool anymore.  I just consider this too risky- use the block based functions instead.
     Also provided a good reason in main.m for why you should use FMDatabaseQueue instead.  Search for "ONLY_USE_THE_POOL_IF_YOU_ARE_DOING_READS".

+ 1 - 1
src/FMDatabaseAdditions.m

@@ -89,7 +89,7 @@ - (FMResultSet*)getSchema {
 - (FMResultSet*)getTableSchema:(NSString*)tableName {
     
     //result colums: cid[INTEGER], name,type [STRING], notnull[INTEGER], dflt_value[],pk[INTEGER]
-    FMResultSet *rs = [self executeQuery:[NSString stringWithFormat: @"PRAGMA table_info(%@)", tableName]];
+    FMResultSet *rs = [self executeQuery:[NSString stringWithFormat: @"PRAGMA table_info('%@')", tableName]];
     
     return rs;
 }

+ 9 - 0
src/fmdb.m

@@ -150,6 +150,15 @@ int main (int argc, const char * argv[]) {
     }
     
     
+    // check funky table names + getTableSchema
+    [db executeUpdate:@"create table '234 fds' (foo text)"];
+    FMDBQuickCheck(![db hadError]);
+    rs = [db getTableSchema:@"234 fds"];
+    FMDBQuickCheck([rs next]);
+    [rs close];
+    
+    
+    
     // ----------------------------------------------------------------------------------------
     // blob support.
     [db executeUpdate:@"create table blobTable (a text, b blob)"];