r66075 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r66074‎ | r66075 | r66076 >
Date:19:24, 8 May 2010
Author:jeroendedauw
Status:deferred
Tags:
Comment:
Replaced SQL where contition hook by a method in SMWDescription
Modified paths:
  • /trunk/extensions/SemanticMediaWiki/includes/storage/SMW_Description.php (modified) (history)
  • /trunk/extensions/SemanticMediaWiki/includes/storage/SMW_SQLStore2_Queries.php (modified) (history)

Diff [purge]

Index: trunk/extensions/SemanticMediaWiki/includes/storage/SMW_Description.php
@@ -142,6 +142,18 @@
143143 }
144144 }
145145
 146+ /**
 147+ * TODO
 148+ *
 149+ * @param string $tableName
 150+ * @param array $fieldNames
 151+ * @param DatabaseBase $dbs
 152+ *
 153+ * @return false
 154+ */
 155+ public function getSQLCondition( $tableName, array $fieldNames, DatabaseBase $dbs ) {
 156+ return false;
 157+ }
146158 }
147159
148160 /**
Index: trunk/extensions/SemanticMediaWiki/includes/storage/SMW_SQLStore2_Queries.php
@@ -629,23 +629,32 @@
630630
631631 // Do not support smw_id joined data for now.
632632 if ( $fieldNames && !$smwidjoinfield ) {
633 - $comp = '';
 633+ $comparator = false;
 634+ $customSQL = false;
634635
635 - // TODO: refactor this hook away by using a method in the description classes
636 -
637636 switch ( $description->getComparator() ) {
638 - case SMW_CMP_EQ: $comp = '='; break;
639 - case SMW_CMP_LEQ: $comp = '<='; break;
640 - case SMW_CMP_GEQ: $comp = '>='; break;
641 - case SMW_CMP_NEQ: $comp = '!='; break;
 637+ case SMW_CMP_EQ: $comparator = '='; break;
 638+ case SMW_CMP_LEQ: $comparator = '<='; break;
 639+ case SMW_CMP_GEQ: $comparator = '>='; break;
 640+ case SMW_CMP_NEQ: $comparator = '!='; break;
642641 }
643642
644 - wfRunHooks( 'smwGetSQLConditionForValue', array( &$where, $description, $query->alias, $fieldNames, $this->m_dbs ) );
645 -
646 - if ( $where == '' ) {
647 - $value = $keys[$valueIndexes[0]]; // TODO //.//
648 - $where = "{$query->alias}.{$fieldNames[0]}{$comp}" . $this->m_dbs->addQuotes( $value );
649 - }
 643+ if ( !$comparator ) {
 644+ $customSQL = $description->getSQLCondition( $query->alias, $fieldNames, $this->m_dbs );
 645+ }
 646+
 647+ if ( $customSQL ) {
 648+ $where = $customSQL;
 649+ }
 650+ else {
 651+ $contitions = array();
 652+
 653+ for( $i = 0, $n = count( $fieldNames ); $i < $n; $i++ ) {
 654+ $contitions[] = "$query->alias.{$fieldNames[$i]}{$comparator}" . $this->m_dbs->addQuotes( $keys[$valueIndexes[$i]] );
 655+ }
 656+
 657+ $where = implode( ' && ', $contitions );
 658+ }
650659 }
651660 }
652661

Follow-up revisions

RevisionCommit summaryAuthorDate
r66076Follow up to r66075jeroendedauw19:25, 8 May 2010

Status & tagging log