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

Fix incompatible type matching #187

Merged
merged 4 commits into from
Oct 26, 2016

Conversation

romaninsh
Copy link
Member

@romaninsh romaninsh commented Oct 10, 2016

Currently, if the field value is "4" and you change it to 4 (int) then this makes field dirty. To avoid this, hotfix was added: 33377f7

Unfortunately this resulted in some bad side-effects (not found by tests) reported here: #184 (comment)

This PR is properly addressing the issue, by using strict comparison unless we are dealing with stringified numbers. Also it adds several tests, so if there are more test-cases that are affected, then please add.

The original problem was caused because hasOne('blah', ); will use non-integer fields even for persistence SQL where id fields use int() by default. Still, we can't be fully sure about that and without typecasting SQL response comes back as string.

@romaninsh
Copy link
Member Author

I have added some test-script for typecasting of non-string type's "" into null.

The point here is that any non-string type with value of "" is invalid and is probably a null.

@romaninsh
Copy link
Member Author

Those cases seem to be cleaning up after improper use of casting, so technically we could say those are unnecessary, but create a lot of problems around Agile Data.

If those fixes create a problem, please provide examples.

$m['name'] = '4.28';
$this->assertEquals([], $m->dirty);
$m['name'] = '5.28';
$this->assertNotEquals([], $m->dirty);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why name didn't become dirty here ???

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it did, hence the assertNotEquals

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ah sorry :D

@romaninsh romaninsh merged commit fbb59f2 into develop Oct 26, 2016
@romaninsh romaninsh deleted the feature/fix-incompatible-type-matching branch October 26, 2016 08:36
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.

2 participants