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

Case insensitive keys for relation models #22

Open
onmotion opened this issue Nov 29, 2018 · 1 comment
Open

Case insensitive keys for relation models #22

onmotion opened this issue Nov 29, 2018 · 1 comment

Comments

@onmotion
Copy link

What steps will reproduce the problem?

 $dataProvider = new ActiveDataProvider([
            'query' => $query->joinWith(['someCaseInsensitiveRelation']),
        ]);

What is the expected result?

So If I make request without dataProvider, I have got all related models:

2018-11-29_16-44-17

What do you get instead?

but if I using dataProvider related models will be empty

2018-11-29_16-39-51

Additional info

It's happens because model keys case sensitive. For example I using Postgres citext or for MySQL (for utf8) my on condition case insensitive (luke = Luke).

I suggest add optional feature for this. May be useCaseInsensitiveKeys = false or something else? It might looks like:

//vendor/yiisoft/yii2/db/ActiveRelationTrait.php

    private function normalizeModelKey($value)
    {
        if (is_object($value) && method_exists($value, '__toString')) {
            // ensure matching to special objects, which are convertable to string, for cross-DBMS relations, for example: `|MongoId`
            $value = $value->__toString();
        }

        return $this->useCaseInsensitiveKeys ? strtolower($value) : $value;
    }

any suggestions?

Q A
Yii version 2.0.15.1
PHP version 7.0.2
Operating system MacOs 12.4

related to #9077

@samdark samdark transferred this issue from yiisoft/yii2 Dec 1, 2018
@samdark
Copy link
Member

samdark commented Dec 1, 2018

Won't be done in 2.0 but could be considered for 3.0.

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

2 participants