Skip to content

d1: fix RowsAffected() in sql.Result implementation#182

Merged
syumai merged 1 commit intosyumai:mainfrom
b0ch3nski:d1-sql-result
Oct 21, 2025
Merged

d1: fix RowsAffected() in sql.Result implementation#182
syumai merged 1 commit intosyumai:mainfrom
b0ch3nski:d1-sql-result

Conversation

@b0ch3nski
Copy link
Contributor

What

This change fixes RowsAffected() method on sql.Result interface implementation for D1.

Motivation

RowsAffected() function is currently broken because it looks for changes in result before fetching meta first - this results in panic:

panic: syscall/js: call of Value.Int on undefined
goroutine 1 [running]:
syscall/js.Value.float({{}, 0x0, 0x0}, {0x940c0, 0x9})
	syscall/js/js.go:523 +0x10
syscall/js.Value.Int(...)
	syscall/js/js.go:540
github.com/syumai/workers/cloudflare/d1.(*result).RowsAffected(0x9032a0)
github.com/syumai/workers@v0.30.2/cloudflare/d1/result.go:29 +0x7

Docs states how the D1Result looks like.

Signed-off-by: Piotr Bocheński <piotr@bochen.ski>
Copy link
Owner

@syumai syumai left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks! 👍

@syumai syumai merged commit 4a5612f into syumai:main Oct 21, 2025
2 checks passed
@b0ch3nski b0ch3nski deleted the d1-sql-result branch October 21, 2025 06:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants