Skip to content

Commit

Permalink
Fixed a problem with getTableSchema: not working with table names tha…
Browse files Browse the repository at this point in the history
…t start with a number.
  • Loading branch information
ccgus committed Mar 22, 2012
1 parent 347cf12 commit a887a6f
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 1 deletion.
6 changes: 6 additions & 0 deletions CHANGES_AND_TODO_LIST.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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 [email protected].


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".
Expand Down
2 changes: 1 addition & 1 deletion src/FMDatabaseAdditions.m
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
9 changes: 9 additions & 0 deletions src/fmdb.m
Original file line number Diff line number Diff line change
Expand Up @@ -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)"];
Expand Down

0 comments on commit a887a6f

Please sign in to comment.