Skip to content

Commit 4efd6de

Browse files
author
Justin Dell
committed
Correct endless range example and provide some clarity
Resolves #321
1 parent 3d59910 commit 4efd6de

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

README.adoc

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1069,11 +1069,17 @@ User.where("created_at > :start AND created_at < end", start: 30.days.ago, end:
10691069
User.where(created_at: 30.days.ago..7.days.ago)
10701070
10711071
# bad
1072-
User.where("created_at > ?", 7.days.ago)
1072+
User.where("created_at >= ?", 7.days.ago)
10731073
10741074
# good
10751075
User.where(created_at: 7.days.ago..)
10761076
1077+
# note - ranges are inclusive or exclusive of their ending, not beginning
1078+
User.where(created_at: 7.days.ago..) # produces >=
1079+
User.where(created_at: 7.days.ago...) # also produces >=
1080+
User.where(created_at: ..7.days.ago) # inclusive: produces <=
1081+
User.where(created_at: ...7.days.ago) # exclusive: produces <
1082+
10771083
# okish - there is no range syntax that would denote inclusion on one end and
10781084
# exclusion on another.
10791085
Customer.where("purchases_count > :min AND purchases_count <= :max", min: 0, max: 5)

0 commit comments

Comments
 (0)