db-ojb-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Robert S. Sfeir" <rob...@codepuccino.com>
Subject Postgres escaping issues
Date Sun, 20 Jun 2004 12:17:23 GMT
Been digging some more this AM.  I think this is an issue in Postgres, not
our tests.

The spot of failure is as you now know:

crit.addLike("firstname", "h%\\%");

Which is perfectly valid according to Postgresql documentation, and does not
return an error when used in pgsql.  But... See below.

Here is why I think that it's something funky with Postgresql:

The data I added:
id | lastname |  firstname
----+----------+--------------
  1 | sfeir    | robert
  2 | sfeir    | robert%dude
  3 | sfeir    | robert%dude
  4 | sfeir    | robert%\dude
  5 | sfeir    | robert\dude

>From pgsql, the following commands were run with results:

Replicated test should have selected records 4 & 5
mytest=# select * from person where firstname like 'r%\\%';
 id | lastname | firstname
----+----------+-----------
(0 rows)

Begins with r
mytest=# select * from person where firstname like 'r%';
 id | lastname |  firstname
----+----------+--------------
  1 | sfeir    | robert
  2 | sfeir    | robert%dude
  3 | sfeir    | robert%dude
  4 | sfeir    | robert%\dude
  5 | sfeir    | robert\dude
(5 rows)

Contains r
mytest=# select * from person where firstname like '%r%';
 id | lastname |  firstname
----+----------+--------------
  1 | sfeir    | robert
  2 | sfeir    | robert%dude
  3 | sfeir    | robert%dude
  4 | sfeir    | robert%\dude
  5 | sfeir    | robert\dude
(5 rows)

Begins with r contains t
mytest=# select * from person where firstname like 'r%t%';
 id | lastname |  firstname
----+----------+--------------
  1 | sfeir    | robert
  2 | sfeir    | robert%dude
  3 | sfeir    | robert%dude
  4 | sfeir    | robert%\dude
  5 | sfeir    | robert\dude
(5 rows)

Begins with r contains \ with the escaped \
mytest=# select * from person where firstname like 'r%\\%';
 id | lastname | firstname
----+----------+-----------
(0 rows)

Now the failures...  No wonder test fails on Postgres.

Begins with r contains % then \
mytest=# select * from person where firstname like 'r%\%%\\%';
 id | lastname | firstname
----+----------+-----------
(0 rows)


mytest=# select * from person where firstname like 'r%\%%';
 id | lastname | firstname
----+----------+-----------
(0 rows)

No go on any of them.  I've followed their docs, doesn't work.  I can't say
for 100% certainty that this is not a psql problem, but certainly I would
say it's not a problem with our tests and there is something wrong in
Postgresql.

I'm using Postgresql 7.3.2 on OS X.  When testing using the JDBC 3.0 driver.

I don't think this is reason to hold the release, we should document it
though.

R



---------------------------------------------------------------------
To unsubscribe, e-mail: ojb-dev-unsubscribe@db.apache.org
For additional commands, e-mail: ojb-dev-help@db.apache.org


Mime
View raw message