bug-gnustep
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[RFC/PATCH] EOEntity


From: David Ayers
Subject: [RFC/PATCH] EOEntity
Date: Tue, 26 Nov 2002 18:09:50 +0100
User-agent: Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.2b) Gecko/20021016

Hello Everyone,

here is patch for EOEntity to allow programatic entity creation.

- create a mutable _attribute array upon init and setCreateMutableObjects: to yes - remove unnecessary initilaization of setCreateMutableObjects: from initWithPropertyList: - insure message sent by assertion can be recognised by the reciver in primaryKeyAttributes (maybe the assertion output should be changed) - initialize _attributesByName in addAttribute: if needed and add attribute to attributes by name (This might still be incorrect for an Entity that was loaded from a model and some one adds an atribute before any of the existing attributes are accessed and the cache is initialized. I'll be looking into the entire caching mechanism soon trying to simplify/structure it a bit if I can soon.)
- remove attribute from _attributesByName in removeAttribute:


Cheers,
Dave

Index: dev-libs/gdl2/EOAccess/EOEntity.m
===================================================================
RCS file: /cvsroot/gnustep/gnustep/dev-libs/gdl2/EOAccess/EOEntity.m,v
retrieving revision 1.3
diff -u -r1.3 EOEntity.m
--- dev-libs/gdl2/EOAccess/EOEntity.m   26 Nov 2002 09:58:22 -0000      1.3
+++ dev-libs/gdl2/EOAccess/EOEntity.m   26 Nov 2002 16:54:53 -0000
@@ -99,8 +99,6 @@
           NSString *tmpString = nil;
           id tmpObject = nil;
           
-          [self setCreateMutableObjects: YES];
-
           ASSIGN(_name, [propertyList objectForKey: @"name"]);
 
           [self setExternalName: [propertyList objectForKey: @"externalName"]];
@@ -478,6 +476,9 @@
   //OK
   if ((self = [super init]))
     {
+      _attributes = [GCMutableArray new];
+
+      [self setCreateMutableObjects: YES];
     }
 
   return self;
@@ -1055,7 +1056,7 @@
                         @"In entity %@: No attribute named %@ to use for 
locking (attributes: %@)",
                         [self name],
                         attributeName,
-                        [_attributes resultsOfPerformingSelector: 
@selector(name)]);
+                        [[self attributes] resultsOfPerformingSelector: 
@selector(name)]);
 
               if ([self isValidPrimaryKeyAttribute: attribute])
                 [_primaryKeyAttributes addObject: attribute];
@@ -1979,6 +1980,12 @@
     _attributes = [[[_attributes autorelease]
                     arrayByAddingObject: attribute] retain];
 
+  if (_attributesByName==nil)
+    {
+      _attributesByName = [GCMutableDictionary new];
+    }
+  [_attributesByName setObject: attribute forKey: attributeName];
+
   [self _setIsEdited]; //To clean caches
   [attribute setParent: self];
 }
@@ -1999,6 +2006,7 @@
          [(GCMutableArray *)_attributes removeObject: attribute];
          _attributes = [[_attributes autorelease] copy];
         }
+      [_attributesByName removeObjectForKey: [attribute name]];
       [self _setIsEdited];//To clean caches
     }
 }


reply via email to

[Prev in Thread] Current Thread [Next in Thread]