[ 
https://issues.apache.org/jira/browse/AVRO-3484?focusedWorklogId=760524&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-760524
 ]

ASF GitHub Bot logged work on AVRO-3484:
----------------------------------------

                Author: ASF GitHub Bot
            Created on: 22/Apr/22 00:44
            Start Date: 22/Apr/22 00:44
    Worklog Time Spent: 10m 
      Work Description: jklamer commented on code in PR #1651:
URL: https://github.com/apache/avro/pull/1651#discussion_r855686031


##########
lang/rust/avro_derive/src/lib.rs:
##########
@@ -117,16 +119,24 @@ fn get_data_struct_schema_def(
         syn::Fields::Named(ref a) => {
             for (position, field) in a.named.iter().enumerate() {
                 let name = field.ident.as_ref().unwrap().to_string(); // we 
know everything has a name
-                let field_documented =
+                let field_attrs =
                     
FieldOptions::from_attributes(&field.attrs[..]).map_err(darling_to_syn)?;
-                let doc = preserve_optional(field_documented.doc);
+                let doc = preserve_optional(field_attrs.doc);
+                let default_value = match field_attrs.default {
+                    Some(default_value) => {
+                        quote! {

Review Comment:
   NIT: I would prefer to run `serde_json::from_str(#default_value)` here and 
throw an error if invalid. To avoid runtime errors. 





Issue Time Tracking
-------------------

    Worklog Id:     (was: 760524)
    Time Spent: 40m  (was: 0.5h)

> Rust: Implement derive default via annotation
> ---------------------------------------------
>
>                 Key: AVRO-3484
>                 URL: https://issues.apache.org/jira/browse/AVRO-3484
>             Project: Apache Avro
>          Issue Type: Improvement
>            Reporter: Jack Klamer
>            Assignee: Martin Tzvetanov Grigorov
>            Priority: Major
>              Labels: pull-request-available
>             Fix For: 1.11.1, 1.12.0
>
>          Time Spent: 40m
>  Remaining Estimate: 0h
>
> Origin Comment: https://github.com/apache/avro/pull/1631#discussion_r845826110
> Follow up on the avro derive work. Will want to be able to set the default 
> for a field inside a struct using annotations



--
This message was sent by Atlassian Jira
(v8.20.7#820007)

Reply via email to