Bug #83715 | MySQL Connector/NET uses LOCATE instead of LIKE for Contains, StartsWith queries | ||
---|---|---|---|
Submitted: | 7 Nov 2016 8:49 | Modified: | 8 Nov 2016 5:50 |
Reporter: | Sparsh Khandelwal | Email Updates: | |
Status: | Verified | Impact on me: | |
Category: | Connector / NET | Severity: | S3 (Non-critical) |
Version: | 6.9.8, 6.9.9 | OS: | Windows (Windows 8.1) |
Assigned to: | CPU Architecture: | Any | |
Tags: | connector / net, linq |
[7 Nov 2016 8:49]
Sparsh Khandelwal
[7 Nov 2016 11:33]
Chiranjeevi Battula
Hello Sparsh Khandelwal, Thank you for the bug report. I could not repeat the issue at our end using with Visual Studio 2013, Connector/NET 6.9.9 version. Could you please provide repeatable test case (exact steps/sample project, screenshot etc. - please make it as private if you prefer) to confirm this issue at our end? Thanks, Chiranjeevi.
[7 Nov 2016 11:34]
Chiranjeevi Battula
Debug Trace: Opened connection at 11/7/2016 04:16:22 +05:30 SELECT `Extent1`.`id`, `Extent1`.`name` FROM `stoppoints` AS `Extent1` WHERE `Extent1`.`name` LIKE @p__linq__0
[7 Nov 2016 16:04]
Sparsh Khandelwal
Ok. I found the issue. I had an extra check in the query that I removed here for the sake of simplification. This is the linq query that I'm using - _DBContext.Set<Applicant>().Where(x => searchTerm != null ? x.FirstName.Contains(searchTerm.Trim()) : 1 == 1); // Generates LOCATE This query generates LINQ. But, if I remove the additional checks and just write the query like this - _DBContext.Set<Applicant>().Where(x => x.FirstName.Contains(searchTerm.Trim())); Then, it generates LIKE, and not LOCATE.
[8 Nov 2016 5:50]
Chiranjeevi Battula
Hello Sparsh Khandelwal, Thank you for the bug feedback. Verified this behavior on Visual Studio 2013 (C#.Net) and Connector/NET 6.9.9 version. Thanks, Chiranjeevi.
[8 Nov 2016 5:50]
Chiranjeevi Battula
output : Debug Trace: Opened connection at 11/8/2016 11:14:54 +05:30 SELECT `Extent1`.`id`, `Extent1`.`name` FROM `stoppoints` AS `Extent1` WHERE (LOCATE(TRIM(@p__linq__0), `Extent1`.`name`)) = 1