Skip to content

Database query fails when database includes "select" or "multi-select" columns. #41

Closed
@jacob-morin

Description

@jacob-morin

Description

Hi, I've recently encountered an issue where my database queries have started failing for databases including "select" or "multi-select" fields.

Steps to reproduce

  1. Create a notion database that includes a "Select" or "Multi-select" field.
  2. Run database query on the database. e.g $notion->databases()->query('xxxxxxxxxxxxxxxxxxx', $databaseRequest)->getResults();

Expected behavior

A normal response containing my database query results.

Screenshots or output

Here is the error message I receive. If the database contains a "multi-select" field instead, it replaces the field type, but otherwise returns the same error.

development.ERROR: The given property type "select" is unsupported for "value". {"exception":"[object] (Brd6\\NotionSdkPhp\\Exception\\UnsupportedPropertyTypeException(code: 0): The given property type \"select\" is unsupported for \"value\". at /var/www/html/vendor/brd6/notion-sdk-php/src/Resource/Property/Value/AbstractValueProperty.php:68)
[stacktrace]
#0 /var/www/html/vendor/brd6/notion-sdk-php/src/Resource/Property/Value/AbstractValueProperty.php(37): Brd6\\NotionSdkPhp\\Resource\\Property\\Value\\AbstractValueProperty::getMapClassFromType('select')
#1 /var/www/html/vendor/brd6/notion-sdk-php/src/Resource/Property/Value/ArrayValueProperty.php(26): Brd6\\NotionSdkPhp\\Resource\\Property\\Value\\AbstractValueProperty::fromRawData(Array)
#2 [internal function]: Brd6\\NotionSdkPhp\\Resource\\Property\\Value\\ArrayValueProperty->Brd6\\NotionSdkPhp\\Resource\\Property\\Value\\{closure}(Array)
#3 /var/www/html/vendor/brd6/notion-sdk-php/src/Resource/Property/Value/ArrayValueProperty.php(27): array_map(Object(Closure), Array)
#4 /var/www/html/vendor/brd6/notion-sdk-php/src/Resource/Property/Value/AbstractValueProperty.php(44): Brd6\\NotionSdkPhp\\Resource\\Property\\Value\\ArrayValueProperty->initialize()
#5 /var/www/html/vendor/brd6/notion-sdk-php/src/Resource/Page/PropertyValue/RollupPropertyValue.php(22): Brd6\\NotionSdkPhp\\Resource\\Property\\Value\\AbstractValueProperty::fromRawData(Array)
#6 /var/www/html/vendor/brd6/notion-sdk-php/src/Resource/Page/PropertyValue/AbstractPropertyValue.php(43): Brd6\\NotionSdkPhp\\Resource\\Page\\PropertyValue\\RollupPropertyValue->initialize()
#7 /var/www/html/vendor/brd6/notion-sdk-php/src/Resource/Page.php(81): Brd6\\NotionSdkPhp\\Resource\\Page\\PropertyValue\\AbstractPropertyValue::fromRawData(Array)
#8 /var/www/html/vendor/brd6/notion-sdk-php/src/Resource/AbstractResource.php(40): Brd6\\NotionSdkPhp\\Resource\\Page->initialize()
#9 /var/www/html/vendor/brd6/notion-sdk-php/src/Resource/Pagination/PageOrDatabaseResults.php(25): Brd6\\NotionSdkPhp\\Resource\\AbstractResource::fromRawData(Array)
#10 [internal function]: Brd6\\NotionSdkPhp\\Resource\\Pagination\\PageOrDatabaseResults->Brd6\\NotionSdkPhp\\Resource\\Pagination\\{closure}(Array)
#11 /var/www/html/vendor/brd6/notion-sdk-php/src/Resource/Pagination/PageOrDatabaseResults.php(26): array_map(Object(Closure), Array)
#12 /var/www/html/vendor/brd6/notion-sdk-php/src/Resource/Pagination/AbstractPaginationResults.php(43): Brd6\\NotionSdkPhp\\Resource\\Pagination\\PageOrDatabaseResults->initialize()
#13 /var/www/html/vendor/brd6/notion-sdk-php/src/Endpoint/DatabasesEndpoint.php(54): Brd6\\NotionSdkPhp\\Resource\\Pagination\\AbstractPaginationResults::fromRawData(Array)
#14 /var/www/html/app/Commands/NotionClients.php(44): Brd6\\NotionSdkPhp\\Endpoint\\DatabasesEndpoint->query('fb753c69cf9549a...', Object(Brd6\\NotionSdkPhp\\Resource\\Database\\DatabaseRequest))
#15 /var/www/html/vendor/illuminate/container/BoundMethod.php(36): App\\Commands\\NotionClients->handle()
#16 /var/www/html/vendor/illuminate/container/Util.php(40): Illuminate\\Container\\BoundMethod::Illuminate\\Container\\{closure}()
#17 /var/www/html/vendor/illuminate/container/BoundMethod.php(93): Illuminate\\Container\\Util::unwrapIfClosure(Object(Closure))
#18 /var/www/html/vendor/illuminate/container/BoundMethod.php(37): Illuminate\\Container\\BoundMethod::callBoundMethod(Object(LaravelZero\\Framework\\Application), Array, Object(Closure))
#19 /var/www/html/vendor/illuminate/container/Container.php(653): Illuminate\\Container\\BoundMethod::call(Object(LaravelZero\\Framework\\Application), Array, Array, NULL)
#20 /var/www/html/vendor/illuminate/console/Command.php(136): Illuminate\\Container\\Container->call(Array)
#21 /var/www/html/vendor/symfony/console/Command/Command.php(298): Illuminate\\Console\\Command->execute(Object(Symfony\\Component\\Console\\Input\\ArgvInput), Object(Illuminate\\Console\\OutputStyle))
#22 /var/www/html/vendor/illuminate/console/Command.php(121): Symfony\\Component\\Console\\Command\\Command->run(Object(Symfony\\Component\\Console\\Input\\ArgvInput), Object(Illuminate\\Console\\OutputStyle))
#23 /var/www/html/vendor/symfony/console/Application.php(1040): Illuminate\\Console\\Command->run(Object(Symfony\\Component\\Console\\Input\\ArgvInput), Object(Symfony\\Component\\Console\\Output\\ConsoleOutput))
#24 /var/www/html/vendor/symfony/console/Application.php(301): Symfony\\Component\\Console\\Application->doRunCommand(Object(App\\Commands\\NotionClients), Object(Symfony\\Component\\Console\\Input\\ArgvInput), Object(Symfony\\Component\\Console\\Output\\ConsoleOutput))
#25 /var/www/html/vendor/symfony/console/Application.php(171): Symfony\\Component\\Console\\Application->doRun(Object(Symfony\\Component\\Console\\Input\\ArgvInput), Object(Symfony\\Component\\Console\\Output\\ConsoleOutput))
#26 /var/www/html/vendor/illuminate/console/Application.php(94): Symfony\\Component\\Console\\Application->run(Object(Symfony\\Component\\Console\\Input\\ArgvInput), Object(Symfony\\Component\\Console\\Output\\ConsoleOutput))
#27 /var/www/html/vendor/laravel-zero/foundation/src/Illuminate/Foundation/Console/Kernel.php(129): Illuminate\\Console\\Application->run(Object(Symfony\\Component\\Console\\Input\\ArgvInput), Object(Symfony\\Component\\Console\\Output\\ConsoleOutput))
#28 /var/www/html/vendor/laravel-zero/framework/src/Kernel.php(91): Illuminate\\Foundation\\Console\\Kernel->handle(Object(Symfony\\Component\\Console\\Input\\ArgvInput), Object(Symfony\\Component\\Console\\Output\\ConsoleOutput))
#29 /var/www/html/silo(37): LaravelZero\\Framework\\Kernel->handle(Object(Symfony\\Component\\Console\\Input\\ArgvInput), Object(Symfony\\Component\\Console\\Output\\ConsoleOutput))
#30 {main}
"}

   Brd6\NotionSdkPhp\Exception\UnsupportedPropertyTypeException

  The given property type "select" is unsupported for "value".

  at vendor/brd6/notion-sdk-php/src/Resource/Property/Value/AbstractValueProperty.php:68
     64▕         $typeFormatted = StringHelper::snakeCaseToCamelCase($type);
     65▕         $class = "Brd6\\NotionSdkPhp\\Resource\\Property\\Value\\{$typeFormatted}ValueProperty";
     66▕
     67▕         if (!class_exists($class)) {
  ➜  68▕             throw new UnsupportedPropertyTypeException($type, self::PROPERTY_BASE_TYPE);
     69▕         }
     70▕
     71▕         return $class;
     72▕     }

      +2 vendor frames
  3   [internal]:0
      Brd6\NotionSdkPhp\Resource\Property\Value\ArrayValueProperty::Brd6\NotionSdkPhp\Resource\Property\Value\{closure}(["select"])

      +7 vendor frames
  11  [internal]:0
      Brd6\NotionSdkPhp\Resource\Pagination\PageOrDatabaseResults::Brd6\NotionSdkPhp\Resource\Pagination\{closure}()

Environment details

  • version of this package: started with 1.1.8, later upgraded to 1.2.1 to no avail.
  • PHP version: 8.1.27
  • OS: Both Ubuntu 20.04.4 LTS (Focal Fossa) and Debian GNU/Linux 12 (bookworm)

Additional context

These errors seem to have started without any changes to my project. Also, other queries seem to work fine for me as long as they do not include a "select" or "multi-select" field.

Thanks for your time! :)

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions