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

43 fix json column double encoding #46

Merged
merged 2 commits into from
Sep 1, 2020

Conversation

hagabaka
Copy link
Contributor

Although with Postgres the current behavior is double-encoding JSON fields, the test case using SQLite will fail with "unable to serialize Closure" instead. Still, the change fixes the issue for both database systems.

Yaohan Chen added 2 commits November 16, 2018 14:32
When a model uses `$casts = ['field' => 'array']` with a JSON field,
getAttributes() will return the JSON-encoded string, while
$model->fill() expects the input to contain the un-encoded JSON value.
So instead, use attributesToArray() to get the model data,
which will work properly with fill().

Fixes mpociot#43
@codecov-io
Copy link

Codecov Report

Merging #46 into master will not change coverage.
The diff coverage is 100%.

Impacted file tree graph

@@            Coverage Diff            @@
##             master      #46   +/-   ##
=========================================
  Coverage     99.13%   99.13%           
  Complexity       45       45           
=========================================
  Files             3        3           
  Lines           115      115           
=========================================
  Hits            114      114           
  Misses            1        1
Impacted Files Coverage Δ Complexity Δ
src/Mpociot/Versionable/VersionableTrait.php 100% <100%> (ø) 31 <0> (ø) ⬇️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 536c732...5d0aa71. Read the comment docs.

@nonoesp nonoesp merged commit 5ebbaba into mpociot:master Sep 1, 2020
@lsmith77
Copy link

lsmith77 commented Sep 22, 2020

just for my understanding .. this fix addresses using during the save process, ie. past stored data might be corrupted?

if that is the case .. has anyone worked on a solution to clean up corrupted data?

@nonoesp
Copy link
Collaborator

nonoesp commented Sep 22, 2020

I think you're right. Haven't tested that.

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.

4 participants