Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Breaking change in v1.5.1 #330

Closed
Gilthoniel opened this issue Dec 12, 2023 · 5 comments
Closed

Breaking change in v1.5.1 #330

Gilthoniel opened this issue Dec 12, 2023 · 5 comments

Comments

@Gilthoniel
Copy link

Gilthoniel commented Dec 12, 2023

The latest release changes the way arguments are matched which is causing a breaking behavior compared to previous versions.

See #295.

Operating system and Go Version

Ubuntu 22.04 and Go v1.21.1

Issue

Arguments must now always be provided otherwise it does not match anymore.

Reproduction steps

func TestExample(t *testing.T) {
	db, mockDB, err := sqlmock.New()
	require.NoError(t, err)

	mockDB.ExpectExec(`UPDATE "foo" SET "bar" .*`).WillReturnResult(sqlmock.NewResult(0, 1))

	_, err = db.Exec(`UPDATE "foo" SET "bar" = $1`, 42)
	require.NoError(t, err)
}

Expected Result

Instead of introducing a breaking change, the behavior should be enabled explicitly by the developer. Here an error is returned.

Actual Result

It should not return an error.

@IvoGoman
Copy link
Contributor

Opened #329 to make this stricter args checking an opt-in.

@razor-1
Copy link

razor-1 commented Dec 12, 2023

This change should have only been done in a new major version. Definitely not a patch version.

@jcburley
Copy link

jcburley commented Jan 5, 2024

Besides doing this, it might be nice to offer .WithAnyArgs() for cases where no matching is desired but the default is, otherwise, to expect arg-matching to be declared.

@razor-1
Copy link

razor-1 commented Jan 5, 2024

@filikos is this going to be corrected/reverted in some way, or does the community need to create a fork in which patch versions don't incorporate backwards-incompatible changes?

@filikos
Copy link
Collaborator

filikos commented Jan 6, 2024

Breaking change fix was merged #329
Thanks for the efforts @IvoGoman
The breaking change was not intentional and fatigued by the amount of changes that we're pending to be released.
https://github.com/DATA-DOG/go-sqlmock/releases/tag/v1.5.1
Will keep this in mind for upcoming releases.

Release: https://github.com/DATA-DOG/go-sqlmock/releases/tag/v1.5.2

@filikos filikos closed this as completed Jan 6, 2024
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

No branches or pull requests

5 participants