Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SQL generated for Contains may not work as expected [DNET466] #457

Closed
firebird-automations opened this issue Nov 8, 2012 · 4 comments
Closed

Comments

@firebird-automations
Copy link

Submitted by: Dave (davek)

Relate to DNET513

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.

Commits: 30d4902

@firebird-automations
Copy link
Author

Modified by: @cincuranet

status: Open [ 1 ] => In Progress [ 3 ]

@firebird-automations
Copy link
Author

Commented by: @cincuranet

Fixed. String constants are now converted to varchars explicitly.

@firebird-automations
Copy link
Author

Modified by: @cincuranet

status: In Progress [ 3 ] => Resolved [ 5 ]

resolution: Fixed [ 1 ]

Fix Version: vNext [ 10491 ]

@firebird-automations
Copy link
Author

Modified by: @cincuranet

Link: This issue relate to DNET513 [ DNET513 ]

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants