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

Conjunction produces wrong dollar parameter placeholders #301

Closed
strider2038 opened this issue Nov 12, 2021 · 2 comments
Closed

Conjunction produces wrong dollar parameter placeholders #301

strider2038 opened this issue Nov 12, 2021 · 2 comments

Comments

@strider2038
Copy link
Contributor

Alongside with #286 using Or or And affects wrong placeholders.

This test reproduces the problem.

func TestSelectSubqueryInConjunctionPlaceholderNumbering(t *testing.T) {
	subquery := Select("a").Where(Eq{"b": 1}).Prefix("EXISTS(").Suffix(")").PlaceholderFormat(Dollar)

	sql, args, err := Select("*").
		Where(Or{subquery}).
		Where("c = ?", 2).
		PlaceholderFormat(Dollar).
		ToSql()
	assert.NoError(t, err)

	expectedSql := "SELECT * WHERE (EXISTS( SELECT a WHERE b = $1 )) AND c = $2"
	assert.Equal(t, expectedSql, sql)
	assert.Equal(t, []interface{}{1, 2}, args)
}
@strider2038
Copy link
Contributor Author

@lann hello! Fix was merged into the master branch. Can you make a bugfix release?

@lann
Copy link
Member

lann commented Nov 29, 2021

Sure: v1.5.2

@lann lann closed this as completed Nov 29, 2021
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

2 participants