aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authormltownsend <mltownsend@gmail.com>2010-05-08 16:27:04 +0000
committermltownsend <mltownsend@gmail.com>2010-05-08 16:27:04 +0000
commit1ba45688cf6b851a662429eb770ce4fcea93d1bf (patch)
tree199a319117f9e558de2b4d53a2be75aa791bf5c9
parentb4648f71fc5d986672158dacae8c1180a8d12413 (diff)
downloadsequelpro-1ba45688cf6b851a662429eb770ce4fcea93d1bf.tar.gz
sequelpro-1ba45688cf6b851a662429eb770ce4fcea93d1bf.tar.bz2
sequelpro-1ba45688cf6b851a662429eb770ce4fcea93d1bf.zip
Fix for Issue#667
-rw-r--r--Source/SPUserManager.m25
1 files changed, 20 insertions, 5 deletions
diff --git a/Source/SPUserManager.m b/Source/SPUserManager.m
index de70b777..f0117045 100644
--- a/Source/SPUserManager.m
+++ b/Source/SPUserManager.m
@@ -210,10 +210,10 @@
// We only care about setting the user and password keys on the parent, together with their
// original values for comparison purposes
- [parent setValue:username forKey:@"user"];
- [parent setValue:username forKey:@"originaluser"];
- [parent setValue:[item objectForKey:@"Password"] forKey:@"password"];
- [parent setValue:[item objectForKey:@"Password"] forKey:@"originalpassword"];
+ [parent setPrimitiveValue:username forKey:@"user"];
+ [parent setPrimitiveValue:username forKey:@"originaluser"];
+ [parent setPrimitiveValue:[item objectForKey:@"Password"] forKey:@"password"];
+ [parent setPrimitiveValue:[item objectForKey:@"Password"] forKey:@"originalpassword"];
[self _initializeChild:child withItem:item];
@@ -1045,6 +1045,18 @@
NSString *dbName = [schemaPriv valueForKey:@"db"];
+ NSString *statement = [NSString stringWithFormat:@"SELECT USER,HOST FROM `mysql`.`db` WHERE USER=%@ AND HOST=%@ AND DB=%@",
+ [[schemaPriv valueForKeyPath:@"user.parent.user"] tickQuotedString],
+ [[schemaPriv valueForKeyPath:@"user.host"] tickQuotedString],
+ [dbName tickQuotedString]];
+ MCPResult *result = [self.mySqlConnection queryString:statement];
+ NSUInteger rows = [result numOfRows];
+ BOOL userExists = YES;
+ if (rows == 0)
+ {
+ userExists = NO;
+ }
+
for (NSString *key in self.privsSupportedByServer)
{
if (![key hasSuffix:@"_priv"]) continue;
@@ -1055,7 +1067,10 @@
[grantPrivileges addObject:[privilege replaceUnderscoreWithSpace]];
}
else {
- [revokePrivileges addObject:[privilege replaceUnderscoreWithSpace]];
+ if (userExists || [grantPrivileges count] > 0) {
+ [revokePrivileges addObject:[privilege replaceUnderscoreWithSpace]];
+ }
+
}
}
@catch (NSException * e) {