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

[5.6] Handle unquoted JSON selector for MYSQL #24817

Merged
merged 6 commits into from
Jul 12, 2018

Conversation

chrishubert
Copy link
Contributor

@chrishubert chrishubert commented Jul 12, 2018

I propose the wrapper to handle unquoted output (using ->> : reference )
The unquoted result is easier to digest later on.

Originally PaymentMethod::select(['id', 'settings->>name'])->get(); would output

#attributes: array:2 [▼
    "id" => "1"
    "`settings`->'$.">name"'" => null
]

NowPaymentMethod::select(['id', 'settings->>name'])->get(); will output

#attributes: array:2 [▼
    "id" => "1"
    "`settings`->>'$."name"'" => "Bank transfer"
]

I can't see a practical use where we would need quoted output.
Defaulting the wrapper as unquoted using ->>
@chrishubert chrishubert changed the title Return unquoted MYSQL Json Select [5.6] Return unquoted MYSQL Json Select Jul 12, 2018
@chrishubert chrishubert changed the title [5.6] Return unquoted MYSQL Json Select [5.6] Handle unquoted JSON selector for MYSQL Jul 12, 2018
@sisve
Copy link
Contributor

sisve commented Jul 12, 2018

This looks like something that could use a test.

@chrishubert
Copy link
Contributor Author

@sisve - Test added

@chrishubert
Copy link
Contributor Author

It's actually interesting - the function wrapJsonSelector in PostgresGrammar by default return an unquoted version 🤔

@taylorotwell taylorotwell merged commit 21709c9 into laravel:5.6 Jul 12, 2018
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

Successfully merging this pull request may close these issues.

3 participants