Skip to content

Commit 4e3f419

Browse files
committed
unknown column if alias set in ActiveRecord::find method (issue #30)
1 parent c0126a6 commit 4e3f419

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

SortableGridBehavior.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,9 @@ public function beforeInsert()
8989
call_user_func($this->scope, $query);
9090
}
9191

92+
/* Override model alias if defined in the model's class */
93+
$query->from([$model::tableName() => $model::tableName()]);
94+
9295
$maxOrder = $query->max('{{' . trim($model::tableName(), '{}') . '}}.[[' . $this->sortableAttribute . ']]');
9396
$model->{$this->sortableAttribute} = $maxOrder + 1;
9497
}

0 commit comments

Comments
 (0)