lunarphp/lunar

Inconsistent datatype of number product attributes in database

ken717w opened this issue · 0 comments

  • Lunar version: 1.0.0-beta.2
  • Laravel Version: 11.22.0
  • PHP Version: 8.3.11
  • Database Driver & Version: MySQL 8.0.32

Expected Behaviour:

Running SQL query SELECT JSON_EXTRACT(attribute_data, '$.my_number_field') AS my_number_field FROM lunar_products; should show my_number_field in integers.

Actual Behaviour:

For new products which I didn't change any of the attributes the above query gives:

{
	"value": 0,
	"field_type": "Lunar\\FieldTypes\\Number"
}

While if I've changed my_number_field to 1, the query gives:

{
	"value": "1",
	"field_type": "Lunar\\FieldTypes\\Number"
}

If I change it back to 0, the query gives:

{
	"value": "0",
	"field_type": "Lunar\\FieldTypes\\Number"
}

Steps To Reproduce:

  1. Create a product attribute of type Lunar\FieldTypes\Number
  2. Create 2 products, and update this attribute in one of them
  3. Run the SQL query above