User "Brion VIBBER" posted a comment on MediaWiki.r87992.

Full URL: http://www.mediawiki.org/wiki/Special:Code/MediaWiki/87992#c16830
Commit summary:

Support abstraction for 'NOT IN' SQL structure

Following a live discussion with Catrope.

When using Database::makeList() in LIST_AND or LIST_OR modes, you can now
suffix the field name with an exclamation mark.  It will negate the logical
boolean.

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

(note: tests not ran, please run them and ammend them)

Comment:

I'm not sure I'm a fan of this; it's not very clear or obvious syntax, and 
we've already got to deal with using a customized query abstraction layer that 
nobody else in the world uses, based on the completely unlabeled order of 
parameters.

If using suffixes is necessary, I might actually recommend using the full 
operators:

  'some_field IS NOT' => null,
  'some_value !=' => 23,
  'some_ts >=' => $db->timestamp($cutoff),
  'some_ts <' => $db->timestamp($cutoff),


Unfortunately we'd be sticking an operator right next to a '=>' which looks 
funky. :)


_______________________________________________
MediaWiki-CodeReview mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-codereview

Reply via email to