Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions Src/Notion.Client/Models/Database/IDatabaseParent.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ namespace Notion.Client
[JsonSubtypes.KnownSubTypeAttribute(typeof(PageParent), ParentType.PageId)]
[JsonSubtypes.KnownSubTypeAttribute(typeof(WorkspaceParent), ParentType.Workspace)]
[JsonSubtypes.KnownSubTypeAttribute(typeof(BlockParent), ParentType.BlockId)]
[JsonSubtypes.KnownSubTypeAttribute(typeof(DatabaseParent), ParentType.DatabaseId)]
public interface IDatabaseParent : IParent
{
}
Expand Down
2 changes: 1 addition & 1 deletion Src/Notion.Client/Models/Parents/DatabaseParent.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

namespace Notion.Client
{
public class DatabaseParent : IPageParent, IBlockParent
public class DatabaseParent : IPageParent, IBlockParent, IDatabaseParent
{
/// <summary>
/// The ID of the database that this page belongs to.
Expand Down
24 changes: 24 additions & 0 deletions Test/Notion.UnitTests/DatabasesClientTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -518,4 +518,28 @@ public async Task RetrieveAsync_throws_argument_null_exception_if_database_id_is
var exception = await Assert.ThrowsAsync<ArgumentNullException>(Act);
Assert.Equal("databaseId", exception.ParamName);
}

[Fact]
public async Task RetrieveWikiParentDatabaseAsync()
{
var databaseId = "7g82e3a3-2c13-07e8-h7d9-d36cab1fd6f9";
var path = ApiEndpoints.DatabasesApiUrls.Retrieve(databaseId);
var jsonData = await File.ReadAllTextAsync("data/databases/WikiParentDatabaseRetrieveResponse.json");

Server.Given(CreateGetRequestBuilder(path))
.RespondWith(
Response.Create()
.WithStatusCode(200)
.WithBody(jsonData)
);

var database = await _client.RetrieveAsync(databaseId);

// Verify that when the parent is a database (such as a Wiki page), parent.type becomes database_id
database.Parent.Type.Should().Be(ParentType.DatabaseId);
database.Parent.Should().BeOfType<DatabaseParent>();
((DatabaseParent)database.Parent).DatabaseId.Should().Be("6a82a3a3-9c10-802c-9c8a-de6564be71fm");
database.Title.Should().ContainSingle();
database.Title[0].PlainText.Should().Be("Database within Wiki page");
}
}
3 changes: 3 additions & 0 deletions Test/Notion.UnitTests/Notion.UnitTests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,9 @@
<None Update="data\databases\UpdateDatabaseResponse.json">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Update="data\databases\WikiParentDatabaseRetrieveResponse.json">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Update="data\pages\TrashPageResponse.json">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
{
"object": "database",
"id": "7g82e3a3-2c13-07e8-h7d9-d36cab1fd6f9",
"cover": null,
"icon": null,
"created_time": "2025-11-11T09:29:00.000Z",
"created_by": {
"object": "user",
"id": "641217ad-5167-4955-a206-f512e67214k7"
},
"last_edited_by": {
"object": "user",
"id": "641217ad-5167-4955-a206-f512e67214k7"
},
"last_edited_time": "2025-11-20T02:27:00.000Z",
"title": [
{
"type": "text",
"text": {
"content": "Database within Wiki page",
"link": null
},
"annotations": {
"bold": false,
"italic": false,
"strikethrough": false,
"underline": false,
"code": false,
"color": "default"
},
"plain_text": "Database within Wiki page",
"href": null
}
],
"description": [],
"is_inline": true,
"properties": {
"Text": {
"id": "N%5EPy",
"name": "Text",
"description": null,
"type": "rich_text",
"rich_text": {}
},
"Date": {
"id": "%5EE_%5C",
"name": "Date",
"description": null,
"type": "date",
"date": {}
},
"Name": {
"id": "title",
"name": "Name",
"description": null,
"type": "title",
"title": {}
}
},
"parent": {
"type": "database_id",
"database_id": "6a82a3a3-9c10-802c-9c8a-de6564be71fm"
},
"url": "https://www.notion.so/4f6ff1bac6d9d1a8e0831c93a3e28a2",
"public_url": null,
"archived": false,
"in_trash": false,
"request_id": "f1e6eg7c-8c27-4fc3-fab6-da6f311d1zh9"
}
Loading