aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorrowanbeentje <rowan@beent.je>2010-05-03 19:16:10 +0000
committerrowanbeentje <rowan@beent.je>2010-05-03 19:16:10 +0000
commitd7ebbe9b1e17c69a35e7ff05b5fa265e180fcebf (patch)
tree9b5c9a9634d3cf55b40e1cd5d092a853c330de16
parent8349166b891abcf4584e87e6320e83c4c0576374 (diff)
downloadsequelpro-d7ebbe9b1e17c69a35e7ff05b5fa265e180fcebf.tar.gz
sequelpro-d7ebbe9b1e17c69a35e7ff05b5fa265e180fcebf.tar.bz2
sequelpro-d7ebbe9b1e17c69a35e7ff05b5fa265e180fcebf.zip
- Merge in fixes from trunk for final release - incoporates r2175, r2177, r2184, r2198, r2200, r2203, r2205 and r2206.
-rw-r--r--Interfaces/English.lproj/UserManagerView.xib112
-rw-r--r--Source/SPExtendedTableInfo.m3
-rw-r--r--Source/SPSSHTunnel.m4
-rw-r--r--Source/SPUserManager.m95
-rw-r--r--Source/SPUserManager.xcdatamodel/elementsbin127771 -> 131784 bytes
-rw-r--r--Source/SPUserManager.xcdatamodel/layoutbin9663 -> 9663 bytes
-rw-r--r--Source/TableContent.m18
-rw-r--r--Source/TableSource.m14
8 files changed, 172 insertions, 74 deletions
diff --git a/Interfaces/English.lproj/UserManagerView.xib b/Interfaces/English.lproj/UserManagerView.xib
index 36c8dd39..d28c0761 100644
--- a/Interfaces/English.lproj/UserManagerView.xib
+++ b/Interfaces/English.lproj/UserManagerView.xib
@@ -2,10 +2,10 @@
<archive type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="7.10">
<data>
<int key="IBDocument.SystemTarget">1050</int>
- <string key="IBDocument.SystemVersion">10C540</string>
- <string key="IBDocument.InterfaceBuilderVersion">740</string>
- <string key="IBDocument.AppKitVersion">1038.25</string>
- <string key="IBDocument.HIToolboxVersion">458.00</string>
+ <string key="IBDocument.SystemVersion">10D2094</string>
+ <string key="IBDocument.InterfaceBuilderVersion">762</string>
+ <string key="IBDocument.AppKitVersion">1038.29</string>
+ <string key="IBDocument.HIToolboxVersion">460.00</string>
<object class="NSMutableDictionary" key="IBDocument.PluginVersions">
<bool key="EncodedWithXMLCoder">YES</bool>
<object class="NSArray" key="dict.sortedKeys">
@@ -15,18 +15,17 @@
</object>
<object class="NSMutableArray" key="dict.values">
<bool key="EncodedWithXMLCoder">YES</bool>
- <string>740</string>
- <string>1.2.2</string>
+ <string>762</string>
+ <string>1.2.5</string>
</object>
</object>
<object class="NSMutableArray" key="IBDocument.EditedObjectIDs">
<bool key="EncodedWithXMLCoder">YES</bool>
- <integer value="31"/>
</object>
<object class="NSArray" key="IBDocument.PluginDependencies">
<bool key="EncodedWithXMLCoder">YES</bool>
- <string>com.brandonwalkin.BWToolkit</string>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
+ <string>com.brandonwalkin.BWToolkit</string>
</object>
<object class="NSMutableDictionary" key="IBDocument.Metadata">
<bool key="EncodedWithXMLCoder">YES</bool>
@@ -56,10 +55,10 @@
<string key="NSWindowTitle">User Managment</string>
<string key="NSWindowClass">NSWindow</string>
<nil key="NSViewClass"/>
- <string key="NSWindowContentMaxSize">{3.40282e+38, 3.40282e+38}</string>
+ <string key="NSWindowContentMaxSize">{1.79769e+308, 1.79769e+308}</string>
<string key="NSWindowContentMinSize">{752, 506}</string>
<object class="NSView" key="NSWindowView" id="846307432">
- <reference key="NSNextResponder"/>
+ <nil key="NSNextResponder"/>
<int key="NSvFlags">256</int>
<object class="NSMutableArray" key="NSSubviews">
<bool key="EncodedWithXMLCoder">YES</bool>
@@ -148,7 +147,7 @@
<string key="NSColorName">controlBackgroundColor</string>
<object class="NSColor" key="NSColor" id="246134814">
<int key="NSColorSpace">3</int>
- <bytes key="NSWhite">MC42NjY2NjY2ODY1AA</bytes>
+ <bytes key="NSWhite">MC42NjY2NjY2NjY3AA</bytes>
</object>
</object>
<object class="NSColor" key="NSTextColor" id="315534074">
@@ -204,7 +203,6 @@
</object>
<string key="NSFrame">{{0, 17}, {194, 467}}</string>
<reference key="NSSuperview" ref="848314643"/>
- <reference key="NSNextKeyView" ref="265138544"/>
<reference key="NSDocView" ref="265138544"/>
<reference key="NSBGColor" ref="898983655"/>
<int key="NScvFlags">4</int>
@@ -238,7 +236,6 @@
</object>
<string key="NSFrameSize">{194, 17}</string>
<reference key="NSSuperview" ref="848314643"/>
- <reference key="NSNextKeyView" ref="98886535"/>
<reference key="NSDocView" ref="98886535"/>
<reference key="NSBGColor" ref="898983655"/>
<int key="NScvFlags">4</int>
@@ -247,7 +244,6 @@
</object>
<string key="NSFrame">{{0, 22}, {194, 484}}</string>
<reference key="NSSuperview" ref="490248567"/>
- <reference key="NSNextKeyView" ref="310332121"/>
<int key="NSsFlags">560</int>
<reference key="NSVScroller" ref="710626046"/>
<reference key="NSHScroller" ref="851800246"/>
@@ -400,6 +396,7 @@
</object>
</object>
</object>
+ <int key="NSSelectedIndex">4</int>
<bool key="NSPullDown">YES</bool>
<int key="NSPreferredEdge">1</int>
<bool key="NSUsesItemFromMenu">YES</bool>
@@ -435,7 +432,7 @@
<object class="NSTabViewItem" id="820796939">
<string key="NSIdentifier">General</string>
<object class="NSView" key="NSView" id="143215913">
- <reference key="NSNextResponder" ref="716372522"/>
+ <nil key="NSNextResponder"/>
<int key="NSvFlags">256</int>
<object class="NSMutableArray" key="NSSubviews">
<bool key="EncodedWithXMLCoder">YES</bool>
@@ -564,7 +561,6 @@
</object>
</object>
<string key="NSFrame">{{10, 33}, {511, 414}}</string>
- <reference key="NSSuperview" ref="716372522"/>
</object>
<string key="NSLabel">General</string>
<reference key="NSColor" ref="409859189"/>
@@ -1398,7 +1394,7 @@
<object class="NSTabViewItem" id="487249930">
<string key="NSIdentifier">Schema Privileges</string>
<object class="NSView" key="NSView" id="601698335">
- <nil key="NSNextResponder"/>
+ <reference key="NSNextResponder" ref="716372522"/>
<int key="NSvFlags">256</int>
<object class="NSMutableArray" key="NSSubviews">
<bool key="EncodedWithXMLCoder">YES</bool>
@@ -1480,7 +1476,6 @@
</object>
<string key="NSFrame">{{1, 17}, {130, 363}}</string>
<reference key="NSSuperview" ref="307214944"/>
- <reference key="NSNextKeyView" ref="280739950"/>
<reference key="NSDocView" ref="280739950"/>
<reference key="NSBGColor" ref="898983655"/>
<int key="NScvFlags">4</int>
@@ -1515,7 +1510,6 @@
</object>
<string key="NSFrame">{{1, 0}, {130, 17}}</string>
<reference key="NSSuperview" ref="307214944"/>
- <reference key="NSNextKeyView" ref="406943647"/>
<reference key="NSDocView" ref="406943647"/>
<reference key="NSBGColor" ref="898983655"/>
<int key="NScvFlags">4</int>
@@ -1524,7 +1518,6 @@
</object>
<string key="NSFrame">{{17, 17}, {132, 381}}</string>
<reference key="NSSuperview" ref="601698335"/>
- <reference key="NSNextKeyView" ref="380397569"/>
<int key="NSsFlags">562</int>
<reference key="NSVScroller" ref="304497597"/>
<reference key="NSHScroller" ref="1067950228"/>
@@ -1611,7 +1604,6 @@
</object>
<string key="NSFrame">{{1, 17}, {130, 363}}</string>
<reference key="NSSuperview" ref="728294866"/>
- <reference key="NSNextKeyView" ref="64638447"/>
<reference key="NSDocView" ref="64638447"/>
<reference key="NSBGColor" ref="898983655"/>
<int key="NScvFlags">4</int>
@@ -1645,7 +1637,6 @@
</object>
<string key="NSFrame">{{1, 0}, {130, 17}}</string>
<reference key="NSSuperview" ref="728294866"/>
- <reference key="NSNextKeyView" ref="599931188"/>
<reference key="NSDocView" ref="599931188"/>
<reference key="NSBGColor" ref="898983655"/>
<int key="NScvFlags">4</int>
@@ -1654,7 +1645,6 @@
</object>
<string key="NSFrame">{{157, 17}, {132, 381}}</string>
<reference key="NSSuperview" ref="601698335"/>
- <reference key="NSNextKeyView" ref="239762482"/>
<int key="NSsFlags">562</int>
<reference key="NSVScroller" ref="210192488"/>
<reference key="NSHScroller" ref="253008686"/>
@@ -1740,7 +1730,6 @@
</object>
<string key="NSFrame">{{1, 17}, {130, 363}}</string>
<reference key="NSSuperview" ref="898351365"/>
- <reference key="NSNextKeyView" ref="443904239"/>
<reference key="NSDocView" ref="443904239"/>
<reference key="NSBGColor" ref="898983655"/>
<int key="NScvFlags">4</int>
@@ -1775,7 +1764,6 @@
</object>
<string key="NSFrame">{{1, 0}, {130, 17}}</string>
<reference key="NSSuperview" ref="898351365"/>
- <reference key="NSNextKeyView" ref="120612996"/>
<reference key="NSDocView" ref="120612996"/>
<reference key="NSBGColor" ref="898983655"/>
<int key="NScvFlags">4</int>
@@ -1784,7 +1772,6 @@
</object>
<string key="NSFrame">{{362, 17}, {132, 381}}</string>
<reference key="NSSuperview" ref="601698335"/>
- <reference key="NSNextKeyView" ref="728383964"/>
<int key="NSsFlags">562</int>
<reference key="NSVScroller" ref="939829514"/>
<reference key="NSHScroller" ref="1063461866"/>
@@ -1843,6 +1830,7 @@
</object>
</object>
<string key="NSFrame">{{10, 33}, {511, 414}}</string>
+ <reference key="NSSuperview" ref="716372522"/>
</object>
<string key="NSLabel">Schema Privileges</string>
<reference key="NSColor" ref="409859189"/>
@@ -2119,13 +2107,13 @@
<reference key="NSTabView" ref="716372522"/>
</object>
</object>
- <reference key="NSSelectedTabViewItem" ref="820796939"/>
+ <reference key="NSSelectedTabViewItem" ref="487249930"/>
<reference key="NSFont" ref="746597359"/>
<int key="NSTvFlags">0</int>
<bool key="NSDrawsBackground">YES</bool>
<object class="NSMutableArray" key="NSSubviews">
<bool key="EncodedWithXMLCoder">YES</bool>
- <reference ref="143215913"/>
+ <reference ref="601698335"/>
</object>
</object>
<object class="NSButton" id="445730006">
@@ -2183,11 +2171,10 @@
</object>
</object>
<string key="NSFrameSize">{752, 506}</string>
- <reference key="NSSuperview"/>
</object>
<string key="NSScreenRect">{{0, 0}, {1680, 1028}}</string>
<string key="NSMinSize">{752, 528}</string>
- <string key="NSMaxSize">{3.40282e+38, 3.40282e+38}</string>
+ <string key="NSMaxSize">{1.79769e+308, 1.79769e+308}</string>
</object>
<object class="NSTreeController" id="889422316">
<object class="NSMutableArray" key="NSDeclaredKeys">
@@ -2509,14 +2496,6 @@
<int key="connectionID">436</int>
</object>
<object class="IBConnectionRecord">
- <object class="IBOutletConnection" key="connection">
- <string key="label">delegate</string>
- <reference key="source" ref="716372522"/>
- <reference key="destination" ref="1001"/>
- </object>
- <int key="connectionID">447</int>
- </object>
- <object class="IBConnectionRecord">
<object class="IBBindingConnection" key="connection">
<string key="label">value: selection.select_priv</string>
<reference key="source" ref="354897609"/>
@@ -4071,6 +4050,22 @@
</object>
<int key="connectionID">922</int>
</object>
+ <object class="IBConnectionRecord">
+ <object class="IBOutletConnection" key="connection">
+ <string key="label">delegate</string>
+ <reference key="source" ref="716372522"/>
+ <reference key="destination" ref="1001"/>
+ </object>
+ <int key="connectionID">924</int>
+ </object>
+ <object class="IBConnectionRecord">
+ <object class="IBActionConnection" key="connection">
+ <string key="label">refresh:</string>
+ <reference key="source" ref="1001"/>
+ <reference key="destination" ref="587450306"/>
+ </object>
+ <int key="connectionID">925</int>
+ </object>
</object>
<object class="IBMutableOrderedSet" key="objectRecords">
<object class="NSArray" key="orderedObjects">
@@ -5483,11 +5478,11 @@
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
- <string>{{240, 174}, {752, 506}}</string>
+ <string>{{152, 121}, {752, 506}}</string>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
<boolean value="NO"/>
<boolean value="NO"/>
- <string>{{240, 174}, {752, 506}}</string>
+ <string>{{152, 121}, {752, 506}}</string>
<boolean value="NO"/>
<boolean value="YES"/>
<string>{752, 506}</string>
@@ -5601,7 +5596,7 @@
<string>com.brandonwalkin.BWToolkit</string>
<string>com.brandonwalkin.BWToolkit</string>
<string>com.brandonwalkin.BWToolkit</string>
- <string>{{511, 95}, {130, 81}}</string>
+ <string>{{202, 63}, {130, 81}}</string>
<string>com.brandonwalkin.BWToolkit</string>
<string>com.brandonwalkin.BWToolkit</string>
<string>com.brandonwalkin.BWToolkit</string>
@@ -5666,7 +5661,7 @@
</object>
</object>
<nil key="sourceID"/>
- <int key="maxID">923</int>
+ <int key="maxID">925</int>
</object>
<object class="IBClassDescriber" key="IBDocument.Classes">
<object class="NSMutableArray" key="referencedPartialClassDescriptions">
@@ -5717,6 +5712,13 @@
<string key="className">NSObject</string>
<object class="IBClassDescriptionSource" key="sourceIdentifier">
<string key="majorKey">IBProjectSource</string>
+ <string key="minorKey">Source/SPMainThreadTrampoline.h</string>
+ </object>
+ </object>
+ <object class="IBPartialClassDescription">
+ <string key="className">NSObject</string>
+ <object class="IBClassDescriptionSource" key="sourceIdentifier">
+ <string key="majorKey">IBProjectSource</string>
<string key="minorKey">Source/SPNotLoaded.h</string>
</object>
</object>
@@ -6626,6 +6628,7 @@
</object>
</object>
<int key="IBDocument.localizationMode">0</int>
+ <string key="IBDocument.TargetRuntimeIdentifier">IBCocoaFramework</string>
<object class="NSMutableDictionary" key="IBDocument.PluginDeclaredDependencies">
<string key="NS.key.0">com.apple.InterfaceBuilder.CocoaPlugin.macosx</string>
<integer value="1050" key="NS.object.0"/>
@@ -6641,5 +6644,30 @@
<bool key="IBDocument.PluginDeclaredDependenciesTrackSystemTargetVersion">YES</bool>
<string key="IBDocument.LastKnownRelativeProjectPath">../../sequel-pro.xcodeproj</string>
<int key="IBDocument.defaultPropertyAccessControl">3</int>
+ <object class="NSMutableDictionary" key="IBDocument.LastKnownImageSizes">
+ <bool key="EncodedWithXMLCoder">YES</bool>
+ <object class="NSArray" key="dict.sortedKeys">
+ <bool key="EncodedWithXMLCoder">YES</bool>
+ <string>NSActionTemplate</string>
+ <string>NSAddTemplate</string>
+ <string>NSLeftFacingTriangleTemplate</string>
+ <string>NSMenuCheckmark</string>
+ <string>NSMenuMixedState</string>
+ <string>NSRemoveTemplate</string>
+ <string>NSRightFacingTriangleTemplate</string>
+ <string>NSSwitch</string>
+ </object>
+ <object class="NSMutableArray" key="dict.values">
+ <bool key="EncodedWithXMLCoder">YES</bool>
+ <string>{10, 10}</string>
+ <string>{8, 8}</string>
+ <string>{9, 9}</string>
+ <string>{9, 8}</string>
+ <string>{7, 2}</string>
+ <string>{8, 8}</string>
+ <string>{9, 9}</string>
+ <string>{15, 15}</string>
+ </object>
+ </object>
</data>
</archive>
diff --git a/Source/SPExtendedTableInfo.m b/Source/SPExtendedTableInfo.m
index fe89d563..d58e731e 100644
--- a/Source/SPExtendedTableInfo.m
+++ b/Source/SPExtendedTableInfo.m
@@ -436,9 +436,10 @@
- (void)textDidEndEditing:(NSNotification *)notification
{
id object = [notification object];
+
if ((object == tableCommentsTextView) && ([object isEditable]) && ([selectedTable length] > 0)) {
- NSString *currentComment = [tableDataInstance statusValueForKey:@"Comment"];
+ NSString *currentComment = [[tableDataInstance statusValueForKey:@"Comment"] stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]];
NSString *newComment = [[tableCommentsTextView string] stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]];
// Check that the user actually changed the tables comment
diff --git a/Source/SPSSHTunnel.m b/Source/SPSSHTunnel.m
index eeef83d2..2b7c31fb 100644
--- a/Source/SPSSHTunnel.m
+++ b/Source/SPSSHTunnel.m
@@ -352,6 +352,10 @@
[[NSNotificationCenter defaultCenter] removeObserver:self
name:@"NSFileHandleDataAvailableNotification"
object:nil];
+
+ // Run the run loop for a short time to ensure all task/pipe callbacks are dealt with
+ [[NSRunLoop currentRunLoop] runUntilDate:[NSDate dateWithTimeIntervalSinceNow:1.0]];
+
[task release], task = nil;
[standardError release], standardError = nil;
[taskEnvironment release], taskEnvironment = nil;
diff --git a/Source/SPUserManager.m b/Source/SPUserManager.m
index cad74193..90cc426d 100644
--- a/Source/SPUserManager.m
+++ b/Source/SPUserManager.m
@@ -208,9 +208,12 @@
NSManagedObject *parent = [self _createNewSPUser];
NSManagedObject *child = [self _createNewSPUser];
- // We only care about setting the user and password keys on the parent
+ // 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"];
[self _initializeChild:child withItem:item];
@@ -265,6 +268,8 @@
- (void)_initializeSchemaPrivs
{
// Initialize Databases
+ [schemas removeAllObjects];
+
MCPResult *results = [self.mySqlConnection listDBs];
if ([results numOfRows]) {
@@ -328,8 +333,8 @@
// Assumes that the child has already been initialized with values from the
// global user table.
// Select rows from the db table that contains schema privs for each user/host
- NSString *queryString = [NSString stringWithFormat:@"SELECT * from `mysql`.`db` d WHERE d.user = '%@' and d.host = '%@'",
- [[child parent] valueForKey:@"user"], [child valueForKey:@"host"]];
+ NSString *queryString = [NSString stringWithFormat:@"SELECT * from `mysql`.`db` d WHERE d.user = %@ and d.host = %@",
+ [[[child parent] valueForKey:@"user"] tickQuotedString], [[child valueForKey:@"host"] tickQuotedString]];
MCPResult *queryResults = [self.mySqlConnection queryString:queryString];
if ([queryResults numOfRows] > 0)
{
@@ -634,14 +639,21 @@
- (IBAction)removeUser:(id)sender
{
NSString *username = [[[treeController selectedObjects] objectAtIndex:0]
- valueForKey:@"user"];
+ valueForKey:@"originaluser"];
NSArray *children = [[[treeController selectedObjects] objectAtIndex:0]
valueForKey:@"children"];
+
+
+ // On all the children - host entries - set the username to be deleted,
+ // for later query contruction.
for(NSManagedObject *child in children)
{
[child setPrimitiveValue:username forKey:@"user"];
}
+ // Unset the host on the user, so that only the host entries are dropped
+ [[[treeController selectedObjects] objectAtIndex:0] setPrimitiveValue:nil forKey:@"host"];
+
[treeController remove:sender];
}
@@ -748,6 +760,19 @@
[grantedTableView reloadData];
[self _initializeAvailablePrivs];
[treeController fetch:nil];
+
+ // After the reset, ensure all original password and user values are up-to-date.
+ NSEntityDescription *entityDescription = [NSEntityDescription entityForName:@"SPUser"
+ inManagedObjectContext:self.managedObjectContext];
+ NSFetchRequest *request = [[[NSFetchRequest alloc] init] autorelease];
+ [request setEntity:entityDescription];
+ NSArray *userArray = [self.managedObjectContext executeFetchRequest:request error:nil];
+ for (NSManagedObject *user in userArray) {
+ if (![user parent]) {
+ [user setValue:[user valueForKey:@"user"] forKey:@"originaluser"];
+ [user setValue:[user valueForKey:@"password"] forKey:@"originalpassword"];
+ }
+ }
}
- (void)_setSchemaPrivValues:(NSArray *)objects enabled:(BOOL)enabled
@@ -864,6 +889,7 @@
- (void)contextDidSave:(NSNotification *)notification
{
NSManagedObjectContext *notificationContext = (NSManagedObjectContext *)[notification object];
+
// If there are multiple user manager windows open, it's possible to get this
// notification from foreign windows. Ignore those notifications.
if (notificationContext != self.managedObjectContext) return;
@@ -905,22 +931,39 @@
if ([[[user entity] name] isEqualToString:@"Privileges"])
{
[self grantDbPrivilegesWithPrivilege:user];
+
+
+ // If the parent user has changed, either the username or password have been edited.
}
- else if (![user host])
+ else if (![user parent])
{
- // Just the user password was changed.
- // Change password to be the same on all hosts.
NSArray *hosts = [user valueForKey:@"children"];
-
- for(NSManagedObject *child in hosts)
- {
- NSString *changePasswordStatement = [NSString stringWithFormat:
- @"SET PASSWORD FOR %@@%@ = PASSWORD('%@')",
- [[user valueForKey:@"user"] tickQuotedString],
- [[child host] tickQuotedString],
- [user valueForKey:@"password"]];
- [self.mySqlConnection queryString:changePasswordStatement];
- [self checkAndDisplayMySqlError];
+
+ // If the user has been changed, update the username on all hosts. Don't check for errors, as some
+ // hosts may be new.
+ if (![[user valueForKey:@"user"] isEqualToString:[user valueForKey:@"originaluser"]]) {
+ for (NSManagedObject *child in hosts) {
+ NSString *renameUserStatement = [NSString stringWithFormat:
+ @"RENAME USER %@@%@ TO %@@%@",
+ [[user valueForKey:@"originaluser"] tickQuotedString],
+ [[child host] tickQuotedString],
+ [[user valueForKey:@"user"] tickQuotedString],
+ [[child host] tickQuotedString]];
+ [self.mySqlConnection queryString:renameUserStatement];
+ }
+ }
+
+ // If the password has been changed, use the same password on all hosts
+ if (![[user valueForKey:@"password"] isEqualToString:[user valueForKey:@"originalpassword"]]) {
+ for (NSManagedObject *child in hosts) {
+ NSString *changePasswordStatement = [NSString stringWithFormat:
+ @"SET PASSWORD FOR %@@%@ = PASSWORD(%@)",
+ [[user valueForKey:@"user"] tickQuotedString],
+ [[child host] tickQuotedString],
+ [[user valueForKey:@"password"] tickQuotedString]];
+ [self.mySqlConnection queryString:changePasswordStatement];
+ [self checkAndDisplayMySqlError];
+ }
}
} else {
[self grantPrivilegesToUser:user];
@@ -939,8 +982,8 @@
if (![[[user entity] name] isEqualToString:@"Privileges"] && [user valueForKey:@"host"] != nil)
{
[droppedUsers appendString:[NSString stringWithFormat:@"%@@%@, ",
- [[user valueForKey:@"user"] backtickQuotedString],
- [[user valueForKey:@"host"] backtickQuotedString]]];
+ [[user valueForKey:@"user"] tickQuotedString],
+ [[user valueForKey:@"host"] tickQuotedString]]];
}
}
@@ -1025,7 +1068,7 @@
{
NSString *grantStatement = [NSString stringWithFormat:@"GRANT %@ ON %@.* TO %@@%@",
[[grantPrivileges componentsJoinedByCommas] uppercaseString],
- dbName,
+ [dbName backtickQuotedString],
[[schemaPriv valueForKeyPath:@"user.parent.user"] tickQuotedString],
[[schemaPriv valueForKeyPath:@"user.host"] tickQuotedString]];
DLog(@"%@", grantStatement);
@@ -1038,7 +1081,7 @@
{
NSString *revokeStatement = [NSString stringWithFormat:@"REVOKE %@ ON %@.* FROM %@@%@",
[[revokePrivileges componentsJoinedByCommas] uppercaseString],
- dbName,
+ [dbName backtickQuotedString],
[[schemaPriv valueForKeyPath:@"user.parent.user"] tickQuotedString],
[[schemaPriv valueForKeyPath:@"user.host"] tickQuotedString]];
DLog(@"%@", revokeStatement);
@@ -1305,6 +1348,16 @@
}
#pragma mark -
+#pragma mark Tab view delegate methods
+
+- (void)tabView:(NSTabView *)usersTabView willSelectTabViewItem:(NSTabViewItem *)tabViewItem
+{
+ if ([[tabViewItem identifier] isEqualToString:@"Schema Privileges"]) {
+ [self _initializeSchemaPrivs];
+ }
+}
+
+#pragma mark -
/**
* Dealloc. Get rid of everything.
diff --git a/Source/SPUserManager.xcdatamodel/elements b/Source/SPUserManager.xcdatamodel/elements
index 33881efc..22c2c418 100644
--- a/Source/SPUserManager.xcdatamodel/elements
+++ b/Source/SPUserManager.xcdatamodel/elements
Binary files differ
diff --git a/Source/SPUserManager.xcdatamodel/layout b/Source/SPUserManager.xcdatamodel/layout
index 14b1545d..60630b61 100644
--- a/Source/SPUserManager.xcdatamodel/layout
+++ b/Source/SPUserManager.xcdatamodel/layout
Binary files differ
diff --git a/Source/TableContent.m b/Source/TableContent.m
index 4710abef..90fbe5d1 100644
--- a/Source/TableContent.m
+++ b/Source/TableContent.m
@@ -2188,7 +2188,7 @@
} else {
[self performSelector:@selector(showErrorSheetWith:)
withObject:[NSArray arrayWithObjects:NSLocalizedString(@"Error", @"error"),
- [NSString stringWithFormat:NSLocalizedString(@"Couldn't remove rows.\nMySQL said: %@", @"message of panel when field cannot be removed"),
+ [NSString stringWithFormat:NSLocalizedString(@"Couldn't remove rows.\n\nMySQL said: %@", @"message of panel when field cannot be removed"),
[mySQLConnection getLastErrorMessage]],
nil]
afterDelay:0.3];
@@ -2335,7 +2335,8 @@
// Remember affected rows for error checking
affectedRows += [mySQLConnection affectedRows];
}
- errors = [selectedRows count] - affectedRows;
+
+ errors = (affectedRows > 0) ? [selectedRows count] - affectedRows : [selectedRows count];
} else {
// if table has more than one PRIMARY KEY
// delete the row by using all PRIMARY KEYs in an OR clause
@@ -2390,21 +2391,23 @@
// Remember affected rows for error checking
affectedRows += [mySQLConnection affectedRows];
}
- errors = [selectedRows count] - affectedRows;
+
+ errors = (affectedRows > 0) ? [selectedRows count] - affectedRows : [selectedRows count];
}
// Restore Console Log window's updating bahaviour
[[SPQueryController sharedQueryController] setAllowConsoleUpdate:consoleUpdateStatus];
- if ( errors ) {
+ if (errors) {
NSArray *message;
//TODO: The following three messages are NOT localisable!
- if(errors < 0) {
+ if (errors < 0) {
message = [NSArray arrayWithObjects:NSLocalizedString(@"Warning", @"warning"),
[NSString stringWithFormat:NSLocalizedString(@"%ld row%@ more %@ removed! Please check the Console and inform the Sequel Pro team!", @"message of panel when more rows were deleted"), (long)(errors*-1), ((errors*-1)>1)?@"s":@"", (errors>1)?@"were":@"was"],
nil];
- } else {
- if(primaryKeyFieldNames == nil)
+ }
+ else {
+ if (primaryKeyFieldNames == nil)
message = [NSArray arrayWithObjects:NSLocalizedString(@"Warning", @"warning"),
[NSString stringWithFormat:NSLocalizedString(@"%ld row%@ ha%@ not been removed. Reload the table to be sure that the rows exist and use a primary key for your table.", @"message of panel when not all selected fields have been deleted"), (long)errors, (errors>1)?@"s":@"", (errors>1)?@"ve":@"s"],
nil];
@@ -2413,6 +2416,7 @@
[NSString stringWithFormat:NSLocalizedString(@"%ld row%@ ha%@ not been removed. Reload the table to be sure that the rows exist and check the Console for possible errors inside the primary key%@ for your table.", @"message of panel when not all selected fields have been deleted by using primary keys"), (long)errors, (errors>1)?@"s":@"", (errors>1)?@"ve":@"s", (errors>1)?@"s":@""],
nil];
}
+
[self performSelector:@selector(showErrorSheetWith:)
withObject:message
afterDelay:0.3];
diff --git a/Source/TableSource.m b/Source/TableSource.m
index 6ff0d971..1e3bee8f 100644
--- a/Source/TableSource.m
+++ b/Source/TableSource.m
@@ -347,6 +347,10 @@
// Check whether a save of the current row is required.
if (![self saveRowOnDeselect]) return;
+ NSInteger index = [tableSourceView selectedRow];
+
+ if ((index == -1) || (index > ([tableFields count] - 1))) return;
+
// Check if the user tries to delete the last defined field in table
// Note that because of better menu item validation, this check will now never evaluate to true.
if ([tableSourceView numberOfRows] < 2) {
@@ -362,7 +366,7 @@
}
- NSString *field = [[tableFields objectAtIndex:[tableSourceView selectedRow]] objectForKey:@"Field"];
+ NSString *field = [[tableFields objectAtIndex:index] objectForKey:@"Field"];
BOOL hasForeignKey = NO;
NSString *referencedTable = @"";
@@ -409,8 +413,12 @@
// Check whether a save of the current fields row is required.
if (![self saveRowOnDeselect]) return;
- NSString *keyName = [[indexes objectAtIndex:[indexView selectedRow]] objectForKey:@"Key_name"];
- NSString *columnName = [[indexes objectAtIndex:[indexView selectedRow]] objectForKey:@"Column_name"];
+ NSInteger index = [indexView selectedRow];
+
+ if ((index == -1) || (index > ([indexes count] - 1))) return;
+
+ NSString *keyName = [[indexes objectAtIndex:index] objectForKey:@"Key_name"];
+ NSString *columnName = [[indexes objectAtIndex:index] objectForKey:@"Column_name"];
BOOL hasForeignKey = NO;
NSString *constraintName = @"";
'>1621 1622 1623 1624 1625 1626 1627 1628 1629 1630 1631 1632 1633 1634 1635 1636 1637 1638 1639 1640 1641 1642 1643 1644 1645 1646 1647 1648 1649 1650 1651 1652 1653 1654 1655 1656 1657 1658 1659 1660 1661 1662 1663 1664 1665 1666 1667 1668 1669 1670 1671 1672 1673 1674 1675 1676 1677 1678 1679 1680 1681 1682 1683 1684 1685 1686 1687 1688 1689 1690 1691 1692 1693 1694 1695 1696 1697 1698 1699 1700 1701 1702 1703 1704 1705 1706 1707 1708 1709 1710 1711 1712 1713 1714 1715 1716 1717 1718 1719 1720 1721 1722 1723 1724 1725 1726 1727 1728 1729 1730 1731 1732 1733 1734 1735 1736 1737 1738 1739 1740 1741 1742 1743 1744 1745 1746 1747 1748 1749 1750 1751 1752 1753 1754 1755 1756 1757 1758 1759 1760 1761 1762 1763 1764 1765 1766 1767 1768 1769 1770 1771 1772 1773 1774 1775 1776 1777 1778 1779 1780 1781 1782 1783 1784 1785 1786 1787 1788 1789 1790 1791 1792 1793 1794 1795 1796 1797 1798 1799 1800 1801 1802 1803 1804 1805 1806 1807 1808 1809 1810 1811 1812 1813 1814 1815 1816 1817 1818 1819 1820 1821 1822 1823 1824 1825 1826 1827 1828 1829 1830 1831 1832 1833 1834 1835 1836 1837 1838 1839 1840 1841 1842 1843 1844 1845 1846 1847 1848 1849 1850 1851 1852 1853 1854 1855 1856 1857 1858 1859 1860 1861 1862 1863 1864 1865 1866 1867 1868 1869 1870 1871 1872 1873 1874 1875 1876 1877 1878 1879 1880 1881 1882 1883 1884 1885 1886 1887 1888 1889 1890 1891 1892 1893 1894 1895 1896 1897 1898 1899 1900 1901 1902 1903 1904 1905 1906 1907 1908 1909 1910 1911 1912 1913 1914 1915 1916 1917 1918 1919 1920 1921 1922 1923 1924 1925 1926 1927 1928 1929 1930 1931 1932 1933 1934 1935 1936 1937 1938 1939 1940 1941 1942 1943 1944 1945 1946 1947 1948 1949 1950 1951 1952 1953 1954 1955 1956 1957 1958 1959 1960 1961 1962 1963 1964 1965 1966 1967 1968 1969 1970 1971 1972 1973 1974 1975 1976 1977 1978 1979 1980 1981 1982 1983 1984 1985 1986 1987 1988 1989 1990 1991 1992 1993 1994 1995 1996 1997 1998 1999 2000 2001 2002 2003 2004 2005 2006 2007 2008 2009 2010 2011 2012 2013 2014 2015 2016 2017 2018 2019 2020 2021 2022 2023 2024 2025 2026 2027 2028 2029 2030 2031 2032 2033 2034 2035 2036 2037 2038 2039 2040 2041 2042 2043 2044 2045 2046 2047 2048 2049 2050 2051 2052 2053 2054 2055 2056 2057 2058 2059 2060 2061 2062 2063 2064 2065 2066 2067 2068 2069 2070 2071 2072 2073 2074 2075 2076 2077 2078 2079 2080 2081 2082 2083 2084 2085 2086 2087 2088 2089 2090 2091 2092 2093 2094 2095 2096 2097 2098 2099 2100 2101 2102 2103 2104 2105 2106 2107 2108 2109 2110 2111 2112 2113 2114 2115 2116 2117 2118 2119 2120 2121 2122 2123 2124 2125 2126 2127 2128 2129 2130 2131 2132 2133 2134 2135 2136 2137 2138 2139 2140 2141 2142 2143 2144 2145 2146 2147 2148 2149 2150 2151 2152 2153 2154 2155 2156 2157 2158 2159 2160 2161 2162 2163 2164 2165 2166 2167 2168 2169 2170 2171 2172 2173 2174 2175 2176 2177 2178 2179 2180 2181 2182 2183 2184 2185 2186 2187 2188 2189 2190 2191 2192 2193 2194 2195 2196 2197 2198 2199 2200 2201 2202 2203 2204 2205 2206 2207 2208 2209 2210 2211 2212 2213 2214 2215