Skip to content

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

Closed
@farez

Description

@farez

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."

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions