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 number field setter #1970

Open
wants to merge 3 commits into
base: 1.x
Choose a base branch
from

Conversation

ken717w
Copy link

@ken717w ken717w commented Sep 26, 2024

Do data type casting from String to either int or float.

This should fixes #1969.

Copy link

vercel bot commented Sep 26, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
lunar-docs ✅ Ready (Inspect) Visit Preview 💬 Add feedback Sep 30, 2024 0:04am

Do data type casting from String to either int or float.
alecritson
alecritson previously approved these changes Sep 30, 2024
@ken717w
Copy link
Author

ken717w commented Sep 30, 2024

The tests failed, are there some sort of linting rules?

@alecritson
Copy link
Collaborator

alecritson commented Sep 30, 2024

The tests failed, are there some sort of linting rules?

Spotted that, pushed a quick patch which should sort it, it was due to $value being an empty string. Although not sure if that will work if you pass a 0 thinking about it 😱

@@ -54,7 +54,7 @@ public function setValue($value)
throw new FieldTypeException(self::class.' value must be numeric.');
}

$this->value = $value;
$this->value = $value ? $value + 0 : '';
Copy link
Contributor

Choose a reason for hiding this comment

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

does returning '' solve the initial issue?

will setting type hint to property/return/argument solve the issue?

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.

Inconsistent datatype of number product attributes in database
3 participants