Page MenuHomePhabricator

Implement Database util method for BETWEEN operator
Closed, DeclinedPublicFeature

Description

array( 'colname' => array( 'BETWEEN', array( 1, 5 ) ) )

or

array( 'colname' => array( 'BETWEEN', 1, 5 ) ) maybe?

Would be applicable syntax... Or something. Similar to LEFT JOIN, I suppose

Shouldn't be too difficult, might poke it later...


Version: unspecified
Severity: enhancement

Details

Reference
bz27646

Event Timeline

bzimport raised the priority of this task from to Medium.Nov 21 2014, 11:30 PM
bzimport set Reference to bz27646.
bzimport added a subscriber: Unknown Object (MLST).

We don't have any good support for the more common operators like != < > <= etc... besides inline sql, we should come up with proper support for those before we add BETWEEN.

Also, we can't support those syntaxes. 'colname' => array( [...] ) is already used to create a 'colname IN (...)'.

We'll need to come up with a new way of writing queries.

We could make a "real" query building object:

DBQuery::conds()

->column('colname')->eq($foo)
->column('colname')->in($arr)
->column('colname')->like("{0}%", $foo) // perhaps something better, but I didn't like the idea of a pile more buildLike-like stuff
->column('colname')->between(1,5)
->column('colname')->compare('>=', 3)

Then again, what I really want myself is abstraction that kills the need to depend heavily on database structure.

(In reply to comment #1)

We don't have any good support for the more common operators like != < > <=
etc... besides inline sql, we should come up with proper support for those
before we add BETWEEN.

Maybe that's a different bug to log? ;)

But you're right, it'd be nicer to be able to support the numerous "basic" operations

This comment was removed by Krinkle.
Krinkle renamed this task from Implement Database convie BETWEEN to Implement Database util method for BETWEEN operator.Jul 23 2019, 5:42 PM
Krinkle lowered the priority of this task from Medium to Low.
Krinkle removed a project: Platform Engineering.
Krinkle removed a subscriber: wikibugs-l-list.
Aklapper changed the subtype of this task from "Task" to "Feature Request".Feb 4 2022, 11:00 AM

I'm not convinced we should do this. It made sense when we didn't have a generalized expression builder but turning a between into a chained and condition is a piece of cake now.

I decline this, it's sorta resolved but you can use expression builders. Let's avoid introducing too many features that can overwhelm devs.