Browse Source

Query transformation should happen after beforeFind is triggered

Jose Lorenzo Rodriguez 11 years ago
parent
commit
33595f379f
1 changed files with 3 additions and 3 deletions
  1. 3 3
      src/ORM/Query.php

+ 3 - 3
src/ORM/Query.php

@@ -607,15 +607,15 @@ class Query extends DatabaseQuery implements JsonSerializable {
  * {@inheritDoc}
  */
 	public function sql(ValueBinder $binder = null) {
-		$this->_transformQuery();
-
 		if (!$this->_beforeFindFired && $this->_type === 'select') {
 			$table = $this->repository();
 			$table->dispatchEvent('Model.beforeFind', [$this, $this->_options, !$this->eagerLoaded()]);
 			$this->_beforeFindFired = true;
 		}
 
-		return parent::sql($binder);
+		$this->_transformQuery();
+		$sql = parent::sql($binder);
+		return $sql;
 	}
 
 /**