Open TWiStErRob opened 1 year ago
I'm trying to call this API via the SDK: https://developers.notion.com/reference/update-property-schema-object#remove-a-property
UpdateDatabaseRequest is the request as far as I can see this doesn't allow for deleting: https://github.com/seratch/notion-sdk-jvm/blob/258488aee4801d85db3b0dc4f36d5257960d698e/core/src/main/kotlin/notion/api/v1/request/databases/UpdateDatabaseRequest.kt#L11
UpdateDatabaseRequest
I tried to cheat the Kotlin type system, but the request sent was properties: {}:
properties: {}
fun NotionClient.removeDatabaseProperty(databaseId: String, propertyName: String) { this.updateDatabase( databaseId = databaseId, properties = @Suppress("UNCHECKED_CAST") (mapOf(propertyName to null) as Map<String, DatabasePropertySchema>) ) }
As far as I see the only option is to properly support this by allowing null:
null
-val properties: Map<String, DatabasePropertySchema>? = null, +val properties: Map<String, DatabasePropertySchema?>? = null,
and also here:
https://github.com/seratch/notion-sdk-jvm/blob/258488aee4801d85db3b0dc4f36d5257960d698e/core/src/main/kotlin/notion/api/v1/endpoint/DatabasesSupport.kt#L69
The SDK will also need to configure Gson to serialize nulls, but only for this specific map type, see for example https://stackoverflow.com/a/60807602/253468 how to create a custom serializer.
Gson
I'm trying to call this API via the SDK: https://developers.notion.com/reference/update-property-schema-object#remove-a-property
UpdateDatabaseRequest
is the request as far as I can see this doesn't allow for deleting: https://github.com/seratch/notion-sdk-jvm/blob/258488aee4801d85db3b0dc4f36d5257960d698e/core/src/main/kotlin/notion/api/v1/request/databases/UpdateDatabaseRequest.kt#L11I tried to cheat the Kotlin type system, but the request sent was
properties: {}
:As far as I see the only option is to properly support this by allowing
null
:and also here:
https://github.com/seratch/notion-sdk-jvm/blob/258488aee4801d85db3b0dc4f36d5257960d698e/core/src/main/kotlin/notion/api/v1/endpoint/DatabasesSupport.kt#L69
The SDK will also need to configure
Gson
to serialize nulls, but only for this specific map type, see for example https://stackoverflow.com/a/60807602/253468 how to create a custom serializer.