Skip to content

v0.13.0

Compare
Choose a tag to compare
@lucaong lucaong released this 11 Sep 13:44
· 194 commits to master since this release

Changes:

  • [breaking change] improve select/3 API for min_key/max_key inclusiveness

Details:

The previous API had a few shortcomings:

  • Corner cases when min_key/max_key was set to nil or to tuples like {123, :included} needed special handling and were error prone.

  • Misspelling :included or :excluded in min_key/max_key would silently fail or lead to unexpected results

  • The API was a bit cumbersome in general

The new API introduces a breaking change, but is much clearer, and removes the shortcomings listed above:

# Exclusive ranges:
## Old API:
{:ok, result} = CubDB.select(db,
  min_key: :foo,
  max_key: {:bar, :excluded}
)
## New API:
{:ok, result} = CubDB.select(db,
  min_key: :foo,
  max_key: :bar,
  max_key_inclusive: false
)

# Open-ended ranges:
## Old API:
{:ok, result} = CubDB.select(db,
  min_key: :foo,
  max_key: nil
)
## New API:
{:ok, result} = CubDB.select(db,
  min_key: :foo
)

# Setting min/max key to `nil`:
## Old API:
{:ok, result} = CubDB.select(db,
  min_key: {nil, :included},
  max_key: :bar
)
# New API:
{:ok, result} = CubDB.select(db,
  min_key: nil,
  max_key: :bar
)