12759.patch

Kevin Ulrich Moschallski, 2011-02-03 15:29

Download (2.1 kB)

 
b/Classes/Persistence/Storage/Typo3DbBackend.php
298 298

  
299 299
		$this->parseSource($source, $sql, $parameters);
300 300
		$this->parseConstraint($query->getConstraint(), $source, $sql, $parameters);
301
		$this->parseOrderings($query->getOrderings(), $source, $sql);
301
		$this->parseOrderings($query->getOrderings(), $query->getConstraint(), $source, $sql);
302 302
		$this->parseLimitAndOffset($query->getLimit(), $query->getOffset(), $sql);
303 303

  
304 304
		$tableNames = array_unique(array_keys($sql['tables'] + $sql['unions']));
......
839 839
	 * Transforms orderings into SQL.
840 840
	 *
841 841
	 * @param array $orderings An array of orderings (Tx_Extbase_Persistence_QOM_Ordering)
842
	 * @param array $constraint
842 843
	 * @param Tx_Extbase_Persistence_QOM_SourceInterface $source The source
843 844
	 * @param array &$sql The query parts
844 845
	 * @return void
845 846
	 */
846
	protected function parseOrderings(array $orderings, Tx_Extbase_Persistence_QOM_SourceInterface $source, array &$sql) {
847
	protected function parseOrderings(array $orderings, $constraint, Tx_Extbase_Persistence_QOM_SourceInterface $source, array &$sql) {
847 848
		foreach ($orderings as $propertyName => $order) {
848 849
			switch ($order) {
849 850
				case Tx_Extbase_Persistence_QOM_QueryObjectModelConstantsInterface::JCR_ORDER_ASCENDING: // Deprecated since Extbase 1.1
......
873 874
				$sql['orderings'][] = $columnName . ' ' . $order;
874 875
			}
875 876
		}
877
		// if no order is specified and constraint operator is IN order the result by the given parameters
878
		if (empty($orderings) && $constraint->getOperator() == 9) {
879
			$values = implode(',', $constraint->getOperand2());
880
			$sql['orderings'][] = "FIELD(".$constraint->getOperand1()->getPropertyName().",".$values.")";
881
		}
876 882
	}
877 883

  
878 884
	/**