Skip to content

[+] allow RowSet with error with no corresponding row#245

Merged
pashagolub merged 1 commit intopashagolub:masterfrom
theory:fix-one-row-error
Oct 29, 2025
Merged

[+] allow RowSet with error with no corresponding row#245
pashagolub merged 1 commit intopashagolub:masterfrom
theory:fix-one-row-error

Conversation

@theory
Copy link
Contributor

@theory theory commented Oct 27, 2025

Allow a RowSet to be specified with an error row number that has no corresponding row. Since the row returns an error, it seems unnecessary for there to be a row.

In other words, rather than require something like:

NewRows([]string{"id", "title"}).
	AddRow("one").
	RowError(0, fmt.Errorf("error"))

In which both a row and a row error specify index 0, but the row is never returned, allow omission of the row:

NewRows([]string{"id", "title"}).
	RowError(0, fmt.Errorf("error"))

The pattern was broken in d07ccec, which checked only the number of rows before closing a RowSet. Fix by having Next check both the length of rows and whether an error is registered for the current row number. Add a test for this case, as well.

Allow a RowSet to be specified with an error row number that has no
corresponding row. Since the row returns an error, it seems unnecessary
for there to be a row.

In other words, rather than require something like:

	NewRows([]string{"id", "title"}).
		AddRow("one").
		RowError(0, fmt.Errorf("error"))

In which both a row and a row error specify index 0, but the row is
never returned, allow omission of the row:

	NewRows([]string{"id", "title"}).
		RowError(0, fmt.Errorf("error"))

The pattern was broken in d07ccec, which checked only the number of rows
before closing a RowSet. Fix by having `Next` check both the length of
rows and whether an error is registered for the current row number. Add
a test for this case, as well.
@coveralls
Copy link

coveralls commented Oct 27, 2025

Coverage Status

coverage: 94.091% (+0.1%) from 93.977%
when pulling 5ddb2e8 on theory:fix-one-row-error
into 06d530e on pashagolub:master.

@theory theory force-pushed the fix-one-row-error branch from f1efd0d to 5ddb2e8 Compare October 27, 2025 17:55
Copy link
Owner

@pashagolub pashagolub left a comment

Choose a reason for hiding this comment

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

LGTM! Thanks

@pashagolub pashagolub changed the title Allow RowSet with error with no corresponding row [+] allow RowSet with error with no corresponding row Oct 29, 2025
@pashagolub pashagolub merged commit b3d11f5 into pashagolub:master Oct 29, 2025
4 checks passed
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.

3 participants