aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMax <post@wickenrode.com>2015-07-14 18:13:25 +0200
committerMax <post@wickenrode.com>2015-07-14 18:13:25 +0200
commitd8a2b9b9e2b998e9bcf8b6ede19b4442cecf5ef8 (patch)
tree4585aba0511176d5ad556a2eda4d36b278964be1
parentdc1adcaafc3439c1998fdfaf15f0cdeee9be778f (diff)
downloadsequelpro-d8a2b9b9e2b998e9bcf8b6ede19b4442cecf5ef8.tar.gz
sequelpro-d8a2b9b9e2b998e9bcf8b6ede19b4442cecf5ef8.tar.bz2
sequelpro-d8a2b9b9e2b998e9bcf8b6ede19b4442cecf5ef8.zip
Fix an exception caused by empty column names in query results (fixes #2173)
Issue likely introduced in 2b52f76e.
-rw-r--r--Frameworks/SPMySQLFramework/Source/SPMySQLResult Categories/Field Definitions.m15
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"];
}