Merge "Add column alias support in BatchRowIterator"
authorjenkins-bot <jenkins-bot@gerrit.wikimedia.org>
Mon, 6 Jun 2016 12:08:27 +0000 (12:08 +0000)
committerGerrit Code Review <gerrit@wikimedia.org>
Mon, 6 Jun 2016 12:08:27 +0000 (12:08 +0000)
includes/utils/BatchRowIterator.php

index 3bd3a4c..419ee47 100644 (file)
@@ -136,8 +136,9 @@ class BatchRowIterator implements RecursiveIterator {
         */
        public function extractPrimaryKeys( $row ) {
                $pk = [];
-               foreach ( $this->primaryKey as $column ) {
-                       $pk[$column] = $row->$column;
+               foreach ( $this->primaryKey as $alias => $column ) {
+                       $name = is_numeric( $alias ) ? $column : $alias;
+                       $pk[$name] = $row->{$name};
                }
                return $pk;
        }
@@ -228,8 +229,9 @@ class BatchRowIterator implements RecursiveIterator {
 
                $maxRow = end( $this->current );
                $maximumValues = [];
-               foreach ( $this->primaryKey as $column ) {
-                       $maximumValues[$column] = $this->db->addQuotes( $maxRow->$column );
+               foreach ( $this->primaryKey as $alias => $column ) {
+                       $name = is_numeric( $alias ) ? $column : $alias;
+                       $maximumValues[$column] = $this->db->addQuotes( $maxRow->{$name} );
                }
 
                $pkConditions = [];