File tree Expand file tree Collapse file tree 5 files changed +98
-1
lines changed
Expand file tree Collapse file tree 5 files changed +98
-1
lines changed Original file line number Diff line number Diff line change @@ -7,6 +7,7 @@ namespace Notion.Client
77 [ JsonSubtypes . KnownSubTypeAttribute ( typeof ( PageParent ) , ParentType . PageId ) ]
88 [ JsonSubtypes . KnownSubTypeAttribute ( typeof ( WorkspaceParent ) , ParentType . Workspace ) ]
99 [ JsonSubtypes . KnownSubTypeAttribute ( typeof ( BlockParent ) , ParentType . BlockId ) ]
10+ [ JsonSubtypes . KnownSubTypeAttribute ( typeof ( DatabaseParent ) , ParentType . DatabaseId ) ]
1011 public interface IDatabaseParent : IParent
1112 {
1213 }
Original file line number Diff line number Diff line change 22
33namespace Notion . Client
44{
5- public class DatabaseParent : IPageParent , IBlockParent
5+ public class DatabaseParent : IPageParent , IBlockParent , IDatabaseParent
66 {
77 /// <summary>
88 /// The ID of the database that this page belongs to.
Original file line number Diff line number Diff line change @@ -518,4 +518,28 @@ public async Task RetrieveAsync_throws_argument_null_exception_if_database_id_is
518518 var exception = await Assert . ThrowsAsync < ArgumentNullException > ( Act ) ;
519519 Assert . Equal ( "databaseId" , exception . ParamName ) ;
520520 }
521+
522+ [ Fact ]
523+ public async Task RetrieveWikiParentDatabaseAsync ( )
524+ {
525+ var databaseId = "7g82e3a3-2c13-07e8-h7d9-d36cab1fd6f9" ;
526+ var path = ApiEndpoints . DatabasesApiUrls . Retrieve ( databaseId ) ;
527+ var jsonData = await File . ReadAllTextAsync ( "data/databases/WikiParentDatabaseRetrieveResponse.json" ) ;
528+
529+ Server . Given ( CreateGetRequestBuilder ( path ) )
530+ . RespondWith (
531+ Response . Create ( )
532+ . WithStatusCode ( 200 )
533+ . WithBody ( jsonData )
534+ ) ;
535+
536+ var database = await _client . RetrieveAsync ( databaseId ) ;
537+
538+ // Verify that when the parent is a database (such as a Wiki page), parent.type becomes database_id
539+ database . Parent . Type . Should ( ) . Be ( ParentType . DatabaseId ) ;
540+ database . Parent . Should ( ) . BeOfType < DatabaseParent > ( ) ;
541+ ( ( DatabaseParent ) database . Parent ) . DatabaseId . Should ( ) . Be ( "6a82a3a3-9c10-802c-9c8a-de6564be71fm" ) ;
542+ database . Title . Should ( ) . ContainSingle ( ) ;
543+ database . Title [ 0 ] . PlainText . Should ( ) . Be ( "Database within Wiki page" ) ;
544+ }
521545}
Original file line number Diff line number Diff line change 5252 <None Update =" data\databases\UpdateDatabaseResponse.json" >
5353 <CopyToOutputDirectory >Always</CopyToOutputDirectory >
5454 </None >
55+ <None Update =" data\databases\WikiParentDatabaseRetrieveResponse.json" >
56+ <CopyToOutputDirectory >Always</CopyToOutputDirectory >
57+ </None >
5558 <None Update =" data\pages\TrashPageResponse.json" >
5659 <CopyToOutputDirectory >Always</CopyToOutputDirectory >
5760 </None >
Original file line number Diff line number Diff line change 1+ {
2+ "object" : " database" ,
3+ "id" : " 7g82e3a3-2c13-07e8-h7d9-d36cab1fd6f9" ,
4+ "cover" : null ,
5+ "icon" : null ,
6+ "created_time" : " 2025-11-11T09:29:00.000Z" ,
7+ "created_by" : {
8+ "object" : " user" ,
9+ "id" : " 641217ad-5167-4955-a206-f512e67214k7"
10+ },
11+ "last_edited_by" : {
12+ "object" : " user" ,
13+ "id" : " 641217ad-5167-4955-a206-f512e67214k7"
14+ },
15+ "last_edited_time" : " 2025-11-20T02:27:00.000Z" ,
16+ "title" : [
17+ {
18+ "type" : " text" ,
19+ "text" : {
20+ "content" : " Database within Wiki page" ,
21+ "link" : null
22+ },
23+ "annotations" : {
24+ "bold" : false ,
25+ "italic" : false ,
26+ "strikethrough" : false ,
27+ "underline" : false ,
28+ "code" : false ,
29+ "color" : " default"
30+ },
31+ "plain_text" : " Database within Wiki page" ,
32+ "href" : null
33+ }
34+ ],
35+ "description" : [],
36+ "is_inline" : true ,
37+ "properties" : {
38+ "Text" : {
39+ "id" : " N%5EPy" ,
40+ "name" : " Text" ,
41+ "description" : null ,
42+ "type" : " rich_text" ,
43+ "rich_text" : {}
44+ },
45+ "Date" : {
46+ "id" : " %5EE_%5C" ,
47+ "name" : " Date" ,
48+ "description" : null ,
49+ "type" : " date" ,
50+ "date" : {}
51+ },
52+ "Name" : {
53+ "id" : " title" ,
54+ "name" : " Name" ,
55+ "description" : null ,
56+ "type" : " title" ,
57+ "title" : {}
58+ }
59+ },
60+ "parent" : {
61+ "type" : " database_id" ,
62+ "database_id" : " 6a82a3a3-9c10-802c-9c8a-de6564be71fm"
63+ },
64+ "url" : " https://www.notion.so/4f6ff1bac6d9d1a8e0831c93a3e28a2" ,
65+ "public_url" : null ,
66+ "archived" : false ,
67+ "in_trash" : false ,
68+ "request_id" : " f1e6eg7c-8c27-4fc3-fab6-da6f311d1zh9"
69+ }
You can’t perform that action at this time.
0 commit comments