Skip to content

Commit c39b0e7

Browse files
Merge pull request #228 from Titaye/fix/database_id_typo
Fix wrong field used in relation field 🔨
2 parents 6f81e40 + 8ab6edd commit c39b0e7

File tree

4 files changed

+123
-1
lines changed

4 files changed

+123
-1
lines changed

Src/Notion.Client/Models/Database/Properties/RelationProperty.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ public class RelationProperty : Property
1313

1414
public class Relation
1515
{
16-
[JsonProperty("datebase_id")]
16+
[JsonProperty("database_id")]
1717
public string DatabaseId { get; set; }
1818

1919
[JsonProperty("synced_property_name")]

Test/Notion.UnitTests/DatabasesClientTests.cs

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -146,6 +146,36 @@ public async Task DatabasePropertyObjectContainNameProperty()
146146
}
147147
}
148148

149+
[Fact]
150+
public async Task DatabasePropertyObjectContainRelationProperty()
151+
{
152+
var databaseId = "f0212efc-caf6-4afc-87f6-1c06f1dfc8a1";
153+
var path = ApiEndpoints.DatabasesApiUrls.Retrieve(databaseId);
154+
var jsonData = await File.ReadAllTextAsync("data/databases/DatabasePropertyObjectContainRelation.json");
155+
156+
Server.Given(CreateGetRequestBuilder(path))
157+
.RespondWith(
158+
Response.Create()
159+
.WithStatusCode(200)
160+
.WithBody(jsonData)
161+
);
162+
163+
var database = await _client.RetrieveAsync(databaseId);
164+
165+
database.Properties.Should().ContainKey("Property").WhichValue.Should().BeEquivalentTo(
166+
new RelationProperty()
167+
{
168+
Id = "zDGa",
169+
Name = "Property",
170+
Relation = new Relation()
171+
{
172+
DatabaseId = "f86f2262-0751-40f2-8f63-e3f7a3c39fcb",
173+
SyncedPropertyName = "Related to sample table (Property)",
174+
SyncedPropertyId = "VQ}{"
175+
}
176+
});
177+
}
178+
149179
[Fact]
150180
public async Task DatabasePropertyObjectContainParentProperty()
151181
{

Test/Notion.UnitTests/Notion.UnitTests.csproj

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,9 @@
9393
<None Update="data\databases\FormulaPropertyCanBeSetWhenCreatingDatabaseResponse.json">
9494
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
9595
</None>
96+
<None Update="data\databases\DatabasePropertyObjectContainRelation.json">
97+
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
98+
</None>
9699
</ItemGroup>
97100

98101
</Project>
Lines changed: 89 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,89 @@
1+
{
2+
"object": "database",
3+
"id": "f0212efc-caf6-4afc-87f6-1c06f1dfc8a1",
4+
"created_time": "2021-05-22T18:44:00.000Z",
5+
"last_edited_time": "2021-05-23T12:29:00.000Z",
6+
"title": [
7+
{
8+
"type": "text",
9+
"text": {
10+
"content": "sample table",
11+
"link": null
12+
},
13+
"annotations": {
14+
"bold": false,
15+
"italic": false,
16+
"strikethrough": false,
17+
"underline": false,
18+
"code": false,
19+
"color": "default"
20+
},
21+
"plain_text": "sample table",
22+
"href": null
23+
}
24+
],
25+
"properties": {
26+
"Tags": {
27+
"id": "YG~h",
28+
"name": "Tags",
29+
"type": "multi_select",
30+
"multi_select": {
31+
"options": []
32+
}
33+
},
34+
"SimpleText": {
35+
"id": "_Dfp",
36+
"name": "SimpleText",
37+
"type": "rich_text",
38+
"rich_text": {}
39+
},
40+
"Column": {
41+
"id": "bxhl",
42+
"name": "Column",
43+
"type": "multi_select",
44+
"multi_select": {
45+
"options": [
46+
{
47+
"id": "5a44a233-33be-435e-b358-2c0ed1799dcf",
48+
"name": "what",
49+
"color": "gray"
50+
}
51+
]
52+
}
53+
},
54+
"SelectProp": {
55+
"id": "eZ[y",
56+
"name": "SelectProp",
57+
"type": "select",
58+
"select": {
59+
"options": [
60+
{
61+
"id": "362dc255-c867-4543-b3ea-7bd988638228",
62+
"name": "Female",
63+
"color": "green"
64+
}
65+
]
66+
}
67+
},
68+
"Property": {
69+
"id": "zDGa",
70+
"name": "Property",
71+
"type": "relation",
72+
"relation": {
73+
"database_id": "f86f2262-0751-40f2-8f63-e3f7a3c39fcb",
74+
"synced_property_name": "Related to sample table (Property)",
75+
"synced_property_id": "VQ}{"
76+
}
77+
},
78+
"Name": {
79+
"id": "title",
80+
"name": "Name",
81+
"type": "title",
82+
"title": {}
83+
}
84+
},
85+
"parent": {
86+
"type": "page_id",
87+
"page_id": "649089db-8984-4051-98fb-a03593b852d8"
88+
}
89+
}

0 commit comments

Comments
 (0)