From a9eb59bc414ee8546cd4e2d8d454f2de437ffd5b Mon Sep 17 00:00:00 2001 From: Sachin Akash Date: Tue, 17 Dec 2024 10:06:54 +0530 Subject: [PATCH 1/3] Apply suggestions from code review Co-authored-by: Krishnananthalingam Tharmigan <63336800+TharmiganK@users.noreply.github.com> --- docs/proposals/introducing_relaxed_data_binding.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/docs/proposals/introducing_relaxed_data_binding.md b/docs/proposals/introducing_relaxed_data_binding.md index ed791b803..a0f154c9b 100644 --- a/docs/proposals/introducing_relaxed_data_binding.md +++ b/docs/proposals/introducing_relaxed_data_binding.md @@ -1,6 +1,6 @@ # Proposal: Introduce Relaxed Data Binding to Ballerina HTTP Module -_Owners_: @SachinAkash01 +_Owners_: @shafreenAnfar @daneshk @NipunaRanasinghe @lnash94 @TharmiganK @SachinAkash01 _Reviewers_: @lnash94 @TharmiganK @shafreenAnfar _Created_: 2024/11/13 _Updated_: 2024/11/18 @@ -55,9 +55,9 @@ Optional & nullable | T? foo?; | Both nil values and absent fields are allowed | -In the `data.jsondata` package, the `Options` configuration already provides support for handling various field types in JSON data binding, accommodating scenarios with both absent fields and nil values. The `Options` record allows us to adjust how nullability and optionality are treated, making it a versatile solution for managing the differences between required and optional fields, as well as nullable and non-nullable fields. +In the `data.jsondata` package, the `Options` configuration already provides support for handling various field types in JSON data binding, accommodating scenarios with both absent fields and null values. The `Options` record allows us to adjust how nullability and optionality are treated, making it a versatile solution for managing the differences between required and optional fields, as well as nullable and non-nullable fields. -The `Options` record in the data.jsondata module is defined as follows:, +The `Options` record in the `data.jsondata` module is defined as follows:, ```ballerina public type Options record { From aaf71c5b399585499b69b51b06e0ea3c2a542d46 Mon Sep 17 00:00:00 2001 From: Sachin Akash Date: Tue, 17 Dec 2024 10:12:36 +0530 Subject: [PATCH 2/3] Fix formatting issues --- docs/proposals/introducing_relaxed_data_binding.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/docs/proposals/introducing_relaxed_data_binding.md b/docs/proposals/introducing_relaxed_data_binding.md index a0f154c9b..da5bafc4e 100644 --- a/docs/proposals/introducing_relaxed_data_binding.md +++ b/docs/proposals/introducing_relaxed_data_binding.md @@ -82,8 +82,8 @@ The approach involves adding a new field, `laxDataBinding`, to the `CommonClient ```ballerina public type CommonClientConfiguration record {| - boolean laxDataBinding = false; - // Other fields + boolean laxDataBinding = false; + // Other fields |}; ``` @@ -92,7 +92,7 @@ We can configure the relaxed data binding in the service level by improving the ```ballerina public type HttpServiceConfig record {| - boolean laxDataBinding = false; - // Other fields + boolean laxDataBinding = false; + // Other fields |}; ``` From 694329daf7cc4d1d26f9c9bc74b0362717c55520 Mon Sep 17 00:00:00 2001 From: Sachin Akash Date: Tue, 17 Dec 2024 10:14:23 +0530 Subject: [PATCH 3/3] Format table --- .../proposals/introducing_relaxed_data_binding.md | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/docs/proposals/introducing_relaxed_data_binding.md b/docs/proposals/introducing_relaxed_data_binding.md index da5bafc4e..e37bb7850 100644 --- a/docs/proposals/introducing_relaxed_data_binding.md +++ b/docs/proposals/introducing_relaxed_data_binding.md @@ -45,15 +45,12 @@ A more user-friendly solution is to implement relaxed data binding, which would ## Description Following is the breakdown of the cases we need to reconsider within the context of payload data binding: -
-Scenario | Ballerina Representation | Current Behavior | Expected Behavior --- | -- | -- | -- -Required & non-nullable | T foo; | Both null values and absent fields cause runtime failures | Same -Required & nullable | T? foo; | Absent fields will cause runtime failures | Need relaxed data binding to map absent fields as nil values -Optional & non-nullable | T foo?; | Null values will cause runtime failures | Need relaxed data binding to map null values as absent fields -Optional & nullable | T? foo?; | Both nil values and absent fields are allowed | Same - -
+| Scenario | Ballerina Record Field Representation | Default Behavior | Relaxed Behavior | +|-------------------------|---------------------------------------|-----------------------------------------------------------|---------------------------------------------------------------| +| Required & non-nullable | `T foo;` | Both null values and absent fields cause runtime failures | Same | +| Required & nullable | `T? foo;` | Absent fields will cause runtime failures | Need relaxed data binding to map absent fields as nil values | +| Optional & non-nullable | `T foo?;` | Null values will cause runtime failures | Need relaxed data binding to map null values as absent fields | +| Optional & nullable | `T? foo?;` | Both nil values and absent fields are allowed | Same | In the `data.jsondata` package, the `Options` configuration already provides support for handling various field types in JSON data binding, accommodating scenarios with both absent fields and null values. The `Options` record allows us to adjust how nullability and optionality are treated, making it a versatile solution for managing the differences between required and optional fields, as well as nullable and non-nullable fields.