discuss-gnustep
[Top][All Lists]
Advanced

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

Re: GDL2: prototypes and EOAttribute.m


From: Matt Rice
Subject: Re: GDL2: prototypes and EOAttribute.m
Date: Fri, 28 Apr 2017 04:00:43 -0700

On Fri, Apr 28, 2017 at 2:21 AM, Mark Clements <mark.clements@ki.se> wrote:
> 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?

Hi Mark,

It has been a fairly long time since i've much looked at the GDL2 code base,
So i am probably not going to be of much help, in the correctness
however _updateFromPrototype does at least _attempt_ to update the values.

EOAttribute.m:2281 [self takeValuesFromDictionary:notOverridenKV];

This should result in the various -[EOAttribute set*:]  methods being
called (eventually after routing through the Key Value Coding
mechanism.

It however wouldn't surprise me if this were broken, GDL2 was somewhat
reliant on an older version of KVC, and there has been various API
churn in this regard that came from Apple...

> 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.

This in particular is a very hairy subject, due to GDL2's reliance on
bundle loading etc,
Do you have the GDL2 adaptors installed in the framework in gnusteps
root somewhere? (Otherwise I would be surprised if this worked due to
the way adaptors are located),

If so, take care to check if you are using GDL2 libraries from one
compile, (in the local directory via LD_LIBRARY_PATH), and adaptors
from another (In the frameworks/ directory)

I would recommend putting the glibc (assuming glibc?) LD_DEBUG="files"
environment variable, to check and make sure that you are not mixing
libraries from various compiles

IMO this is quite unfortunate,

There is also this repository here containing the testsuite.

http://svn.gna.org/viewcvs/gnustep/tests/testsuite/trunk/gdl2/

Overall, i'm not sure about the patch (It sounds like this should be
happening in the takeValue* call discussed above, rather than the
getter, and that something has gone awry there).

Hope this helps.



> 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;
>  }
>
>
> _______________________________________________
> Discuss-gnustep mailing list
> Discuss-gnustep@gnu.org
> https://lists.gnu.org/mailman/listinfo/discuss-gnustep



reply via email to

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