diff --git a/src/Database/Query/FMBaseBuilder.php b/src/Database/Query/FMBaseBuilder.php index bc9be5b..e106679 100644 --- a/src/Database/Query/FMBaseBuilder.php +++ b/src/Database/Query/FMBaseBuilder.php @@ -832,8 +832,8 @@ public function insert(array $values) $this->fieldData = $this->mapFieldNamesForArray($values); - //TODO handle inserting multiple records at once, maybe? - //TODO handle setting portal data + // TODO handle inserting multiple records at once, maybe? + // TODO handle setting portal data // Finally, we will run this query against the database connection and return // the results. We will need to also flatten these bindings before running diff --git a/src/Services/FileMakerConnection.php b/src/Services/FileMakerConnection.php index 1d66733..0452944 100644 --- a/src/Services/FileMakerConnection.php +++ b/src/Services/FileMakerConnection.php @@ -874,7 +874,20 @@ public function setTimeout($timeout) protected function getDefaultQueryGrammar() { - return new FMGrammar; + // check if this is laravel 11 or 12 + // Laravel 11 constructs a grammar without any parameters + // Laravel 12 requires a connection as a constructor parameter + $version = app()->version(); + // get the major version number + $majorVersion = (int) explode('.', $version)[0]; + if ($majorVersion < 12) { + // Laravel 11 and earlier + return new FMGrammar; + } + + // Laravel 12 + return new FMGrammar($this); + } // public function getLayoutMetadata($layout = null) diff --git a/tests/Unit/FileMakerConnectionTest.php b/tests/Unit/FileMakerConnectionTest.php index 5f3b233..51a5211 100644 --- a/tests/Unit/FileMakerConnectionTest.php +++ b/tests/Unit/FileMakerConnectionTest.php @@ -19,7 +19,7 @@ protected function tearDown(): void Mockery::close(); } - public function testConnectionGetsTheDefaultDatabaseConfiguration() + public function test_connection_gets_the_default_database_configuration() { $connection = app(FileMakerConnection::class); @@ -27,7 +27,7 @@ public function testConnectionGetsTheDefaultDatabaseConfiguration() $this->assertEquals('tester', $connection->getConfig('database')); } - public function testSetConnectionChangesTheDatabaseConfiguration() + public function test_set_connection_changes_the_database_configuration() { $connection = app(FileMakerConnection::class); $this->assertEquals('filemaker', $connection->getConfig('name')); @@ -39,7 +39,7 @@ public function testSetConnectionChangesTheDatabaseConfiguration() $this->assertEquals('tester2', $connection->getConfig('database')); } - public function testSetLayoutChangesTheLayoutUsed() + public function test_set_layout_changes_the_layout_used() { $connection = app(FileMakerConnection::class); $this->assertEquals('', $connection->getLayout()); @@ -49,7 +49,7 @@ public function testSetLayoutChangesTheLayoutUsed() $this->assertEquals('dapi-pet', $connection->getLayout()); } - public function testDatabasePrefixIsAddedToLayoutNames() + public function test_database_prefix_is_added_to_layout_names() { $connection = app(FileMakerConnection::class)->setConnection('prefix'); @@ -62,7 +62,7 @@ public function testDatabasePrefixIsAddedToLayoutNames() $this->assertEquals('dapi-car', $connection->getLayout()); } - public function testLoginToFileMaker() + public function test_login_to_file_maker() { $this->overrideDBHost(); Http::fake([ @@ -77,7 +77,7 @@ public function testLoginToFileMaker() $this->assertEquals('new-token', $token); } - public function testFailedLoginToFileMakerThrow() + public function test_failed_login_to_file_maker_throw() { $this->overrideDBHost(); Http::fake([