On 11-08-24 01:17 PM, Ashar Voultoiz wrote:
Hello,
During the Berlin hack-a-ton (which was an awesome event), I have added a quick hack to MediaWiki which is correctly marked as fixme. The revision I am requesting comments for is r87992:
http://www.mediawiki.org/wiki/Special:Code/MediaWiki/87992
Copy pasting the example from the commit message:
Example: $db->makeList( array( 'field!' => array( 1,2,3 ) ); outputs: 'field' NOT IN ('1', '2', '3' );
$db->makeList( array( 'foo!' => array( 777 ) ) ); outputs: 'foo' =! 777
The exclamation mark is an easy mark to have the condition negated.
Brion raised concerns: syntax is not obvious and lacking potentially useful feature. He recommends using full operators:
'some_field IS NOT' => null, 'some_value !=' => 23, 'some_ts >=' => $db->timestamp($cutoff), 'some_ts <' => $db->timestamp($cutoff),
Thus the proposed diff is:
- 'field!'
- 'field !='
I would appreciate if developers can comment on this feature, either on the mailing list or on the revision comment list.
NB: please note the 'field!' feature has been used in the code since there. Might need to have to fix them if we change the code.
IMHO we are deeply in need of a way to abstract operators.
In various places in code we drop down to things like 'column_a>column_b' which is treated as raw sql.
The biggest problem is !=. The != operator is actually a MySQLism and not valid standard SQL. The standard way to do this in SQL is with <>. While some engines like PostgreSQL and Sqlite implement != in addition to <> for compatibility with stuff written for MySQL, there are other DB engines like CUBRID which rightfully consider != to be invalid and break.
Though the idea of supporting 'field op' is an interesting new take on this idea, as long as we make sure that we explicitly say that it's only the operator we support there, not raw sql just being dumped. So that we have a way to support engines that use <>.
~Daniel Friesen (Dantman, Nadir-Seen-Fire) [http://daniel.friesen.name]