Skip to content

Add table column filter support for JSON type#1747

Merged
mvorisek merged 5 commits intodevelopfrom
feature/fix-table-filters
Aug 30, 2022
Merged

Add table column filter support for JSON type#1747
mvorisek merged 5 commits intodevelopfrom
feature/fix-table-filters

Conversation

@DarkSide666
Copy link
Copy Markdown
Member

@DarkSide666 DarkSide666 commented Mar 4, 2022

fix #1744
fix #1746

@DarkSide666 DarkSide666 requested review from ibelar and mvorisek March 4, 2022 12:26
Types::DATETIME_MUTABLE => FilterModel\TypeDatetime::class,
Types::DATETIME_IMMUTABLE => FilterModel\TypeDatetime::class,

Types::JSON => FilterModel\TypeString::class,
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These types are casted to non-string in PHP, the php values are never used in these filters?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes it looks like that. For example, type=json field shows as text in grid column and looks like filter works on top of it.
Probably @ibelar could check this in more details too.
Of course, filtering as string will not be the best option, but at least it will not throw exception then and at least partly work as filter.

Copy link
Copy Markdown
Member

@mvorisek mvorisek Mar 5, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I also wonder if such filtering is even cross-DB compatible when the DB column type is native like JSON.

If it is, then maybe we can add FilterModel\TypeString::class as a fallback for any unspecified type

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If not compatible with all DB engines, then maybe we can somehow not add filter on these columns at all (automatically)?
What I don't like there is that ugly exception we get if json column is added in Grid with filters.

@DarkSide666 DarkSide666 requested a review from mvorisek March 4, 2022 18:34
@mvorisek mvorisek removed their request for review April 22, 2022 16:45
@mvorisek mvorisek force-pushed the feature/fix-table-filters branch from e432443 to 8734db9 Compare August 28, 2022 16:20
@mvorisek mvorisek removed request for ibelar and mvorisek August 28, 2022 18:23
@mvorisek mvorisek changed the title Feature/fix table filters Add table column filter support for JSON type Aug 28, 2022
Copy link
Copy Markdown
Member

@mvorisek mvorisek left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, waiting for a green CI

Copy link
Copy Markdown
Member

@mvorisek mvorisek left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

image

for some reasons, Behat /w Coverage does not pass, it seems unrelated, but better to fix it first

@mvorisek mvorisek merged commit 1aab74b into develop Aug 30, 2022
@mvorisek mvorisek deleted the feature/fix-table-filters branch August 30, 2022 10:57
@mvorisek
Copy link
Copy Markdown
Member

Thank you!

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

Labels

None yet

Development

Successfully merging this pull request may close these issues.

Table\Column\FilterModel do not support "Is Not" for string columns Table\Column\FilterModel throws error on json type fields

2 participants