Skip to content

fix: nil database/sql arg produces NullType instead of Void#2063

Open
asmyasnikov with Copilot wants to merge 5 commits into
masterfrom
copilot/fix-nil-as-database-sql-arg
Open

fix: nil database/sql arg produces NullType instead of Void#2063
asmyasnikov with Copilot wants to merge 5 commits into
masterfrom
copilot/fix-nil-as-database-sql-arg

Conversation

Copilot AI commented Mar 26, 2026

Copy link
Copy Markdown
Contributor

Passing nil as a database/sql argument was converted to YDB Void, which YDB rejects for optional columns. It should produce NullType instead.

db.ExecContext(ctx, "UPSERT INTO tbl (id, val) VALUES ($id, $val)",
    sql.Named("id", int64(1)),
    sql.Named("val", nil), // was: Void → now: NullType
)

Changes

  • internal/bind/params.go: toValue() nil case now returns value.NullValue(types.Null{}) instead of value.VoidValue()
  • internal/bind/params_test.go: Updated expected value for nil input accordingly
  • tests/integration/database_sql_nil_arg_test.go: Integration test — creates a table with an optional column, upserts a row with nil, reads back and asserts NULL

Warning

Firewall rules blocked me from connecting to one or more addresses (expand for details)

I tried to connect to the following addresses, but was blocked by firewall rules:

  • invalid_host
    • Triggering command: /tmp/go-build246005809/b560/credentials.test /tmp/go-build246005809/b560/credentials.test -test.testlogfile=/tmp/go-build246005809/b560/testlog.txt -test.paniconexit0 -test.timeout=10m0s /tmp/go-build246005809/b440/vet.cfg jKgLs6b-H .cfg x64/pkg/tool/lin-nolocalimports /tmp/ccudQByT.s -c=4 2719715/b128/ x64/pkg/tool/lin/opt/hostedtoolcache/go/1.24.13/x64/src/go/doc/comment.go ctor�� rg/x/net@v0.48.0/internal/timese-p .cfg x64/pkg/tool/linux_amd64/vet --gdwarf-5 ut-1217761693.c -o x64/pkg/tool/lin-buildtags (dns block)

If you need me to access, download, or install something from one of these locations, you can either:

Original prompt

This section details on the original issue you should resolve

<issue_title>bug: nil as database/sql arg transforms to Void, but must be a NullType</issue_title>
<issue_description>```go
result, err := db.ExecQuery(ctx, "INSERT INTO tbl (a, b, c) VALUES ($p1, $p2, $p3)",
sql.Named("p1", 1),
sql.Named("p2", nil), // produced Void
sql.Named("p3", 3),
)

YDB not accepts [Void](https://github.com/ydb-platform/ydb-api-protos/blob/7aa20b63d6cb2bd856ff0562d8b275e65b76f83b/protos/ydb_value.proto#L118) value for insert into Optional column
Special type [NullType](https://github.com/ydb-platform/ydb-api-protos/blob/7aa20b63d6cb2bd856ff0562d8b275e65b76f83b/protos/ydb_value.proto#L119) helps to accept nil from user and apply to YDB on INSERT queries</issue_description>

<agent_instructions>Переделай обработку nil (сейчас Void, должно быть NUllType) в качестве аргументов database/sql
Добавь юнит-тесты и интеграционные тесты (создание таблицы, вставка строки)</agent_instructions>

## Comments on the Issue (you are @copilot in this section)

<comments>
</comments>


🔒 GitHub Advanced Security automatically protects Copilot coding agent pull requests. You can protect all pull requests by enabling Advanced Security for your repositories. Learn more about Advanced Security.

Copilot AI changed the title [WIP] Fix nil as database/sql arg to transform to NullType fix: nil database/sql arg produces NullType instead of Void Mar 26, 2026
Copilot AI requested a review from asmyasnikov March 26, 2026 06:43
@asmyasnikov

Copy link
Copy Markdown
Member

@copilot откати все изменения в go.mod

@github-actions

github-actions Bot commented Mar 26, 2026

Copy link
Copy Markdown

summary

Inferred base version: v3.135.3
Suggested version: v3.135.4

@codecov-commenter

codecov-commenter commented Mar 26, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 46.05%. Comparing base (d892a39) to head (e6b6a23).
⚠️ Report is 32 commits behind head on master.

❗ There is a different number of reports uploaded between BASE (d892a39) and HEAD (e6b6a23). Click for more details.

HEAD has 465 uploads less than BASE
Flag BASE (d892a39) HEAD (e6b6a23)
macOS 21 2
unit 65 6
go-1.26.x 72 3
go-1.21.x 65 3
windows 22 2
ubuntu 94 2
integration 63 0
ydb-24.4 22 0
ydb-latest 21 0
experiment 9 0
ydb-nightly 9 0
ydb-edge 20 0
Additional details and impacted files
@@             Coverage Diff             @@
##           master    #2063       +/-   ##
===========================================
- Coverage   75.05%   46.05%   -29.00%     
===========================================
  Files         427      426        -1     
  Lines       36902    36767      -135     
===========================================
- Hits        27696    16933    -10763     
- Misses       8025    19206    +11181     
+ Partials     1181      628      -553     
Flag Coverage Δ
experiment ?
go-1.21.x 45.99% <100.00%> (-26.58%) ⬇️
go-1.26.x 46.04% <100.00%> (-28.87%) ⬇️
integration ?
macOS 46.04% <100.00%> (-0.03%) ⬇️
ubuntu 46.04% <100.00%> (-29.01%) ⬇️
unit 46.05% <100.00%> (-0.07%) ⬇️
windows 46.03% <100.00%> (-0.05%) ⬇️
ydb-24.4 ?
ydb-edge ?
ydb-latest ?
ydb-nightly ?

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Copilot AI commented Mar 26, 2026

Copy link
Copy Markdown
Contributor Author

@copilot откати все изменения в go.mod

Done in bc1fea8 — reverted examples/go.sum, tests/slo/go.mod, and tests/slo/go.sum back to their original state.

@asmyasnikov
asmyasnikov marked this pull request as ready for review March 26, 2026 07:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

bug: nil as database/sql arg transforms to Void, but must be a NullType

3 participants