SQL generated for Contains may not work as expected
---------------------------------------------------

                 Key: DNET-466
                 URL: http://tracker.firebirdsql.org/browse/DNET-466
             Project: .NET Data provider
          Issue Type: Improvement
          Components: Entity Framework support
    Affects Versions: 2.7.7
         Environment: Firebird 2.5.2
            Reporter: Dave
            Assignee: Jiri Cincura
            Priority: Minor


I have a table :

create table SearchTest ( val varchar(20) );

which has two rows:

insert into SearchTest ( val ) values ('one');
insert into SearchTest ( val ) values ('three');

When I try to select all rows where column 'val' contains either 'one' or 
'hree':

var a = from b in TestEntities.SEARCHTESTs
        from c in new []{ "one", "hree" }
        where b.VAL.Contains(c)
        select b;

I get a query like this:

SELECT
"C"."VAL" AS "VAL"
FROM  "SEARCHTEST" AS "C"
CROSS JOIN  (SELECT
        _UTF8 X'4F4E45' AS "C1"
        FROM  ( SELECT 1 AS X FROM RDB$DATABASE) AS "D"
UNION ALL
        SELECT
        _UTF8 X'48524545' AS "C1"
        FROM  ( SELECT 1 AS X FROM RDB$DATABASE) AS "E") AS "F"
WHERE ((POSITION("F"."C1", "C"."VAL")) > 0)

The result of this query does not include the row containing 'one' because 
"F"."C1" is of type CHAR(4), and cannot match a three character value.

CASTing the literals to VARCHAR results in the expected behavior.

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: 
http://tracker.firebirdsql.org/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

------------------------------------------------------------------------------
Everyone hates slow websites. So do we.
Make your web apps faster with AppDynamics
Download AppDynamics Lite for free today:
http://p.sf.net/sfu/appdyn_d2d_nov
_______________________________________________
Firebird-net-provider mailing list
Firebird-net-provider@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/firebird-net-provider

Reply via email to