Issue Details (XML | Word | Printable)

Key: DNET-466
Type: Improvement Improvement
Status: Resolved Resolved
Resolution: Fixed
Priority: Minor Minor
Assignee: Jiri Cincura
Reporter: Dave
Votes: 0
Watchers: 1
Operations

If you were logged in you would be able to see more operations.
.NET Data provider

SQL generated for Contains may not work as expected

Created: 08/Nov/12 09:10 PM   Updated: 18/Aug/13 08:39 AM
Component/s: Entity Framework
Affects Version/s: 2.7.7
Fix Version/s: 3.1.0.0

Environment: Firebird 2.5.2
Issue Links:
Relate
 


 Description  « Hide
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.

 All   Comments   Change History   Subversion Commits      Sort Order: Ascending order - Click to sort in descending order
Jiri Cincura added a comment - 16/Feb/13 10:03 AM
Fixed. String constants are now converted to varchars explicitly.