LexikFormFilterBundle icon indicating copy to clipboard operation
LexikFormFilterBundle copied to clipboard

Allow filtering on natural keys

Open pbowyer opened this issue 6 years ago • 2 comments

Why?

The bundle assumes that relations are surrogate keys, and they are always of Type::INTEGER.

What?

This change uses class metadata to get the correct type for the identifier. Now keys of Type::STRING (and others) will work.

Notes

This is the result of a morning's debugging, working out why specific filters weren't working. It is submitted for discussion and to see if there's a better approach. It's not yet suitable to merge as there are no tests written.

pbowyer avatar Feb 20 '19 12:02 pbowyer

TBH I can't see how to test this, based on the current tests 😕

pbowyer avatar Apr 17 '19 12:04 pbowyer

An update: we've been using this in production for nearly 3 years and it works great.

If readers want to use the branch, update your composer.json to the following:

{
    "require": {
        "lexik/form-filter-bundle": "dev-natural-keys"
    },
    "repositories": [
        {
            "type": "vcs",
            "url": "https://github.com/pbowyer/LexikFormFilterBundle"
        }
    ],
}

Preferably fork my repository first, so any changes I make you can review first.

pbowyer avatar Mar 07 '22 16:03 pbowyer