Skip to content

Commit

Permalink
Merge pull request #4 from Uyan712/feat/db-expressions-escape
Browse files Browse the repository at this point in the history
Add support for Grammar's escape function
  • Loading branch information
halnique authored Jan 23, 2024
2 parents 349bc9a + fff6858 commit 68a5531
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions src/Connection.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
use Colopl\TiDB\Schema\Grammar as SchemaGrammar;
use Illuminate\Database\Grammar;
use Illuminate\Database\MySqlConnection;
use function method_exists;

class Connection extends MySqlConnection
{
Expand All @@ -31,15 +32,25 @@ class Connection extends MySqlConnection
*/
protected function getDefaultQueryGrammar()
{
return $this->withTablePrefix(new QueryGrammar);
$grammar = new QueryGrammar;
if (method_exists($grammar, 'setConnection')) {
$grammar->setConnection($this);
}

return $this->withTablePrefix($grammar);
}

/**
* @return Grammar
*/
protected function getDefaultSchemaGrammar()
{
return $this->withTablePrefix(new SchemaGrammar);
$grammar = new SchemaGrammar;
if (method_exists($grammar, 'setConnection')) {
$grammar->setConnection($this);
}

return $this->withTablePrefix($grammar);
}

/**
Expand Down

0 comments on commit 68a5531

Please sign in to comment.