Skip to content

Query Builder where clause should support more operators #18

@quangdatv

Description

@quangdatv

As I read from the code, currently, Instream.Query.Builder where clause only supports equal operator. It should support more operators like >, <, >=, <=

One idea is for each {key, value} pair in the where conditions map, the key can be a string with format "field[space]op" whereas op is either ">", "<", ">=" nor "<=". If the key is an atom or op is omitted, we can consider the operator is equal.

For example:

# SELECT * FROM some_measurement WHERE binary = 'foo' AND numeric >= 42 AND location = 'abc'
from("some_measurement")
|> where(%{ binary: "foo", "numeric >=": 42, "location": "abc" })
|> MyApp.MyConnection.query()

Query Builder should also support LIMIT and OFFSET clauses
For example:

# SELECT * FROM some_measurement WHERE binary = 'foo' LIMIT 15 OFFSET 78
from("some_measurement")
|> where(%{ binary: "foo"})
|> limit(15)
|> offset(78)
|> MyApp.MyConnection.query()

If you don't mind, I can create a PR for this

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions