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

fix: panic if condition is nil on WHERE / AND clauses #117

Merged
merged 1 commit into from
May 18, 2021

Conversation

Houtmann
Copy link

There is a bug when you write a WHERE and or AND clause with the condition nil.
The WHERE clause is not written.

package main

import (
	"fmt"

	"github.com/ulule/loukoum/v3"
	"github.com/ulule/loukoum/v3/stmt"
)

func main() {
	var cursorcond stmt.Expression
	q, args :=
		loukoum.Select("col").
			From("table").
			Where(loukoum.Condition("col").Equal("value")).
			And(cursorcond).
			OrderBy(loukoum.Order("col")).
			Limit(1).
			Query()
	fmt.Println(q, args)
}

SELECT "col" FROM "table" ORDER BY col ASC LIMIT 1 []

@Houtmann Houtmann requested review from thoas and yansal May 18, 2021 13:08
@thoas thoas merged commit c7aafb4 into master May 18, 2021
@thoas thoas deleted the fix/panic-if-condition-is-nil branch May 18, 2021 13:50
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