Add Between/NotBetween expression helpers#400
Open
sonnemusk wants to merge 1 commit into
Open
Conversation
Add map-style Between and NotBetween Sqlizers that emit `col BETWEEN ? AND ?` / `col NOT BETWEEN ? AND ?` with two bound args per column. Values must be two-element lists or arrays. Also provide Bt as a type alias for Between, as suggested in Masterminds#340.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds first-class
BETWEEN/NOT BETWEENsupport to squirrel's expression helpers, addressing #340.Today the common workaround is:
This PR makes that consistent with
Eq,Lt,Like, and friends:API design
Between/NotBetween:map[string]interface{}, same multi-column AND style asEq/Lt.nilreturn an error.Bt: type alias forBetween(as suggested in the issue).Between{}evaluates to(1=1), matching emptyEq{}.?), so they work withPlaceholderFormat(dollar, colon, etc.).A previous attempt in #180 used an unexported-field struct and was never usable; this follows the established map-based pattern instead.
Tests
Unit coverage in
expr_test.gofor:Between/NotBetween/Bt[]T,[]interface{}, and[2]TboundsSelect(...).Where(...)Related
Closes #340