aboutsummaryrefslogtreecommitdiffstats
path: root/Source/SPDatabaseData.m
diff options
context:
space:
mode:
authorrowanbeentje <rowan@beent.je>2010-06-14 21:20:40 +0000
committerrowanbeentje <rowan@beent.je>2010-06-14 21:20:40 +0000
commitce0bde25cb5388aeb33e57883e7da89473086417 (patch)
treea2c91ca879e15a8f809361a5a5d1a18ee4e603de /Source/SPDatabaseData.m
parent6e1a24c45eb99a9c9f8e1cb708b64bdc504d5efe (diff)
downloadsequelpro-ce0bde25cb5388aeb33e57883e7da89473086417.tar.gz
sequelpro-ce0bde25cb5388aeb33e57883e7da89473086417.tar.bz2
sequelpro-ce0bde25cb5388aeb33e57883e7da89473086417.zip
- Convert connection encoding menus to be menu tag based to fix localisation errors
- Add database encoding retrieval support for MySQL 4.1 - Convert the add table and add database sheets to use encoding menus derived from server supported encodings - Re-layout preferences with larger labels to aid localisation - Fix preference resizing in non-Favorite tabs
Diffstat (limited to 'Source/SPDatabaseData.m')
-rw-r--r--Source/SPDatabaseData.m26
1 files changed, 24 insertions, 2 deletions
diff --git a/Source/SPDatabaseData.m b/Source/SPDatabaseData.m
index becd1d6e..27b542c4 100644
--- a/Source/SPDatabaseData.m
+++ b/Source/SPDatabaseData.m
@@ -29,6 +29,7 @@
@interface SPDatabaseData (PrivateAPI)
- (NSMutableArray *)_getDatabaseDataForQuery:(NSString *)query;
+NSInteger _sortMySQL4CharsetEntry(NSDictionary *itemOne, NSDictionary *itemTwo, void *context);
@end
@@ -392,8 +393,21 @@ const SPDatabaseCharSets charsets[] =
// Try to retrieve the available character set encodings from the database
// Check the information_schema.character_sets table is accessible
- if (serverMajorVersion >= 5)
- [characterSetEncodings addObjectsFromArray:[self _getDatabaseDataForQuery:@"SELECT * FROM `information_schema`.`character_sets` ORDER BY `character_set_name` ASC"]];
+ if (serverMajorVersion >= 5) {
+ [characterSetEncodings addObjectsFromArray:[self _getDatabaseDataForQuery:@"SELECT * FROM `information_schema`.`character_sets` ORDER BY `character_set_name` ASC"]];
+ } else if (serverMajorVersion == 4 && serverMinorVersion >= 1) {
+ NSArray *supportedEncodings = [self _getDatabaseDataForQuery:@"SHOW CHARACTER SET"];
+ supportedEncodings = [supportedEncodings sortedArrayUsingFunction:_sortMySQL4CharsetEntry context:nil];
+ for (NSDictionary *anEncoding in supportedEncodings) {
+ NSDictionary *convertedEncoding = [NSDictionary dictionaryWithObjectsAndKeys:
+ [anEncoding objectForKey:@"Charset"], @"CHARACTER_SET_NAME",
+ [anEncoding objectForKey:@"Description"], @"DESCRIPTION",
+ [anEncoding objectForKey:@"Default collation"], @"DEFAULT_COLLATE_NAME",
+ [anEncoding objectForKey:@"Maxlen"], @"MAXLEN",
+ nil];
+ [characterSetEncodings addObject:convertedEncoding];
+ }
+ }
// If that failed, get the list of character set encodings from the hard-coded list
if (![characterSetEncodings count]) {
@@ -453,4 +467,12 @@ const SPDatabaseCharSets charsets[] =
return array;
}
+/**
+ * Sorts a 4.1-style SHOW CHARACTER SET result by the Charset key.
+ */
+NSInteger _sortMySQL4CharsetEntry(NSDictionary *itemOne, NSDictionary *itemTwo, void *context)
+{
+ return [[itemOne objectForKey:@"Charset"] compare:[itemTwo objectForKey:@"Charset"]];
+}
+
@end