Skip to content

Commit 195d6da

Browse files
author
Cyril Wanner
committed
improve getQualifiedColumnName
1 parent b129178 commit 195d6da

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

src/Parser.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -728,14 +728,15 @@ protected function isRelation($model, $relationName)
728728
* Get the qualified column name
729729
*
730730
* @param string $column
731+
* @param null $table
731732
* @return string
732733
*/
733734
protected function getQualifiedColumnName($column, $table = null)
734735
{
735736
//Check whether there is a matching column expression that contains an
736737
//alias and should therefore not be turned into a qualified column name.
737-
$isAlias = count(array_filter($this->query->columns ?: [], function($column) {
738-
return stripos($column, ' as ') !== false;
738+
$isAlias = count(array_filter($this->query->columns ?: [], function($queryColumn) use ($column) {
739+
return preg_match('/.*[\s\'"`]as\s*[\s\'"`]' . $column . '[\'"`]?$/', trim($queryColumn));
739740
})) > 0;
740741

741742
if (strpos($column, '.') === false && !$isAlias) {

0 commit comments

Comments
 (0)