From 2b52f76ed2103bc6d458767906753814ee8ba9e1 Mon Sep 17 00:00:00 2001 From: Max Date: Fri, 19 Jun 2015 21:44:23 +0200 Subject: Fix an issue (affecting mostly Russian & Asian users) where Sequel Pro would error if the mysql server truncated a column name (fixes #2150) --- .../Source/SPMySQLResult Categories/Field Definitions.m | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) (limited to 'Frameworks/SPMySQLFramework/Source/SPMySQLResult Categories') 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"]; -- cgit v1.2.3