Merge pull request #244 from codler/patch-7
DB::raw should have higher precedence than alias
This commit is contained in:
commit
4737c6d8a9
|
@ -17,6 +17,11 @@ abstract class Grammar {
|
|||
*/
|
||||
public function wrap($value)
|
||||
{
|
||||
// Expressions should be injected into the query as raw strings,
|
||||
// so we do not want to wrap them in any way. We'll just return
|
||||
// the string value from the expression to be included.
|
||||
if ($value instanceof Expression) return $value->get();
|
||||
|
||||
// If the value being wrapped contains a column alias, we need to
|
||||
// wrap it a little differently as each segment must be wrapped
|
||||
// and not the entire string. We'll split the value on the "as"
|
||||
|
@ -28,11 +33,6 @@ public function wrap($value)
|
|||
return $this->wrap($segments[0]).' AS '.$this->wrap($segments[2]);
|
||||
}
|
||||
|
||||
// Expressions should be injected into the query as raw strings,
|
||||
// so we do not want to wrap them in any way. We'll just return
|
||||
// the string value from the expression to be included.
|
||||
if ($value instanceof Expression) return $value->get();
|
||||
|
||||
// Since columns may be prefixed with their corresponding table
|
||||
// name so as to not make them ambiguous, we will need to wrap
|
||||
// the table and the column in keyword identifiers.
|
||||
|
|
Loading…
Reference in New Issue