Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [eclipselink-dev] three-args LOCATE function replacement using STRPOS and SUBSTRING on Postgres

Hi James,

I've attached a patch, with test case too.

https://bugs.eclipse.org/bugs/show_bug.cgi?id=299334

I'm using a similar query (but with POSITION instead) for Symfoware and it passes the tests.

Regards,
Dies


On 12/01/2010 00:54, James Sutherland wrote:
I suppose it doesn't cover the missing case, please log a bug for this for PostgreSQL.


-----Original Message-----
From: Dies Koper [mailto:diesk@xxxxxxxxxxxxxxxxxxx]
Sent: Monday, January 11, 2010 2:37 AM
To: Dev mailing list for Eclipse Persistence Services
Subject: [eclipselink-dev] three-args LOCATE function replacement using STRPOS and SUBSTRING on Postgres

Hi James,

As Symfoware also doesn't have a three-args LOCATE function I considered
doing something equivalent to what you implemented for Postgres:

LOCATE (a, b, i) ->
(STRPOS(SUBSTRING( a FROM i ), b ) + (i - 1))

But doesn't this give a wrong value when a does not include b?

Example:
a = "James"
b = "me"
i = 4

LOCATE (a, b, i) should return 0 as the search starts at 'e' in "James".
(STRPOS(SUBSTRING( a FROM i ), b ) + (i - 1)) would return 0 + (4 - 1) = 3.

So I figured it wouldn't work on Symfoware. Don't you have this issue on
Postgres?

I'm going to try the following on Symfoware, which is similar to what is
discussed on the mailing list:

COALESCE(NULLIF(POSITION(NULLIF(tofind,'') IN SUBSTRING(string_exp FROM
startpos)), 0) - 1 + startpos, 0)

http://www.mail-archive.com/jboss-development@xxxxxxxxxxxxxxxxxxxxx/msg27548.html

Thanks,
Dies



Back to the top