discuss-gnustep
[Top][All Lists]
Advanced

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

GDL2: prototypes and EOAttribute.m


From: Mark Clements
Subject: GDL2: prototypes and EOAttribute.m
Date: Fri, 28 Apr 2017 09:21:52 +0000

I am new to Objective C and GNUstep - and interested in GDL2.

Using https://github.com/gnustep/gdl2 and gcc 4.8.4, I have been working with 
the Trading example with PostgreSQL and ran into a bug: 

Examples/Trading/obj/createTradingDB: Uncaught exception PostgreSQLException, 
reason: SQL expression 'CREATE TABLE TST_CUSTOMER (GRPID (null), NAME 
(null)(30) NOT NULL, PID (null) NOT NULL)' caused ERROR:  syntax error at or 
near "("
LINE 1: CREATE TABLE TST_CUSTOMER (GRPID (null), NAME (null)(30) NOT...
                                         ^
In looking for a bug fix, I was - and am - confused by how prototypes are used 
in EOAttribute.m. The documentation and comments suggest that the getters use 
_prototype, but this is not implemented in code. Moreover, does 
-(void)_updateFromPrototype actually update the values in the EOAttribute 
class? The following patch seems to work for this example - but is it correct?

As a second question: what is a canonical approach for running createTradingDB 
without make install? The incantation I have been using is:

TEST_ADAPTOR=PostgreSQL 
LD_LIBRARY_PATH=EOAccess/obj:EOControl/obj:Examples/Trading/obj:$LD_LIBRARY_PATH
 Examples/Trading/obj/createTradingDB --GNU-Debug=gsdb

Kindly, Mark.


diff --git a/EOAccess/EOAttribute.m b/EOAccess/EOAttribute.m
index df9b36e..58255ea 100644
--- a/EOAccess/EOAttribute.m
+++ b/EOAccess/EOAttribute.m
@@ -511,17 +511,29 @@ static NSArray* staticPrototypeKeys=nil;
  */
 - (int)scale
 {
-  return _scale;
+  if (_scale>0)
+    return _scale;
+  else if (_prototype && [_prototype scale])
+    return [_prototype scale];
+  else return 0;
 }
 
 - (unsigned)precision
 {
-  return _precision;
+  if (_precision>0)
+    return _precision;
+  else if (_prototype && [_prototype precision])
+    return [_prototype precision];
+  else return 0;
 }
 
 - (unsigned)width
 {
-  return _width;
+  if (_width>0)
+    return _width;
+  else if (_prototype && [_prototype width])
+    return [_prototype width];
+  else return 0;
 }
 
 - (id)parent
@@ -636,6 +648,8 @@ static NSArray* staticPrototypeKeys=nil;
     return _valueClassName;
   else if ([self isFlattened])
     return [[_definitionArray realAttribute] valueClassName];
+  else if (_prototype && [_prototype valueClassName])
+    return [_prototype valueClassName];
   else
     return nil;
 }
@@ -656,6 +670,8 @@ static NSArray* staticPrototypeKeys=nil;
     return _externalType;
   else if ([self isFlattened])
     return [[_definitionArray realAttribute] externalType];
+  else if (_prototype && [_prototype externalType])
+    return [_prototype externalType];
   else 
     return nil;
 }




reply via email to

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