Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[11.x] Add MSSQL 2017 and PGSQL 10 builds #52631

Merged
merged 4 commits into from
Sep 5, 2024
Merged

Conversation

driesvints
Copy link
Member

@driesvints driesvints commented Sep 3, 2024

Test the low end supported databases.

Would love to get help getting the tests to pass.

@driesvints driesvints changed the title Add MSSQL 2017 and PGSQL 10 builds [11.x] Add MSSQL 2017 and PGSQL 10 builds Sep 3, 2024
@Jubeki
Copy link
Contributor

Jubeki commented Sep 3, 2024

It seems like generated columns only exist as of PostegreSQL 12:
https://www.postgresql.org/docs/12/ddl-generated-columns.html

This Documentation (5.3 Generated Columns) does not exist on v11 or v10:
https://www.postgresql.org/docs/10/ddl.html

Edit: Seems to be confirmed by the v12 release notes: https://www.postgresql.org/docs/release/12.0/

@Jubeki
Copy link
Contributor

Jubeki commented Sep 3, 2024

websearch_to_tsquery exists only as of PostgreSQL v11: https://www.postgresql.org/docs/release/11.0/

@Jubeki
Copy link
Contributor

Jubeki commented Sep 3, 2024

Primary key and foreign key on partitioned tables only exists as of PostgreSQL v11:
https://www.postgresql.org/docs/release/11.0/

@driesvints
Copy link
Member Author

Thanks @Jubeki. We should be able to skip these tests then somehow.

@Jubeki
Copy link
Contributor

Jubeki commented Sep 3, 2024

version_compare(Schema::getConnection()->getServerVersion(), '12.0', '<')

This should probably work, as it is also used here:

.(version_compare($this->connection?->getServerVersion(), '12.0', '<') ? "'' as generated, " : 'a.attgenerated as generated, ')

@driesvints
Copy link
Member Author

Was thinking more like a Phpunit annotation but I guess Phpunit doesn't uses those anymore? 🤔

@Jubeki
Copy link
Contributor

Jubeki commented Sep 3, 2024

There is already a check for the used type of database, so I don't think there is an Attribute for that:

if ($this->driver !== 'pgsql') {
$this->markTestSkipped('Test requires a PostgreSQL connection.');
}

@Jubeki
Copy link
Contributor

Jubeki commented Sep 3, 2024

Maybe @crynobone has an idea about the Attributes.

@crynobone
Copy link
Member

You need to write one to hook with Testbench, something like:

<?php

namespace Illuminate\Tests\Testbench\Attributes;

use Attribute;
use Closure;
use Illuminate\Support\Facades\DB;
use Orchestra\Testbench\Contracts\Attributes\Actionable as ActionableContract;

#[Attribute(Attribute::TARGET_CLASS | Attribute::TARGET_METHOD | Attribute::IS_REPEATABLE)]
class RequiresDatabase implements ActionableContract
{
    /**
     * Construct a new attribute.
     *
     * @param  string  $driver
     * @param  string  $versionRequirement
     */
    public function __construct(public string $driver, public string $versionRequirement)
    {
        //
    }

    /**
     * Handle the attribute.
     *
     * @param  \Illuminate\Foundation\Application  $app
     * @param  \Closure(string, array<int, mixed>):void  $action
     * @return void
     */
    public function handle($app, Closure $action): void
    {
        $connection = DB::connection($this->driver);

        if (
            preg_match('/(?P<operator>[<>=!]{0,2})\s*(?P<version>[\d\.-]+(dev|(RC|alpha|beta)[\d\.])?)[ \t]*\r?$/m', $this->versionRequirement, $matches)
        ) {
            if (empty($matches['operator'])) {
                $matches['operator'] = '>=';
            }

            if (! version_compare($connection->getServerVersion(), $matches['version'], $matches['operator'])) {
                call_user_func($action, 'markTestSkipped', [sprintf("Requires %s:%s", $connection->getName(), $this->versionRequirement)]);
            }
        }
    }
}

@driesvints
Copy link
Member Author

driesvints commented Sep 4, 2024

It's okay. Fine to leave the current skips. Just need to fix the postgres types failure and then this one is ready to go.

* Find out which types are not counted

* dump types

* Bypass count check for pgsql 10
@driesvints driesvints marked this pull request as ready for review September 5, 2024 07:09
@driesvints
Copy link
Member Author

Nice, thanks @Jubeki

@taylorotwell taylorotwell merged commit 4579141 into 11.x Sep 5, 2024
32 checks passed
@taylorotwell taylorotwell deleted the driesvints-patch-1 branch September 5, 2024 20:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants