• 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: EOFetchSpecification text to number conversion
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: EOFetchSpecification text to number conversion


  • Subject: Re: EOFetchSpecification text to number conversion
  • From: Lachlan Deck <email@hidden>
  • Date: Tue, 8 Jul 2008 10:09:31 +1000

On 08/07/2008, at 2:55 AM, Chuck Hill wrote:

On Jul 7, 2008, at 7:19 AM, Frédéric JECKER wrote:

I recently changed a table primary key column from NUMBER(6) to NUMBER(12) for a legacy app.
After this change I had a lot of bugs and discovered that search queries where returning zero rows.
In this legacy app, a lot of fetch specifications are written like this :


String pid="806000022"; //for the example, in real life this value is read from a text file.
new EOFetchSpecification("Patient", EOQualifier.qualifierWithQualifierFormat("nip = " + pid, null), null);


With debugging on, this gives the following query which returns 0 rows :
<SELECT (...) FROM Pat_Patient t0 WHERE t0.nip = ?" withBindings: 1:8.06E8(nip)>


Now, when using an Integer instead a String :
String pid=":806000022";
new EOFetchSpecification("Patient", EOQualifier.qualifierWithQualifierFormat("nip = " + Integer.valueOf(pid), null), null);


Gives the following query which returns the awaited rows.
<SELECT (...) FROM Pat_Patient t0 WHERE t0.nip = ?" withBindings: 1:806000022(nip)>


Any idea which could avoid me rewriting the 200+ fetch specifications of this app ?

I can't think of any.

Well, because you didn't tell it what type of value you had it probably tried to convert it to a double of some kind. If you're going to use qualifierFormat, use the symbols provided. i.e., %d
qualifierWithQualifierFormat("nip = %d", new NSArray(pid));


This is yet another reason to never use qualifierWithQualifierFormat. If you had used EOKeyValueQualifier, you would not have this problem.

You probably would in the absence of using Integer.valueOf.

Just say "no" to magic strings.

Yep, what he said.

with regards,
--

Lachlan Deck _______________________________________________
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


References: 
 >EOFetchSpecification text to number conversion (From: Frédéric JECKER <email@hidden>)
 >Re: EOFetchSpecification text to number conversion (From: Chuck Hill <email@hidden>)

  • Prev by Date: Re: [ANN] WO 5.4.2 javadoc tarball
  • Next by Date: Re: WOCollapsibleComponentContent is broken on Leopard
  • Previous by thread: Re: EOFetchSpecification text to number conversion
  • Next by thread: Re: EOFetchSpecification text to number conversion
  • Index(es):
    • Date
    • Thread