Repository navigation
Conversation
Code coverage overviewLanguages: Go Go / code-coverage/gotest
View coverage of the 5 most impacted files.
ℹ️ Calculations represent line coverage. Results may change as calculations are updated. Updated |
| if err != nil { | ||
| return err | ||
| } | ||
| switch d := dest.(type) { |
There was a problem hiding this comment.
With var p *string, row.Scan(&p) succeeds for SQL NULL but returns unsupported Scan for a TEXT BLOB containing "ok". This switch matches *string exactly, so **string falls through and ConvertAssign receives a stdlib.Blob. I reproduced the same failure with rows.Scan(&raw) for sql.RawBytes, with sql.Null[[]byte], and with a defined string type.
|
|
||
| if fd.IsBlob() { | ||
| if src == nil { | ||
| if d, ok := dest.(*io.ReadCloser); ok { |
There was a problem hiding this comment.
Scanning a non-NULL BLOB into var r io.Reader succeeds. Scanning the next NULL into the same &r returns unsupported Scan and leaves the previous BLOB in r. This branch only clears *io.ReadCloser.
| require.NoError(t, err) | ||
| defer closeResource(t, &actual) | ||
| require.Equal(t, int32(1), actual.SubType) | ||
| require.Equal(t, "UTF8", actual.Charset) |
There was a problem hiding this comment.
On Firebird 5.0.4 with encoding=ASCII, this assertion gets "ASCII" in both query execution modes. Firebird reports the result in the connection charset even though the CAST specifies UTF8.
Either open an explicitly UTF8 connection for this test or compare actual.Charset with the result metadata reported on the same connection.
| *d = str | ||
| return nil | ||
| case *[]byte: | ||
| bin, err := blobValue.Bytes() |
There was a problem hiding this comment.
NextRow has already materialized these bytes in r.blobValues[index]. Calling Blob.Bytes() reads the entire buffer again through io.ReadAll. For an 8 MiB value, this path allocated 16.3 MiB across 34 allocations per scan.
The *[]byte case can run before buildBlobValue and return sql.ConvertAssign(scanCtx, dest, r.blobValues[index]). That measured 8.0 MiB across 2 allocations and still gives the caller an independent copy.
| } | ||
| *d = bin | ||
| return nil | ||
| case *sql.NullString, *sql.Null[string]: |
There was a problem hiding this comment.
The *string branch above and this branch both call blobValue.Text() and handle the same error. sql.ConvertAssign also handles *string, so all three destinations can share one case: case *string, *sql.NullString, *sql.Null[string]. Decode once and return sql.ConvertAssign(scanCtx, dest, str).
| }) | ||
| } | ||
|
|
||
| func TestScanBlobIntoNullString(t *testing.T) { |
There was a problem hiding this comment.
The four nullable-string tests starting here each open a database for every query mode. They could share one testWithAllQueryExecModes call with a subtest for each nullable type. Scan 'blob' and then NULL into the same variable in each subtest. That covers both the successful conversion and the clearing of the previous value.
| return err | ||
| } | ||
| switch d := dest.(type) { | ||
| case *string: |
There was a problem hiding this comment.
This case also changes binary BLOB behavior. Scanning CAST(x'FF' AS BLOB SUB_TYPE BINARY) into a string now succeeds and returns a string containing the raw byte 0xff. The base commit returned a conversion error.
Is binary-to-string conversion intended? If so, cover it explicitly. If the change is scoped to TEXT BLOBs, guard the string destinations by BLOB subtype.
No description provided.