cznic / ql

github.com/cznic/ql has moved to modernc.org/ql
https://godoc.org/modernc.org/ql
BSD 3-Clause "New" or "Revised" License
1.31k stars 75 forks source link

Support lt,gt,le,ge,ne,eq operators for blob #180

Closed ghost closed 7 years ago

ghost commented 7 years ago

It utilizes bytes.Compare from the standard library. The operators lt, gt, le and ge are only useful when comparing blobs of the same size, as they will return false otherwise. A use case for this is f.i. when storing IP addresses as blobs, to compare them and/or select ranges.

cznic commented 7 years ago

@metafex Before proceeding I would like to ask if the existing support for this via string(blob1) relop string(blob2) is usable in your use case? Note: The code fragment is QL, not Go.

ghost commented 7 years ago

Theoretically it is usable, but it would need a lot of extra logic as the queries are generated and would need extra type-checking if a parameter is a blob or if the corresponding field is one.

ghost commented 7 years ago

Added a test for various blob sizes and added that strings and blobs can be compared.