From 32b7f96d716540525099f9019faec72c2df9714f Mon Sep 17 00:00:00 2001 From: Harry Gulliford Date: Tue, 8 Oct 2024 16:18:09 +1100 Subject: [PATCH 01/15] Add compile tables, views, columns to schema grammar --- src/Schema/Grammars/FirebirdGrammar.php | 43 +++++++++++++++++++++++++ 1 file changed, 43 insertions(+) diff --git a/src/Schema/Grammars/FirebirdGrammar.php b/src/Schema/Grammars/FirebirdGrammar.php index 5eed43a..56907c4 100755 --- a/src/Schema/Grammars/FirebirdGrammar.php +++ b/src/Schema/Grammars/FirebirdGrammar.php @@ -22,6 +22,20 @@ class FirebirdGrammar extends Grammar */ protected $serials = ['bigInteger', 'integer', 'mediumInteger', 'smallInteger', 'tinyInteger']; + /** + * Compile the query to determine the tables. + * + * @return string + */ + public function compileTables() + { + return 'select trim(trailing from rdb$relation_name) as "name" ' + .'from rdb$relations ' + .'where rdb$relation_type = 0 ' + .'and (rdb$system_flag is null or rdb$system_flag = 0) ' + .'order by rdb$relation_name'; + } + /** * Compile the query to determine if a table exists. * @@ -32,6 +46,35 @@ public function compileTableExists() return 'select rdb$relation_name from rdb$relations where rdb$relation_name = ?'; } + /** + * Compile the query to determine the views. + * + * @return string + */ + public function compileViews() + { + return 'select rdb$relation_name as "name", ' + .'rdb$view_source as "definition" ' + .'from rdb$relations ' + .'where rdb$view_blr is not null ' + .'and (rdb$system_flag is null or rdb$system_flag = 0)'; + + } + + /** + * Compile the query to determine the columns. + * + * @param string $table + * @return string + */ + public function compileColumns($table) + { + return 'select trim(trailing from rdb$field_name) as "name" ' + .'from rdb$relation_fields ' + .'where rdb$relation_name = '.$this->quoteString($table).' ' + .'order by rdb$relation_name'; + } + /** * Compile the query to determine the list of columns. * From e64cc51cea10c789effa23714d47c11f0f24eda0 Mon Sep 17 00:00:00 2001 From: Harry Gulliford Date: Tue, 8 Oct 2024 16:44:30 +1100 Subject: [PATCH 02/15] Fix trailing trim on views name --- src/Schema/Grammars/FirebirdGrammar.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Schema/Grammars/FirebirdGrammar.php b/src/Schema/Grammars/FirebirdGrammar.php index 56907c4..1408195 100755 --- a/src/Schema/Grammars/FirebirdGrammar.php +++ b/src/Schema/Grammars/FirebirdGrammar.php @@ -53,7 +53,7 @@ public function compileTableExists() */ public function compileViews() { - return 'select rdb$relation_name as "name", ' + return 'select trim(trailing from rdb$relation_name) as "name", ' .'rdb$view_source as "definition" ' .'from rdb$relations ' .'where rdb$view_blr is not null ' From 88f9de92aa3b513f4b810b31d66c46add0b41b2b Mon Sep 17 00:00:00 2001 From: Harry Gulliford Date: Tue, 8 Oct 2024 16:47:19 +1100 Subject: [PATCH 03/15] Add tests for views schema --- tests/SchemaTest.php | 10 ++++++++++ tests/Support/MigrateDatabase.php | 21 +++++++++++++++++++++ 2 files changed, 31 insertions(+) diff --git a/tests/SchemaTest.php b/tests/SchemaTest.php index 4d9c92b..3a5ce16 100644 --- a/tests/SchemaTest.php +++ b/tests/SchemaTest.php @@ -25,6 +25,16 @@ public function it_has_column() $this->assertFalse(Schema::hasColumn('users', 'foo')); } + /** @test */ + public function it_has_views(): void + { + $this->createViews(); + + $this->assertTrue(Schema::hasView('view_all_users')); + + $this->assertFalse(Schema::hasView(uniqid('view_'))); + } + /** @test */ public function it_has_columns() { diff --git a/tests/Support/MigrateDatabase.php b/tests/Support/MigrateDatabase.php index 43f5fe7..872ad1a 100644 --- a/tests/Support/MigrateDatabase.php +++ b/tests/Support/MigrateDatabase.php @@ -15,6 +15,8 @@ public function setUp(): void parent::setUp(); if (! MigrationState::$migrated) { + $this->dropViews(); + $this->dropTables(); $this->createTables(); @@ -100,4 +102,23 @@ public function dropProcedure() } } } + + public function createViews(): void + { + DB::select('CREATE VIEW "view_all_users" AS SELECT * FROM "users"'); + } + + public function dropViews(): void + { + try { + DB::select('DROP VIEW "view_all_users"'); + } catch (QueryException $e) { + // Suppress the "view does not exist" exception, as we want to + // replicate dropIfExists() functionality without using the Schema + // class. + if (! Str::contains($e->getMessage(), 'does not exist')) { + throw $e; + } + } + } } From 18df6bcd2978023c66108aa2885351eedb964ef1 Mon Sep 17 00:00:00 2001 From: Harry Gulliford Date: Tue, 8 Oct 2024 16:48:24 +1100 Subject: [PATCH 04/15] Style fixes --- src/Schema/Grammars/FirebirdGrammar.php | 1 - 1 file changed, 1 deletion(-) diff --git a/src/Schema/Grammars/FirebirdGrammar.php b/src/Schema/Grammars/FirebirdGrammar.php index 1408195..2d871a7 100755 --- a/src/Schema/Grammars/FirebirdGrammar.php +++ b/src/Schema/Grammars/FirebirdGrammar.php @@ -58,7 +58,6 @@ public function compileViews() .'from rdb$relations ' .'where rdb$view_blr is not null ' .'and (rdb$system_flag is null or rdb$system_flag = 0)'; - } /** From de56880897ffb2fbf5042233c982998ff4e6218f Mon Sep 17 00:00:00 2001 From: Harry Gulliford Date: Tue, 8 Oct 2024 16:59:54 +1100 Subject: [PATCH 05/15] Disable fail-fast in actions --- .github/workflows/tests.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index fa38a9f..d57212b 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -29,6 +29,7 @@ jobs: php: 8.0 - laravel: 10.* php: 7.4 + fail-fast: false name: PHP ${{ matrix.php }}, Laravel ${{ matrix.laravel }}, Firebird ${{ matrix.firebird }}, ${{ matrix.stability }} From 1253bfc4492f6a8dca4fed6b5440d21c49a6d520 Mon Sep 17 00:00:00 2001 From: Harry Gulliford Date: Tue, 8 Oct 2024 20:20:32 +1100 Subject: [PATCH 06/15] Skip has view test if < laravel 10.34 --- tests/SchemaTest.php | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/tests/SchemaTest.php b/tests/SchemaTest.php index 3a5ce16..47d2634 100644 --- a/tests/SchemaTest.php +++ b/tests/SchemaTest.php @@ -26,8 +26,12 @@ public function it_has_column() } /** @test */ - public function it_has_views(): void + public function it_has_view(): void { + if (version_compare($this->app->version(), '10.34.0', '<')) { + $this->markTestSkipped('The hasView method is only available in Laravel 10.34.0 and above.'); + } + $this->createViews(); $this->assertTrue(Schema::hasView('view_all_users')); From 2bb4e8be7684901cad3dbdec63ae4a73e8bcce5b Mon Sep 17 00:00:00 2001 From: Harry Gulliford Date: Tue, 8 Oct 2024 20:28:01 +1100 Subject: [PATCH 07/15] Add php 8.3 to test matrix --- .github/workflows/tests.yml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index d57212b..ac07979 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -9,7 +9,7 @@ jobs: strategy: matrix: os: [ubuntu-latest] - php: [8.2, 8.1, 8.0, 7.4] + php: [8.3, 8.2, 8.1, 8.0, 7.4] laravel: [10.*, 9.*, 8.*] stability: [prefer-lowest, prefer-stable] firebird: [v4.0, v3.0, v2.5.9-sc] @@ -21,6 +21,8 @@ jobs: - laravel: 10.* testbench: ^8.0 exclude: + - laravel: 8.* + php: 8.3 - laravel: 8.* php: 8.2 - laravel: 9.* From ee91a6a8c88c160d5ee5fb4767306de339f92ecc Mon Sep 17 00:00:00 2001 From: Harry Gulliford Date: Tue, 8 Oct 2024 20:43:25 +1100 Subject: [PATCH 08/15] Add support for Laravel 11 --- .github/workflows/tests.yml | 8 +++++++- composer.json | 12 ++++++------ 2 files changed, 13 insertions(+), 7 deletions(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index ac07979..f56a0fb 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -10,7 +10,7 @@ jobs: matrix: os: [ubuntu-latest] php: [8.3, 8.2, 8.1, 8.0, 7.4] - laravel: [10.*, 9.*, 8.*] + laravel: [11.*, 10.*, 9.*, 8.*] stability: [prefer-lowest, prefer-stable] firebird: [v4.0, v3.0, v2.5.9-sc] include: @@ -31,6 +31,12 @@ jobs: php: 8.0 - laravel: 10.* php: 7.4 + - laravel: 11.* + php: 8.1 + - laravel: 11.* + php: 8.0 + - laravel: 11.* + php: 7.4 fail-fast: false name: PHP ${{ matrix.php }}, Laravel ${{ matrix.laravel }}, Firebird ${{ matrix.firebird }}, ${{ matrix.stability }} diff --git a/composer.json b/composer.json index 949e711..8e44abd 100644 --- a/composer.json +++ b/composer.json @@ -4,15 +4,15 @@ "license": "MIT", "require": { "php": "^7.4|^8.0", - "illuminate/support": "^8.65|^9.33|^10.0", - "illuminate/container": "^8.65|^9.33|^10.0", - "illuminate/database": "^8.65|^9.33|^10.0", - "illuminate/events": "^8.65|^9.33|^10.0" + "illuminate/support": "^8.65|^9.33|^10.0|^11.0", + "illuminate/container": "^8.65|^9.33|^10.0|^11.0", + "illuminate/database": "^8.65|^9.33|^10.0|^11.0", + "illuminate/events": "^8.65|^9.33|^10.0|^11.0" }, "require-dev": { "mockery/mockery": "^1.4", - "phpunit/phpunit": "^9.5.10", - "orchestra/testbench": "^6.19|^7.0|^8.0", + "phpunit/phpunit": "^9.5.10|^10.0", + "orchestra/testbench": "^6.19|^7.0|^8.0|^9.0", "fakerphp/faker": "^1.15" }, "archive": { From ec33fc9a7563208c12acbb4fb38bc5cdcd06639f Mon Sep 17 00:00:00 2001 From: Harry Gulliford Date: Tue, 8 Oct 2024 20:46:17 +1100 Subject: [PATCH 09/15] Define testbench 9 for laravel 11 --- .github/workflows/tests.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index f56a0fb..8eaed93 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -20,6 +20,8 @@ jobs: testbench: ^7.0 - laravel: 10.* testbench: ^8.0 + - laravel: 11.* + testbench: ^9.0 exclude: - laravel: 8.* php: 8.3 From 6447b74c2b93a96942466a1b1b48da5b4cc7aaf6 Mon Sep 17 00:00:00 2001 From: Harry Gulliford Date: Tue, 8 Oct 2024 20:52:52 +1100 Subject: [PATCH 10/15] Resolve deprecated phpunit methods --- composer.json | 2 +- tests/QueryTest.php | 32 ++++++++++++++++---------------- 2 files changed, 17 insertions(+), 17 deletions(-) diff --git a/composer.json b/composer.json index 8e44abd..345dce5 100644 --- a/composer.json +++ b/composer.json @@ -11,7 +11,7 @@ }, "require-dev": { "mockery/mockery": "^1.4", - "phpunit/phpunit": "^9.5.10|^10.0", + "phpunit/phpunit": "^9.6.11|^10.0", "orchestra/testbench": "^6.19|^7.0|^8.0|^9.0", "fakerphp/faker": "^1.15" }, diff --git a/tests/QueryTest.php b/tests/QueryTest.php index 5526ceb..012e93d 100644 --- a/tests/QueryTest.php +++ b/tests/QueryTest.php @@ -54,9 +54,9 @@ public function it_can_select() $this->assertCount(3, (array) $result); - $this->assertObjectHasAttribute('name', $result); - $this->assertObjectHasAttribute('city', $result); - $this->assertObjectHasAttribute('country', $result); + $this->assertObjectHasProperty('name', $result); + $this->assertObjectHasProperty('city', $result); + $this->assertObjectHasProperty('country', $result); $this->assertEquals('Anna', $result->name); $this->assertEquals('Sydney', $result->city); @@ -82,9 +82,9 @@ public function it_can_select_with_aliases() $this->assertCount(3, (array) $result); - $this->assertObjectHasAttribute('USER_NAME', $result); - $this->assertObjectHasAttribute('user_city', $result); - $this->assertObjectHasAttribute('User_Country', $result); + $this->assertObjectHasProperty('USER_NAME', $result); + $this->assertObjectHasProperty('user_city', $result); + $this->assertObjectHasProperty('User_Country', $result); $this->assertEquals('Anna', $result->USER_NAME); $this->assertEquals('Sydney', $result->user_city); @@ -1050,11 +1050,11 @@ public function it_can_add_inner_join() ->get(); $this->assertCount(10, $results); - $this->assertObjectHasAttribute('name', $results->first()); - $this->assertObjectHasAttribute('email', $results->first()); - $this->assertObjectHasAttribute('state', $results->first()); - $this->assertObjectHasAttribute('price', $results->first()); - $this->assertObjectHasAttribute('quantity', $results->first()); + $this->assertObjectHasProperty('name', $results->first()); + $this->assertObjectHasProperty('email', $results->first()); + $this->assertObjectHasProperty('state', $results->first()); + $this->assertObjectHasProperty('price', $results->first()); + $this->assertObjectHasProperty('quantity', $results->first()); } /** @test */ @@ -1073,11 +1073,11 @@ public function it_can_add_inner_join_where() $this->assertCount(2, $results); $this->assertEquals(100, $results->first()->price); - $this->assertObjectHasAttribute('name', $results->first()); - $this->assertObjectHasAttribute('email', $results->first()); - $this->assertObjectHasAttribute('state', $results->first()); - $this->assertObjectHasAttribute('price', $results->first()); - $this->assertObjectHasAttribute('quantity', $results->first()); + $this->assertObjectHasProperty('name', $results->first()); + $this->assertObjectHasProperty('email', $results->first()); + $this->assertObjectHasProperty('state', $results->first()); + $this->assertObjectHasProperty('price', $results->first()); + $this->assertObjectHasProperty('quantity', $results->first()); } /** @test */ From 2db309ce1c05cdf7cd14e27ab1db263185465fe1 Mon Sep 17 00:00:00 2001 From: Harry Gulliford Date: Tue, 8 Oct 2024 21:01:45 +1100 Subject: [PATCH 11/15] Bump actions/checkout to v4 --- .github/workflows/tests.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 8eaed93..6e236bf 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -55,7 +55,7 @@ jobs: steps: - name: Checkout code - uses: actions/checkout@v2 + uses: actions/checkout@v4 - name: Setup PHP uses: shivammathur/setup-php@v2 From 526877021230a3aeba5f7dde4b3285df17534da9 Mon Sep 17 00:00:00 2001 From: Harry Gulliford Date: Tue, 8 Oct 2024 21:04:06 +1100 Subject: [PATCH 12/15] Update gitignore --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index 8227305..261ae4a 100644 --- a/.gitignore +++ b/.gitignore @@ -1,6 +1,7 @@ .idea .php_cs .php_cs.cache +.phpunit.cache .phpunit.result.cache .DS_Store build From e86ecbd7d4826cd067541afba2689e2cd1137f51 Mon Sep 17 00:00:00 2001 From: Harry Gulliford Date: Tue, 8 Oct 2024 21:04:17 +1100 Subject: [PATCH 13/15] Update readme --- readme.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/readme.md b/readme.md index 94ff4b5..807dd50 100644 --- a/readme.md +++ b/readme.md @@ -9,8 +9,8 @@ This package adds support for the Firebird PDO Database Driver in Laravel applic ## Version Support -- **PHP:** 7.4, 8.0, 8.1, 8.2 -- **Laravel:** 8.x, 9.x, 10.x +- **PHP:** 7.4, 8.0, 8.1, 8.2, 8.3 +- **Laravel:** 8.x, 9.x, 10.x, 11.x - **Firebird:** 2.5, 3.0, 4.0 ## Installation From 1097c2cae0342543b770fa4354e1ce6e0c7b760b Mon Sep 17 00:00:00 2001 From: Johannes Pichler Date: Fri, 11 Jul 2025 11:44:49 +0200 Subject: [PATCH 14/15] Update for Laravel 12 compatibility --- composer.json | 12 ++++++------ src/FirebirdConnection.php | 4 ++-- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/composer.json b/composer.json index 345dce5..711b282 100644 --- a/composer.json +++ b/composer.json @@ -4,15 +4,15 @@ "license": "MIT", "require": { "php": "^7.4|^8.0", - "illuminate/support": "^8.65|^9.33|^10.0|^11.0", - "illuminate/container": "^8.65|^9.33|^10.0|^11.0", - "illuminate/database": "^8.65|^9.33|^10.0|^11.0", - "illuminate/events": "^8.65|^9.33|^10.0|^11.0" + "illuminate/support": "^8.65|^9.33|^10.0|^11.0|^12.0", + "illuminate/container": "^8.65|^9.33|^10.0|^11.0|^12.0", + "illuminate/database": "^8.65|^9.33|^10.0|^11.0|^12.0", + "illuminate/events": "^8.65|^9.33|^10.0|^11.0|^12.0" }, "require-dev": { "mockery/mockery": "^1.4", - "phpunit/phpunit": "^9.6.11|^10.0", - "orchestra/testbench": "^6.19|^7.0|^8.0|^9.0", + "phpunit/phpunit": "^9.6.11|^10.0|^11.0", + "orchestra/testbench": "^6.19|^7.0|^8.0|^9.0|^10.0", "fakerphp/faker": "^1.15" }, "archive": { diff --git a/src/FirebirdConnection.php b/src/FirebirdConnection.php index 519034c..e9ad826 100755 --- a/src/FirebirdConnection.php +++ b/src/FirebirdConnection.php @@ -18,7 +18,7 @@ class FirebirdConnection extends DatabaseConnection */ protected function getDefaultQueryGrammar() { - return new FirebirdQueryGrammar; + return new FirebirdQueryGrammar($this); } /** @@ -52,7 +52,7 @@ public function getSchemaBuilder() */ protected function getDefaultSchemaGrammar() { - return $this->withTablePrefix(new FirebirdSchemaGrammar); + return $this->withTablePrefix(new FirebirdSchemaGrammar($this)); } /** From d0e56817032a27baa54c913f9775ab961f2c5695 Mon Sep 17 00:00:00 2001 From: Johannes Pichler Date: Fri, 11 Jul 2025 11:51:08 +0200 Subject: [PATCH 15/15] update tests --- .github/workflows/tests.yml | 29 ++++------------------------- 1 file changed, 4 insertions(+), 25 deletions(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 6e236bf..7c48514 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -9,36 +9,15 @@ jobs: strategy: matrix: os: [ubuntu-latest] - php: [8.3, 8.2, 8.1, 8.0, 7.4] - laravel: [11.*, 10.*, 9.*, 8.*] + php: [8.4, 8.3, 8.2] + laravel: [12.*, 11.*] stability: [prefer-lowest, prefer-stable] firebird: [v4.0, v3.0, v2.5.9-sc] include: - - laravel: 8.* - testbench: ^6.19 - - laravel: 9.* - testbench: ^7.0 - - laravel: 10.* - testbench: ^8.0 - laravel: 11.* testbench: ^9.0 - exclude: - - laravel: 8.* - php: 8.3 - - laravel: 8.* - php: 8.2 - - laravel: 9.* - php: 7.4 - - laravel: 10.* - php: 8.0 - - laravel: 10.* - php: 7.4 - - laravel: 11.* - php: 8.1 - - laravel: 11.* - php: 8.0 - - laravel: 11.* - php: 7.4 + - laravel: 12.* + testbench: ^10.0 fail-fast: false name: PHP ${{ matrix.php }}, Laravel ${{ matrix.laravel }}, Firebird ${{ matrix.firebird }}, ${{ matrix.stability }}