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

string.IsNullOrEmpty does not match C# version of string.IsNullOrEmpty for space only strings, MS SQL Server (actually it matches string.IsNulOrWhitespace)) #4138

Open
ldenis2 opened this issue May 23, 2023 · 1 comment · May be fixed by #4177
Assignees
Labels
status: has-pr There is active PR for issue type: bug
Milestone

Comments

@ldenis2
Copy link

ldenis2 commented May 23, 2023

Describe your issue

when you use in a query function like !string.IsNullOrEmpty it is converted to SQL like
SELECT
Count(*)
FROM
[Data$t11] [auto968]
WHERE
NOT ([auto968].[text] IS NULL OR Len([auto968].[text]) = 0)

and according to [https://learn.microsoft.com/en-us/sql/t-sql/functions/len-transact-sql?view=sql-server-ver16] LEN Returns the number of characters of the specified string expression, excluding trailing spaces. It means that string of space characters will not match the predicate. Please use DATALEN or fix it in a different proper way.

Steps to reproduce

GetTable().Where (_=> !string.IsNullOrEmpty(_.text)).Count()

Environment details

Linq To DB version: 4.3.0

Database (with version): SQL Server 2019

ADO.NET Provider (with version): Microsoft.Data.SqlClient 4.1.0

Operating system: Windows 10

.NET Version: net4.8

@ldenis2 ldenis2 changed the title string.IsNullOrEmpty does not match C# version of string.IsNullOrEmpty for MS SQL Server (actually it matches string.IsNulOrWhitespace)) string.IsNullOrEmpty does not match C# version of string.IsNullOrEmpty for space only strings, MS SQL Server (actually it matches string.IsNulOrWhitespace)) May 23, 2023
@MaceWindu MaceWindu added this to the 5.3.0 milestone Jun 24, 2023
@MaceWindu MaceWindu self-assigned this Jun 24, 2023
@MaceWindu
Copy link
Contributor

Sybase legacy (shame!)

@MaceWindu MaceWindu added the status: has-pr There is active PR for issue label Jun 25, 2023
@MaceWindu MaceWindu modified the milestones: 5.3.0, 6.0.0 Jun 26, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status: has-pr There is active PR for issue type: bug
Development

Successfully merging a pull request may close this issue.

2 participants