• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag
 

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Derived attribute problem
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Derived attribute problem


  • Subject: Re: Derived attribute problem
  • From: Aaron Rosenzweig <email@hidden>
  • Date: Sun, 23 Mar 2014 00:01:45 -0400

Hi Angelo,

Couple things to try:

1) Remove the single apostrophes surrounding “status” and try again. It is possible that it isn’t parsing properly… don’t column names need to have “double apostrophes” ??? Perhaps MySQL is lax about that but still… Either use no apostrophe or use a “double apostrophe” meaning a single character the shift-apostrophe key. If it is a single apostrophe that is a String in SQL. 

2) Try a different way. Remove all the code you have in the derived part and make this a normal EOAttribute. Put “STATUS” in there by itself. Now go to the “advanced” tab and type what you want in the “Read Format” and check the “read only” box. In the read format you want to use %P for your columnName so you’ll want something like this:

case %P when 0 then 'Active' when 1 then 'Inactive’ end

Honestly, I almost always use the #2 way and never the “derived” way because it is more flexible. I like the idea that I define the column in one box and in another I write something complex but refer to it with %P. 

Try it out and report back.
Aaron Rosenzweig / Chat 'n Bike
e:  email@hidden  t:  (301) 956-2319
Chat 'n Bike Chat 'n Bike

On Mar 22, 2014, at 10:31 PM, Ângelo Andrade Cirino <email@hidden> wrote:

Hi,

I am developing a Wonder D2W application. When I use a class method to display a derived attribute, say a full status or a full name, I am able to correctly display the attribute in a D2W listing for example, but then I lose the listing ability to sort by the derived attribute.

I then created the derived attribute directly in my EOModel, with the same name and no class method for it. For simplicity, take this example. The status attribute is an integer number, a code for the status. 0 represents inactive, 1 active. So I created a derived attribute fullStatus with the following SQL (tested in a MySQL query):

case 'status'
when 0 then 'Active'
when 1 then 'Inactive'
end

This is the error I get when executing the application:

ERROR er.extensions.appserver.ERXApplication  - Exception caught: sqlStringForAttribute: attempt to generate SQL for attribute 'fullStatus' on entity 'Party' with undefined column name. You must define a column name for this attribute before attempting a database operation.

I searched the list and googled for a similar problem but found none. The entity plist part regarding the derived attribute is this:

{
columnName = "fullStatus"; 
definition = "case 'status' when 0 then 'Active' when 1 then 'Inactive' end"; 
isReadOnly = Y; 
name = "fullStatus"; 
prototypeName = varchar16; 
userInfo = {"_EntityModeler" = {generateSource = NO; }; }; 
}, 

It seems a little odd to me, since I did not expect a derived attribute to have a columnName.

With the solution to this problem I intend to learn how to work with derived attributes and confirm if a D2W listing will indeed be able to sort by the derived attribute.

Thanx in advance,

Angelo


PS: by the way, EOModeler seems very unstable. For example, when generating migrations, instead of this

partyTable.addForeignKey("personID", "Person", "id");
it generated this

partyTable.addForeignKey("personID", "${relationship.destination.externalName}", "${join.destinationAttribute.columnName}");

EOModeler will sometimes corrupt the model file in a way that I am forced to delete the entities that I changed prior to saving, then I quit it and start the work all over again.
Do not post admin requests to the list. They will be ignored. Webobjects-dev mailing list (email@hidden) Help/Unsubscribe/Update your Subscription: This email sent to email@hidden
  • Follow-Ups:
    • Re: Derived attribute problem
      • From: Ângelo Andrade Cirino <email@hidden>
References: 
 >Derived attribute problem (From: Ângelo Andrade Cirino <email@hidden>)

  • Prev by Date: Derived attribute problem
  • Next by Date: Re: Derived attribute problem
  • Previous by thread: Derived attribute problem
  • Next by thread: Re: Derived attribute problem
  • Index(es):
    • Date
    • Thread