Marshal/Unmarshal missing UDT fields as null instead of failing in unsafe mode

We can't return an error in case a field is added to the UDT,
otherwise existing code would break by simply altering the UDT in the
database. For extra fields at the end of the UDT put nulls to be in
line with gocql, but also python-driver and java-driver.

In gocql it was fixed in d2ed1bb74f
This commit is contained in:
Dmitry Kropachev
2024-06-14 11:28:30 -04:00
committed by Sylwia Szunejko
parent c6f942afc7
commit 6a60650668
3 changed files with 341 additions and 15 deletions

View File

@@ -215,6 +215,13 @@ func (q *Queryx) Bind(v ...interface{}) *Queryx {
return q
}
// Scan executes the query, copies the columns of the first selected
// row into the values pointed at by dest and discards the rest. If no rows
// were selected, ErrNotFound is returned.
func (q *Queryx) Scan(v ...interface{}) error {
return q.Query.Scan(udtWrapSlice(q.Mapper, q.unsafe, v)...)
}
// Err returns any binding errors.
func (q *Queryx) Err() error {
return q.err