diff options
-rw-r--r-- | Frameworks/SPMySQLFramework/Source/SPMySQLResult Categories/Field Definitions.m | 15 |
1 files changed, 10 insertions, 5 deletions
diff --git a/Frameworks/SPMySQLFramework/Source/SPMySQLResult Categories/Field Definitions.m b/Frameworks/SPMySQLFramework/Source/SPMySQLResult Categories/Field Definitions.m index d0eac4a1..c61b9140 100644 --- a/Frameworks/SPMySQLFramework/Source/SPMySQLResult Categories/Field Definitions.m +++ b/Frameworks/SPMySQLFramework/Source/SPMySQLResult Categories/Field Definitions.m @@ -232,28 +232,33 @@ const SPMySQLResultCharset SPMySQLCharsetMap[] = // Record the original column position within the result set [eachField setObject:[NSString stringWithFormat:@"%llu", (unsigned long long)i] forKey:@"datacolumnindex"]; + // mysqlField.name might point to an empty string or NULL (theoretically). + // _stringWithBytes:... will return @"" if either bytes is NULL or length is 0. + // For now let's interpret (bytes != NULL) as a valid string (possibly empty) + // and otherwise as 'value not set'. + // Record the column name, or alias if one is being used - if (mysqlField.name_length) { + if (mysqlField.name) { [eachField setObject:[self _lossyStringWithBytes:mysqlField.name length:mysqlField.name_length wasLossy:NULL] forKey:@"name"]; } // Record the original column name if using an alias - if (mysqlField.org_name_length) { + if (mysqlField.org_name) { [eachField setObject:[self _stringWithBytes:mysqlField.org_name length:mysqlField.org_name_length] forKey:@"org_name"]; } // If the column had an underlying table, record the table name, respecting aliases - if (mysqlField.table_length) { + if (mysqlField.table) { [eachField setObject:[self _stringWithBytes:mysqlField.table length:mysqlField.table_length] forKey:@"table"]; } // If the column had an underlying table, record the original table name, ignoring aliases - if (mysqlField.org_table_length) { + if (mysqlField.org_table) { [eachField setObject:[self _stringWithBytes:mysqlField.org_table length:mysqlField.org_table_length] forKey:@"org_table"]; } // If the column had an underlying database, record the database name - if (mysqlField.db_length) { + if (mysqlField.db) { [eachField setObject:[self _stringWithBytes:mysqlField.db length:mysqlField.db_length] forKey:@"db"]; } |