notion-dotnet / notion-sdk-net

A Notion SDK for .Net
MIT License
181 stars 44 forks source link

Fix broken database relation request parameters. #404

Open gehongyan opened 9 months ago

gehongyan commented 9 months ago

Description

The database relation request parameters are broken.

In Notion API version 2022-06-28, database relations would have a type of single_property and dual_property.

The type of Relation property of RelationProperty was updated, but that of RelationPropertySchema and RelationUpdatePropertySchema were missed.

Fixes #403

Related Notion changelog: https://developers.notion.com/page/changelog#database-relations-have-a-type-of-single_property-and-dual_property

How Has This Been Tested?

I published the package locally and installed it in my projects. The use case is updated as:

await notionClient.Databases.UpdateAsync(createdDatabase.Id, new DatabasesUpdateParameters
{
    Properties = new Dictionary<string, IUpdatePropertySchema>
    {
        ["Conflicted"] = new RelationUpdatePropertySchema
        {
            Relation = new SinglePropertyRelation()
            {
                SingleProperty = new Dictionary<string, object>(),
                DatabaseId = createdDatabase.Id
            }
        }
    }
});

My code tries to update a database schema to add a new self-referencing column, which works well now.

Type of change

gehongyan commented 9 months ago

By the way, I am not sure why the Notion API still describes the Relation as unchanged.

https://developers.notion.com/reference/property-object#relation

KoditkarVedant commented 9 months ago

@gehongyan Not sure if the document out of sync with changes by Notion. By the way would you be able to add the Integration test for this change? I don't run them as part of workflow but are useful locally to verify.