Skip to content

Commit 395b419

Browse files
committed
Fix tests of older Laravel versions
1 parent bef99c2 commit 395b419

File tree

1 file changed

+13
-1
lines changed

1 file changed

+13
-1
lines changed

src/CockroachDbConnection.php

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ public function getSchemaBuilder(): DbBuilder
4646
*/
4747
protected function getDefaultSchemaGrammar(): BaseGrammar
4848
{
49-
return $this->withTablePrefix((new SchemaGrammar())->setConnection($this));
49+
return $this->withTablePrefix($this->setConnection(new SchemaGrammar());
5050
}
5151

5252
/**
@@ -77,4 +77,16 @@ protected function getDoctrineDriver()
7777
{
7878
return new PostgresDriver();
7979
}
80+
81+
/**
82+
* Required to set the connection. This isn't compatible with older Laravel versions
83+
*/
84+
protected function setConnection(BaseGrammar $grammar): BaseGrammar
85+
{
86+
if (method_exists($grammar, 'setConnection')) {
87+
return $grammar->setConnection($this);
88+
}
89+
90+
return $grammar;
91+
}
8092
}

0 commit comments

Comments
 (0)