Skip to content

Commit

Permalink
Merge branch '1.12'
Browse files Browse the repository at this point in the history
  • Loading branch information
staudenmeir committed Nov 17, 2023
2 parents b3047c4 + 99d1485 commit 2d96715
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/Query/Grammars/SqlServerGrammar.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ class SqlServerGrammar extends Base implements ExpressionGrammar
*/
public function compileInitialPath($column, $alias)
{
return 'cast('.$this->wrap($column).' as varchar) as '.$this->wrap($alias);
return 'cast('.$this->wrap($column).' as varchar(max)) as '.$this->wrap($alias);
}

/**
Expand All @@ -36,10 +36,10 @@ public function compileRecursivePath($column, $alias, bool $reverse = false)
$wrappedAlias = $this->wrap($alias);

if ($reverse) {
return "cast(cast($wrappedColumn as varchar) + ? + $wrappedAlias as varchar) as $wrappedAlias";
return "cast(cast($wrappedColumn as varchar(max)) + ? + $wrappedAlias as varchar(max)) as $wrappedAlias";
}

return "cast($wrappedAlias + ? + cast($wrappedColumn as varchar) as varchar) as $wrappedAlias";
return "cast($wrappedAlias + ? + cast($wrappedColumn as varchar(max)) as varchar(max)) as $wrappedAlias";
}

/**
Expand Down Expand Up @@ -96,7 +96,7 @@ public function compileCycleDetection(string $localKey, string $path): string
$localKey = $this->wrap($localKey);
$path = $this->wrap($path);

$castLocalKey = "cast($localKey as varchar)";
$castLocalKey = "cast($localKey as varchar(max))";

return "charindex($castLocalKey + ?, $path) > 0 or charindex(? + $castLocalKey + ?, $path) > 0";
}
Expand Down

0 comments on commit 2d96715

Please sign in to comment.