From 6c969b5834d98e8093d6a118cb149ae06a67e1c7 Mon Sep 17 00:00:00 2001 From: Uyan712 Date: Mon, 22 Jan 2024 20:55:28 +0900 Subject: [PATCH 1/2] add support for Grammar's escape function --- src/Connection.php | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/Connection.php b/src/Connection.php index 0b06096..1a22816 100644 --- a/src/Connection.php +++ b/src/Connection.php @@ -31,7 +31,9 @@ class Connection extends MySqlConnection */ protected function getDefaultQueryGrammar() { - return $this->withTablePrefix(new QueryGrammar); + ($grammar = new QueryGrammar)->setConnection($this); + + return $this->withTablePrefix($grammar); } /** @@ -39,7 +41,9 @@ protected function getDefaultQueryGrammar() */ protected function getDefaultSchemaGrammar() { - return $this->withTablePrefix(new SchemaGrammar); + ($grammar = new SchemaGrammar)->setConnection($this); + + return $this->withTablePrefix($grammar); } /** From fff6858de895d47937a1d32d9019ecdae9779f91 Mon Sep 17 00:00:00 2001 From: Uyan712 Date: Tue, 23 Jan 2024 12:25:58 +0900 Subject: [PATCH 2/2] ensure existence of `setConnection` method --- src/Connection.php | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/Connection.php b/src/Connection.php index 1a22816..20d211f 100644 --- a/src/Connection.php +++ b/src/Connection.php @@ -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 { @@ -31,7 +32,10 @@ class Connection extends MySqlConnection */ protected function getDefaultQueryGrammar() { - ($grammar = new QueryGrammar)->setConnection($this); + $grammar = new QueryGrammar; + if (method_exists($grammar, 'setConnection')) { + $grammar->setConnection($this); + } return $this->withTablePrefix($grammar); } @@ -41,7 +45,10 @@ protected function getDefaultQueryGrammar() */ protected function getDefaultSchemaGrammar() { - ($grammar = new SchemaGrammar)->setConnection($this); + $grammar = new SchemaGrammar; + if (method_exists($grammar, 'setConnection')) { + $grammar->setConnection($this); + } return $this->withTablePrefix($grammar); }