Skip to content

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

Merged
thoas merged 1 commit intomasterfrom
fix/panic-if-condition-is-nil
May 18, 2021
Merged

fix: panic if condition is nil on WHERE / AND clauses#117
thoas merged 1 commit intomasterfrom
fix/panic-if-condition-is-nil

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