-
-
Notifications
You must be signed in to change notification settings - Fork 164
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
fix: $model->getChanges()
triggered due to strict comparison
#187
Conversation
@@ -495,6 +495,10 @@ public static function parseDatabase($value) | |||
*/ | |||
public static function serializeDatabase($value) | |||
{ | |||
if ($value instanceof self) { | |||
return $value->value; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is the meat of the change and falls back to $value just in case
use Illuminate\Contracts\Console\Kernel; | ||
use Illuminate\Filesystem\Filesystem; | ||
|
||
class ArtisanCommandsTest extends ApplicationTestCase | ||
{ | ||
/** | ||
* TODO remove once we cut support for Laravel < 5.7 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We dropped < 7
@@ -72,4 +73,21 @@ public function test_model_with_trait_but_no_casts() | |||
$model->foo = true; | |||
$this->assertTrue($model->foo); | |||
} | |||
|
|||
public function test_get_changes_works_correctly() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Tried to repro the test case from #166
@BenSampo Please review this. Laravel's "dirty attribute" logic is currently broken because of this. |
Related Issue/Intent
Resolves #166
Changes
Fixes
getChanges()
being polluted by non changes. Laravel is using strict comparison under the hood, so comparing two different enum instances will return false. Comparing the underlying native types will return true.Breaking changes
None