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

Rollup that refers to an empty Select property throws exception during database query #65

Closed
farez opened this issue Jun 24, 2022 · 4 comments · Fixed by #68
Closed
Assignees
Labels
bug Something isn't working
Milestone

Comments

@farez
Copy link
Contributor

farez commented Jun 24, 2022

Describe the bug

When using the Notion::database() method to retrieve pages in a database, a HandlingException is thrown if it encounters a Rollup that refers to a Select, and that Select is empty.

The exception is thrown inside FiveamCode\LaravelNotionApi\Entities\Properties\Select::fillFromRaw(). Exception message:

"The property-type is select, however the raw data-structure does not reprecent this type. Please check the raw response-data."

To Reproduce

Laravel 8.60, OS MacOS 11.6 (Bug Sur), PHP 8.0.14.

  1. Create 2 databases in Notion, DB1 and DB2.
  2. In DB1, create a Select property titled "Select". Enter a couple of options.
  3. In DB2, create a Relation to DB1. Call it "Relation".
  4. In DB2, create a Rollup that uses the relation to DB1, and its Select property. Call it "Rollup".
  5. Create a row in DB1 but leave the Select empty. Title it "A".
  6. Create a row in DB2, Title it "X", and select "A" in its Relation property.

Now use the following code to read the DB2 database:

$notion = new Notion(secret_key);
$results = $notion->database(id_for_DB2)->query();

Expected behavior

All rows from DB2 should be returned in $results. Instead, HandlingException is thrown with the message

"The property-type is select, however the raw data-structure does not reprecent this type. Please check the raw response-data."

@johguentner johguentner added the bug Something isn't working label Jun 27, 2022
@johguentner
Copy link
Member

Hey @farez,
Thank you for all your detailed issue and taking the time to provide all the information needed.
I'll try to reproduce the error and fix it as soon as it's possible.

@johguentner johguentner linked a pull request Jul 9, 2022 that will close this issue
@johguentner
Copy link
Member

Hey @farez,
thank you again for reporting the issue.
The recent PR #68 fixes your issue.

We'll try to push this out asap, however we want to make sure to write some tests for it, before merging.

@johguentner johguentner added this to the v0.8.0 milestone Jul 9, 2022
@farez
Copy link
Contributor Author

farez commented Jul 9, 2022 via email

@johguentner
Copy link
Member

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants