Skip to content

Conversation

tpetry
Copy link
Contributor

@tpetry tpetry commented Oct 7, 2025

About two weeks ago, PostgreSQL 18 was released which finally supports virtual generated columns. This PR adds support for it - in a backwards compatible manner.

The virtualAs() column modifier was officially not support for PostgreSQL and produced SQL that was invalid:

alter table "users" add column "email_lower2" text not null generated always as (lower(email));
-- ERROR:  syntax error at or near ";"
-- LINE 1: ...il_lower2" text not null generated always as (lower(email));

With PostgreSQL 18, this syntax is now supported and defaults to a virtual generated column. However, the current implementation was changed to explicitly add the virtual keyword to the DDL query - just to be sure in case defaults may change in the future.

Additionally, the tests schema builder tests have been changed to now also test virtual columns which had been excluded in the past - because PG didn't support it.

@taylorotwell taylorotwell merged commit a89a872 into laravel:12.x Oct 7, 2025
66 checks passed
@taylorotwell
Copy link
Member

Thanks!

@tpetry tpetry deleted the 12.x-pgsql-virtualas branch October 7, 2025 17:18
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.

2 participants