brd6/notion-sdk-php

Why does getNumber() cast to an int?

chrisfromredfin opened this issue · 4 comments

Description

When setting data in Notion in a number field, I'm setting values like 13.75 and 4.25. When I look at the getProperties() in the debugger and see raw data I see my decimal value. But when I then call getNumber() it's casting to an int everywhere.

Steps to reproduce

  1. Create a Notion DB with a number column.
  2. Set a value in the number column that has a decimal.
  3. call ->getProperties() on the row.
  4. call ->getNumber() on the $properties['My number'] it seems to floor() the number.

Expected behavior

I would expect the value as a decimal.

Screenshots or output

https://github.com/brd6/notion-sdk-php/blob/main/src/Resource/Property/Value/NumberValueProperty.php

Environment details

PHP 8.1 in DDEV.

Thanks for reporting this! I'll add a fix for the decimal handling.

(FWIW we just changed the casting-to-int to casting-to-float and that seems to work.)

brd6 commented

Fixed!