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: aa...@chatnbike.com t: (301) 956-2319 On Mar 22, 2014, at 10:31 PM, Ângelo Andrade Cirino <aacir...@gmail.com> 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 (Webobjects-dev@lists.apple.com) > Help/Unsubscribe/Update your Subscription: > https://lists.apple.com/mailman/options/webobjects-dev/aaron%40chatnbike.com > > This email sent to aa...@chatnbike.com
_______________________________________________ Do not post admin requests to the list. They will be ignored. Webobjects-dev mailing list (Webobjects-dev@lists.apple.com) Help/Unsubscribe/Update your Subscription: https://lists.apple.com/mailman/options/webobjects-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com