minwook-shin / notion-database

Python bindings for Notion Database API
https://pypi.org/project/notion-database/
GNU Lesser General Public License v3.0
137 stars 12 forks source link

Bug in Properties class to set_checkbox #8

Closed BMeyn closed 2 years ago

BMeyn commented 2 years ago

Hi,

I think i found a bug in the properties class. I tried to unset the checkbox in one of my notion databases. I alway got a validation erros because the set_checkbox function will always replace the 'False' value with a dict:

example:

PROPERTY = Properties()
ROPERTY.set_checkbox("Checkbox, False)

P = Page(integrations_token=NOTION_KEY)
P.retrieve_page(page_id=page_id)
P.update_page(page_id=page_id, properties=PROPERTY)

This example always resulted in the follwoing errror message:

grafik

I was able to resolve this by changing the default value in the set_checkbox function to 'False'

    def set_checkbox(self, col, text=None):
        """
        checkbox configuration

        :param col: column name
        :param text: page text. If no text is given, for database only.
        :return:
        """
        if not text:
            text = False #! changed this from {} to 'False'
        self.result.update({col: {"checkbox": text}})

I´m not sure If I made somthing wrong or there was a change in the notion API.

minwook-shin commented 2 years ago

hello, @BMeyn

fixed it now. thanks you! Install notion-database==20220628.2 and check the changed version.