Menu

#41 MySQL Adapter should use concat instead of pipes

v2.0_Beta3
open
nobody
Adapters (7)
5
2005-09-26
2005-09-26
No

I am using MySQL.
I have a Domain class contains a string called domain.

The query:

Query q = pm.newQuery(Domain.class);
q.declareParameters("String s");
q.setFilter("s.endsWith(domain) || domain.endsWith
(s)");
Collection results = (Collection) q.execute
("jammconsulting.com");

Returns all of the Domain objects from the database,
not just those that end with jammconsulting.com.

The query generates this SQL:

SELECT THIS.DOMAIN_ID,THIS.`DOMAIN` FROM
`DOMAIN` THIS WHERE ? LIKE '%' || THIS.`DOMAIN`
OR THIS.`DOMAIN` LIKE ?

In MySQL, by default, the || is treated as an OR
condition instead of a concatenation.

Altough the user can set their MySQL database to work
correctly using the --sql-mode option
PIPES_AS_CONCAT, most users will not have that set
and the functionality looks broken.

Discussion


Log in to post a comment.

MongoDB Logo MongoDB