aboutsummaryrefslogtreecommitdiffstats
path: root/Source/SPUserMO.m
diff options
context:
space:
mode:
authorMax <post@wickenrode.com>2015-11-18 00:14:52 +0100
committerMax <post@wickenrode.com>2015-11-18 00:14:52 +0100
commitdfe9c477aac50a859e283e0eb6316682458e3e39 (patch)
tree400ab62a643c398e752aecf291fdefe1d0a90db0 /Source/SPUserMO.m
parent1f7684a8d075a77914301aea444e2a244347249d (diff)
downloadsequelpro-dfe9c477aac50a859e283e0eb6316682458e3e39.tar.gz
sequelpro-dfe9c477aac50a859e283e0eb6316682458e3e39.tar.bz2
sequelpro-dfe9c477aac50a859e283e0eb6316682458e3e39.zip
* Remove restriction on 16 chars for username in User Manager (#1886)
* Change user manager code so that mysql queries are executed on validation instead of after save (in Core Data, not mysql). This should in general make more sense since a failure in MySQL essentialy means that Core Data can't save it either (but did anyway in the past). * Remove a deprecated method call that is no longer needed in 10.6+
Diffstat (limited to 'Source/SPUserMO.m')
-rw-r--r--Source/SPUserMO.m34
1 files changed, 31 insertions, 3 deletions
diff --git a/Source/SPUserMO.m b/Source/SPUserMO.m
index e9254f7e..e3f6f3bf 100644
--- a/Source/SPUserMO.m
+++ b/Source/SPUserMO.m
@@ -29,13 +29,14 @@
// More info at <https://github.com/sequelpro/sequelpro>
#import "SPUserMO.h"
+#import "SPUserManager.h"
static NSString *SPUserMOParentKey = @"parent";
static NSString *SPUserMOUserKey = @"user";
static NSString *SPUserMOHostKey = @"host";
static NSString *SPUserMOChildrenKey = @"children";
-@implementation NSManagedObject (CoreDataGeneratedAccessors)
+@implementation SPUserMO
@dynamic user;
@dynamic host;
@@ -64,7 +65,7 @@ static NSString *SPUserMOChildrenKey = @"children";
}
}
-- (void)addChildrenObject:(NSManagedObject *)value
+- (void)addChildrenObject:(SPUserMO *)value
{
NSSet *changedObjects = [[NSSet alloc] initWithObjects:&value count:1];
@@ -77,7 +78,7 @@ static NSString *SPUserMOChildrenKey = @"children";
value.user = self.user;
}
-- (void)removeChildrenObject:(NSManagedObject *)value
+- (void)removeChildrenObject:(SPUserMO *)value
{
NSSet *changedObjects = [[NSSet alloc] initWithObjects:&value count:1];
@@ -88,4 +89,31 @@ static NSString *SPUserMOChildrenKey = @"children";
[changedObjects release];
}
+- (BOOL)validateForInsert:(NSError **)error
+{
+ if(![super validateForInsert:error]) return NO;
+
+ SPUserManager *mgr = [self valueForKey:@"userManager"];
+
+ return [mgr insertUser:self];
+}
+
+- (BOOL)validateForDelete:(NSError **)error
+{
+ if(![super validateForDelete:error]) return NO;
+
+ SPUserManager *mgr = [self valueForKey:@"userManager"];
+
+ return [mgr deleteUser:self];
+}
+
+- (BOOL)validateForUpdate:(NSError **)error
+{
+ if(![super validateForUpdate:error]) return NO;
+
+ SPUserManager *mgr = [self valueForKey:@"userManager"];
+
+ return [mgr updateUser:self];
+}
+
@end