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

No data displayed when applying an "is null" filter on nullable text columns #381

Closed
Zapolatero opened this issue Feb 21, 2023 · 1 comment

Comments

@Zapolatero
Copy link
Contributor

Describe the bug
When applying the filter "isNull" on a nullable text column, no item is returned.
This issue happens even if, when no filter is applied on this column, items with a null value on this column are displayed.

To Reproduce
This behavior can be reproduced on the autogenerated page on the gridBlazor demo.
Steps to reproduce the behavior:

  1. Go to https://gridblazor.azurewebsites.net/autogeneratedcolumns
  2. Click on the "ship name" column to order the grid by ship name, ascending
  3. Check that the grid contains items with a null ship name
  4. Apply a "is Null" filter on the "ship name" column
  5. See that no item is diplayed on the grid

Expected behavior
When the grid displays data with a null value on a text column, we expect to see data when applying an "is Null" filter on this column.
But the grid is empty when applying such a filter.

Screenshots
Items with null values for the "ship name" column are displayed on the grid
grid_no_filter

When applying an "is null" filter on the same column, no items are shown :
grid_filter

Additional context
This issue originates in the way filters are managed in the DefaultColumnFilter.cs class. When applying an "is null" filter on a text column, the sql generated by the Entity Framework to filter data will be as follows :

SELECT [o].[OrderID], [o].[CustomerID], ...
    FROM [Orders] AS [o]
    WHERE ([o].[ShipRegion] IS NOT NULL) AND UPPER([o].[ShipRegion]) = N''

This filter only returns items whose value for the filtered column is an empty, not null string. This is a problem as we would also like to fecth items with a null string.

In order to return data with a null string and data with an empty string for the filtered column, the where clause should be as follows :

WHERE ([o].[ShipRegion] IS NULL) OR UPPER([o].[ShipRegion]) = N''

Bug fix
I forked this repository and am currently trying to fix the issue. I will issue a pull request as soon as I find a fix.

@Zapolatero
Copy link
Contributor Author

I also found that, when applying a not equals filter on a text column, items who have a null string as a value for the filtered column wont be taken in account and wont be displayed. Even if their value is different to the filter's value, as they are null.

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

No branches or pull requests

1 participant