Masterminds / squirrel

Fluent SQL generation for golang
Other
6.88k stars 465 forks source link

Add BETWEEN ? AND ? in Squirrel #284

Closed gustavohmsilva closed 2 years ago

gustavohmsilva commented 3 years ago

Hi all,

Currently, we have been using Expr function to generate a SQL with BETWEEN, or, depending on the circunstances, we've been using a combination of And{} and LtOrEq{} and GtOrEq{} to reproduce the same thing. This is tho somewhat janky as the first is against the idea of Squirrel (minimize SQL written in Go Codebase) and the second, overly complicated.

Would it be worth consideration by the mantainers to develop squirrel.Between{} in Squirrel?

Pawda commented 3 years ago

Hi @gustavohmsilva,

As @lann replied here: #180

You can get the same effect with e.g. sq.Expr("x BETWEEN ? AND ?", low, high)

Works fine, and the other way around too: sq.Expr("? BETWEEN col_min AND col_max", x)

lramosduarte commented 2 years ago

Hi @gustavohmsilva,

As @lann replied here: #180

You can get the same effect with e.g. sq.Expr("x BETWEEN ? AND ?", low, high)

Works fine, and the other way around too: sq.Expr("? BETWEEN col_min AND col_max", x)

It's work for me, and it even work with custom PlaceholderFormat(squirrel.Dollar)