diff options
author | Max <post@wickenrode.com> | 2015-06-19 21:44:23 +0200 |
---|---|---|
committer | Max <post@wickenrode.com> | 2015-06-19 21:44:23 +0200 |
commit | 2b52f76ed2103bc6d458767906753814ee8ba9e1 (patch) | |
tree | 6cda5dc4fdabd24ce673b956c5096c06a86a1d3b /Frameworks/SPMySQLFramework/Source/SPMySQLResult Categories | |
parent | ce3353422006e927be3005123223c20d8e09b539 (diff) | |
download | sequelpro-2b52f76ed2103bc6d458767906753814ee8ba9e1.tar.gz sequelpro-2b52f76ed2103bc6d458767906753814ee8ba9e1.tar.bz2 sequelpro-2b52f76ed2103bc6d458767906753814ee8ba9e1.zip |
Fix an issue (affecting mostly Russian & Asian users) where Sequel Pro would error if the mysql server truncated a column name (fixes #2150)
Diffstat (limited to 'Frameworks/SPMySQLFramework/Source/SPMySQLResult Categories')
-rw-r--r-- | Frameworks/SPMySQLFramework/Source/SPMySQLResult Categories/Field Definitions.m | 13 |
1 files changed, 9 insertions, 4 deletions
diff --git a/Frameworks/SPMySQLFramework/Source/SPMySQLResult Categories/Field Definitions.m b/Frameworks/SPMySQLFramework/Source/SPMySQLResult Categories/Field Definitions.m index b70d2032..d0eac4a1 100644 --- a/Frameworks/SPMySQLFramework/Source/SPMySQLResult Categories/Field Definitions.m +++ b/Frameworks/SPMySQLFramework/Source/SPMySQLResult Categories/Field Definitions.m @@ -44,6 +44,7 @@ @interface SPMySQLResult (Private_API) - (NSString *)_stringWithBytes:(const void *)bytes length:(NSUInteger)length; +- (NSString *)_lossyStringWithBytes:(const void *)bytes length:(NSUInteger)length wasLossy:(BOOL *)outLossy; @end @@ -232,11 +233,15 @@ const SPMySQLResultCharset SPMySQLCharsetMap[] = [eachField setObject:[NSString stringWithFormat:@"%llu", (unsigned long long)i] forKey:@"datacolumnindex"]; // Record the column name, or alias if one is being used - [eachField setObject:[self _stringWithBytes:mysqlField.name length:mysqlField.name_length] forKey:@"name"]; - + if (mysqlField.name_length) { + [eachField setObject:[self _lossyStringWithBytes:mysqlField.name length:mysqlField.name_length wasLossy:NULL] forKey:@"name"]; + } + // Record the original column name if using an alias - [eachField setObject:[self _stringWithBytes:mysqlField.org_name length:mysqlField.org_name_length] forKey:@"org_name"]; - + if (mysqlField.org_name_length) { + [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) { [eachField setObject:[self _stringWithBytes:mysqlField.table length:mysqlField.table_length] forKey:@"table"]; |