worryg0d commented on code in PR #1942:
URL: 
https://github.com/apache/cassandra-gocql-driver/pull/1942#discussion_r3109537715


##########
cluster.go:
##########
@@ -458,6 +465,38 @@ type SchemaListenersConfig struct {
        AggregateChangeListener AggregateChangeListener
 }
 
+// Holds configuration of encoding / decoding behavior of the driver.
+type EncodingConfig struct {
+       // Turns on the encoding nil maps as initialized UDTs for UDTs.
+       // This is a lagacy behavior and it is enabled by default for backward 
compatibility, but it will be disabled in the next major version
+       // If this is enabled, then nil maps will be encoded as an initilizied 
UDT object in which each field is set to NULL.
+       //
+       // For example, there are following UDT and table definitions:
+       //
+       // ```cql
+       // CREATE TYPE my_udt (field_a text, field_b int);
+       // CREATE TABLE my_table (id int PRIMARY KEY, value frozen<my_udt>);
+       // ```
+       //
+       // The following code will insert a UDT object with both fields set to 
NULL:
+       //
+       // ```go
+       // var nilMap map[string]interface{} = nil
+       // session.Query("INSERT INTO my_table (id, value) VALUES (?, ?)", 1, 
nilMap).Exec()
+       // ```
+       //
+       // The table my_table will contain:
+       //
+       // id | value
+       // 1  | {field_a: null, field_b: null}
+       // ---+-------------------------------
+       //
+       // Default: true
+       EncodeNilMapAsInitilizedUDT bool
+       // Supresses the warning that is emitted when 
EncodeNilMapAsInitilizedUDT is enabled.
+       SuppressEncodeNilMapAsInitilizedUDTWarning bool

Review Comment:
   Decoding depends on what is written in the DB:
   
   1. Null value - gocql decodes as nil map
   2. something like this `{street: null, zip: null}` - gocql decodes as udt 
with null values
   
   The behavior is consistent between v1.7 and v2 



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to