Skip to content

Comments

Add support for generated columns in PostgreSQL (Redux)#41856

Merged
matthewd merged 2 commits intorails:mainfrom
MSNexploder:virtual-columns
Sep 16, 2021
Merged

Add support for generated columns in PostgreSQL (Redux)#41856
matthewd merged 2 commits intorails:mainfrom
MSNexploder:virtual-columns

Conversation

@MSNexploder
Copy link
Contributor

Basically this is a friendly takeover of #39368 which adds support for generated columns in PostgreSQL (which are available since PostgreSQL 12).

Sadly there was no progress since July 2020.
I kept @fanfilmu as author and just rebased onto current main and incorporated most of the given feedback.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is the only place where I disagree with some of the given feedback regarding future proofing (e.g. #39368 (comment)). In PostgreSQL 14 there is still no VIRTUAL support planed.
In my opinion it's better to provide a precise error message rather than adding support for something that may not happen anytime soon (and maybe even create incorrect SQL statements in the process).

Note: This only affects migration support. Reading any type of virtual column is supported.

@MSNexploder MSNexploder force-pushed the virtual-columns branch 3 times, most recently from 6e1b337 to 4233c97 Compare April 13, 2021 06:53
@MSNexploder MSNexploder force-pushed the virtual-columns branch 2 times, most recently from 89d5577 to 249e327 Compare April 18, 2021 09:36
@fschwahn
Copy link
Contributor

We've been running this PR as a monkeypatch for a few months without issues. It would be great to have this merged!

@luizkowalski
Copy link
Contributor

Any chances that this PR could fix this issue? #42469

@matthewd
Copy link
Member

Yeah, with time marching on, I'm feeling more inclined towards the current implementation's conservatism: Postgres will presumably implement virtual columns at some point in the future, but our ability to predict exactly what that'll look like is limited. Better to make support available for the existing feature, and leave an attempt to use the still-theoretical future behaviour to fail in a clear way (which is no better or worse than how it would already fail today if we continue to not ship this PR).

@bbugh
Copy link

bbugh commented Dec 17, 2021

Apologies for commenting, did this make it into Rails 7? I was looking through changelogs and couldn't find anything conclusive.

@ghiculescu
Copy link
Member

@jhubert
Copy link
Contributor

jhubert commented Apr 12, 2022

We're not quite on Rails 7 yet, so I back-ported this to a gem for Rails 6.1.5 in the hopes that it may be useful for others as well:

https://github.com/retailzipline/pg_generated_column_support

yahonda added a commit to yahonda/rails that referenced this pull request Jun 2, 2025
PostgreSQL 18 Beta 1 introduces virtual (not persisted) generated columns,
which are now the default unless the STORED option is explicitly specified.

Rails previously supported only stored generated columns on PostgreSQL 12+,
via rails#41856, as only stored generated columns
were supported by PostgreSQL at the time.

This commit adds support for virtual generated columns on PostgreSQL 18 and later:

- `t.virtual ... stored: false` now generates virtual generated columns.
- Omitting `stored:` also creates virtual generated columns on PostgreSQL 18+.
- On PostgreSQL < 18, specifying `stored: false` or omitting `stored:` raises ArgumentError.
  consistent with the existing behavior in earlier Rails versions.

Reference: PostgreSQL 18 release notes
https://www.postgresql.org/docs/18/release-18.html

> Allow generated columns to be virtual, and make them the default
> (Peter Eisentraut, Jian He, Richard Guo, Dean Rasheed)
>
> Virtual generated columns generate their values when the columns are read, not written.
> The write behavior can still be specified via the STORED option.

Source:
- https://git.postgresql.org/gitweb/?p=postgresql.git;a=commitdiff;h=83ea6c540
- https://git.postgresql.org/gitweb/?p=postgresql.git;a=commitdiff;h=cdc168ad4
- https://git.postgresql.org/gitweb/?p=postgresql.git;a=commitdiff;h=1e4351af3
yahonda added a commit to yahonda/rails that referenced this pull request Jun 2, 2025
PostgreSQL 18 Beta 1 introduces virtual (not persisted) generated columns,
which are now the default unless the STORED option is explicitly specified.

Rails previously supported only stored generated columns on PostgreSQL 12+,
via rails#41856, as only stored generated columns
were supported by PostgreSQL at the time.

This commit adds support for virtual generated columns on PostgreSQL 18 and later:

- `t.virtual ... stored: false` now generates virtual generated columns.
- Omitting `stored:` also creates virtual generated columns on PostgreSQL 18+.
- On PostgreSQL < 18, specifying `stored: false` or omitting `stored:` raises ArgumentError.
  consistent with the existing behavior in earlier Rails versions.

Reference: PostgreSQL 18 release notes
https://www.postgresql.org/docs/18/release-18.html

> Allow generated columns to be virtual, and make them the default
> (Peter Eisentraut, Jian He, Richard Guo, Dean Rasheed)
>
> Virtual generated columns generate their values when the columns are read, not written.
> The write behavior can still be specified via the STORED option.

Source:
- https://git.postgresql.org/gitweb/?p=postgresql.git;a=commitdiff;h=83ea6c540
- https://git.postgresql.org/gitweb/?p=postgresql.git;a=commitdiff;h=cdc168ad4
- https://git.postgresql.org/gitweb/?p=postgresql.git;a=commitdiff;h=1e4351af3
yahonda added a commit to yahonda/rails that referenced this pull request Jun 3, 2025
PostgreSQL 18 Beta 1 introduces virtual (not persisted) generated columns,
which are now the default unless the STORED option is explicitly specified.

Rails previously supported only stored generated columns on PostgreSQL 12+,
via rails#41856, as only stored generated columns
were supported by PostgreSQL at the time.

This commit adds support for virtual generated columns on PostgreSQL 18 and later:

- `t.virtual ... stored: false` now generates virtual generated columns.
- Omitting `stored:` also creates virtual generated columns on PostgreSQL 18+.
- On PostgreSQL < 18, specifying `stored: false` or omitting `stored:` raises ArgumentError.
  consistent with the existing behavior in earlier Rails versions.

Reference: PostgreSQL 18 release notes
https://www.postgresql.org/docs/18/release-18.html

> Allow generated columns to be virtual, and make them the default
> (Peter Eisentraut, Jian He, Richard Guo, Dean Rasheed)
>
> Virtual generated columns generate their values when the columns are read, not written.
> The write behavior can still be specified via the STORED option.

Source:
- https://git.postgresql.org/gitweb/?p=postgresql.git;a=commitdiff;h=83ea6c540
- https://git.postgresql.org/gitweb/?p=postgresql.git;a=commitdiff;h=cdc168ad4
- https://git.postgresql.org/gitweb/?p=postgresql.git;a=commitdiff;h=1e4351af3
yahonda added a commit to yahonda/rails that referenced this pull request Jun 8, 2025
PostgreSQL 18 Beta 1 introduces virtual (not persisted) generated columns,
which are now the default unless the STORED option is explicitly specified.

Rails previously supported only stored generated columns on PostgreSQL 12+,
via rails#41856, as only stored generated columns
were supported by PostgreSQL at the time.

This commit adds support for virtual generated columns on PostgreSQL 18 and later:

- `t.virtual ... stored: false` now generates virtual generated columns.
- Omitting `stored:` also creates virtual generated columns on PostgreSQL 18+.
- On PostgreSQL < 18, specifying `stored: false` or omitting `stored:` raises ArgumentError.
  consistent with the existing behavior in earlier Rails versions.

Reference: PostgreSQL 18 release notes
https://www.postgresql.org/docs/18/release-18.html

> Allow generated columns to be virtual, and make them the default
> (Peter Eisentraut, Jian He, Richard Guo, Dean Rasheed)
>
> Virtual generated columns generate their values when the columns are read, not written.
> The write behavior can still be specified via the STORED option.

Source:
- https://git.postgresql.org/gitweb/?p=postgresql.git;a=commitdiff;h=83ea6c540
- https://git.postgresql.org/gitweb/?p=postgresql.git;a=commitdiff;h=cdc168ad4
- https://git.postgresql.org/gitweb/?p=postgresql.git;a=commitdiff;h=1e4351af3

Co-authored-by: fatkodima <[email protected]>
yahonda added a commit to yahonda/rails that referenced this pull request Jun 9, 2025
PostgreSQL 18 Beta 1 introduces virtual (not persisted) generated columns,
which are now the default unless the STORED option is explicitly specified.

Rails previously supported only stored generated columns on PostgreSQL 12+,
via rails#41856, as only stored generated columns
were supported by PostgreSQL at the time.

This commit adds support for virtual generated columns on PostgreSQL 18 and later:

- `t.virtual ... stored: false` now generates virtual generated columns.
- Omitting `stored:` also creates virtual generated columns on PostgreSQL 18+.
- On PostgreSQL < 18, specifying `stored: false` or omitting `stored:` raises ArgumentError.
  consistent with the existing behavior in earlier Rails versions.

Reference: PostgreSQL 18 release notes
https://www.postgresql.org/docs/18/release-18.html

> Allow generated columns to be virtual, and make them the default
> (Peter Eisentraut, Jian He, Richard Guo, Dean Rasheed)
>
> Virtual generated columns generate their values when the columns are read, not written.
> The write behavior can still be specified via the STORED option.

Source:
- https://git.postgresql.org/gitweb/?p=postgresql.git;a=commitdiff;h=83ea6c540
- https://git.postgresql.org/gitweb/?p=postgresql.git;a=commitdiff;h=cdc168ad4
- https://git.postgresql.org/gitweb/?p=postgresql.git;a=commitdiff;h=1e4351af3

Co-authored-by: fatkodima <[email protected]>
yahonda added a commit to yahonda/rails that referenced this pull request Jun 9, 2025
PostgreSQL 18 Beta 1 introduces virtual (not persisted) generated columns,
which are now the default unless the STORED option is explicitly specified.

Rails previously supported only stored generated columns on PostgreSQL 12+,
via rails#41856, as only stored generated columns
were supported by PostgreSQL at the time.

This commit adds support for virtual generated columns on PostgreSQL 18 and later:

- `t.virtual ... stored: false` now generates virtual generated columns.
- Omitting `stored:` also creates virtual generated columns on PostgreSQL 18+.
- On PostgreSQL < 18, specifying `stored: false` or omitting `stored:` raises ArgumentError.
  consistent with the existing behavior in earlier Rails versions.

Reference: PostgreSQL 18 release notes
https://www.postgresql.org/docs/18/release-18.html

> Allow generated columns to be virtual, and make them the default
> (Peter Eisentraut, Jian He, Richard Guo, Dean Rasheed)
>
> Virtual generated columns generate their values when the columns are read, not written.
> The write behavior can still be specified via the STORED option.

Source:
- https://git.postgresql.org/gitweb/?p=postgresql.git;a=commitdiff;h=83ea6c540
- https://git.postgresql.org/gitweb/?p=postgresql.git;a=commitdiff;h=cdc168ad4
- https://git.postgresql.org/gitweb/?p=postgresql.git;a=commitdiff;h=1e4351af3

Co-authored-by: fatkodima <[email protected]>
yahonda added a commit to yahonda/rails that referenced this pull request Jun 10, 2025
PostgreSQL 18 Beta 1 introduces virtual (not persisted) generated columns,
which are now the default unless the STORED option is explicitly specified.

Rails previously supported only stored generated columns on PostgreSQL 12+,
via rails#41856, as only stored generated columns
were supported by PostgreSQL at the time.

This commit adds support for virtual generated columns on PostgreSQL 18 and later:

- `t.virtual ... stored: false` now generates virtual generated columns.
- Omitting `stored:` also creates virtual generated columns on PostgreSQL 18+.
- On PostgreSQL < 18, specifying `stored: false` or omitting `stored:` raises ArgumentError.
  consistent with the existing behavior in earlier Rails versions.

Reference: PostgreSQL 18 release notes
https://www.postgresql.org/docs/18/release-18.html

> Allow generated columns to be virtual, and make them the default
> (Peter Eisentraut, Jian He, Richard Guo, Dean Rasheed)
>
> Virtual generated columns generate their values when the columns are read, not written.
> The write behavior can still be specified via the STORED option.

Source:
- https://git.postgresql.org/gitweb/?p=postgresql.git;a=commitdiff;h=83ea6c540
- https://git.postgresql.org/gitweb/?p=postgresql.git;a=commitdiff;h=cdc168ad4
- https://git.postgresql.org/gitweb/?p=postgresql.git;a=commitdiff;h=1e4351af3

Co-authored-by: fatkodima <[email protected]>
Co-authored-by: Ryuta Kamizono <[email protected]>
yahonda added a commit to yahonda/rails that referenced this pull request Jun 11, 2025
PostgreSQL 18 Beta 1 introduces virtual (not persisted) generated columns,
which are now the default unless the STORED option is explicitly specified.

Rails previously supported only stored generated columns on PostgreSQL 12+,
via rails#41856, as only stored generated columns
were supported by PostgreSQL at the time.

This commit adds support for virtual generated columns on PostgreSQL 18 and later:

- `t.virtual ... stored: false` now generates virtual generated columns.
- Omitting `stored:` also creates virtual generated columns on PostgreSQL 18+.
- On PostgreSQL < 18, specifying `stored: false` or omitting `stored:` raises ArgumentError.
  consistent with the existing behavior in earlier Rails versions.

Reference: PostgreSQL 18 release notes
https://www.postgresql.org/docs/18/release-18.html

> Allow generated columns to be virtual, and make them the default
> (Peter Eisentraut, Jian He, Richard Guo, Dean Rasheed)
>
> Virtual generated columns generate their values when the columns are read, not written.
> The write behavior can still be specified via the STORED option.

Source:
- https://git.postgresql.org/gitweb/?p=postgresql.git;a=commitdiff;h=83ea6c540
- https://git.postgresql.org/gitweb/?p=postgresql.git;a=commitdiff;h=cdc168ad4
- https://git.postgresql.org/gitweb/?p=postgresql.git;a=commitdiff;h=1e4351af3

Co-authored-by: fatkodima <[email protected]>
Co-authored-by: Ryuta Kamizono <[email protected]>
yahonda added a commit to yahonda/rails that referenced this pull request Jun 12, 2025
PostgreSQL 18 Beta 1 introduces virtual (not persisted) generated columns,
which are now the default unless the STORED option is explicitly specified.

Rails previously supported only stored generated columns on PostgreSQL 12+,
via rails#41856, as only stored generated columns
were supported by PostgreSQL at the time.

This commit adds support for virtual generated columns on PostgreSQL 18 and later:

- `t.virtual ... stored: false` now generates virtual generated columns.
- Omitting `stored:` also creates virtual generated columns on PostgreSQL 18+.
- On PostgreSQL < 18, specifying `stored: false` or omitting `stored:` raises ArgumentError.
  consistent with the existing behavior in earlier Rails versions.

Reference: PostgreSQL 18 release notes
https://www.postgresql.org/docs/18/release-18.html

> Allow generated columns to be virtual, and make them the default
> (Peter Eisentraut, Jian He, Richard Guo, Dean Rasheed)
>
> Virtual generated columns generate their values when the columns are read, not written.
> The write behavior can still be specified via the STORED option.

Source:
- https://git.postgresql.org/gitweb/?p=postgresql.git;a=commitdiff;h=83ea6c540
- https://git.postgresql.org/gitweb/?p=postgresql.git;a=commitdiff;h=cdc168ad4
- https://git.postgresql.org/gitweb/?p=postgresql.git;a=commitdiff;h=1e4351af3

Co-authored-by: fatkodima <[email protected]>
Co-authored-by: Ryuta Kamizono <[email protected]>
ttilberg added a commit to ttilberg/activerecord-sqlserver-adapter that referenced this pull request Jun 23, 2025
yahonda added a commit to yahonda/rails that referenced this pull request Jun 26, 2025
PostgreSQL 18 Beta 1 introduces virtual (not persisted) generated columns,
which are now the default unless the STORED option is explicitly specified.

Rails previously supported only stored generated columns on PostgreSQL 12+,
via rails#41856, as only stored generated columns
were supported by PostgreSQL at the time.

This commit adds support for virtual generated columns on PostgreSQL 18 and later:

- `t.virtual ... stored: false` now generates virtual generated columns.
- Omitting `stored:` also creates virtual generated columns on PostgreSQL 18+.
- On PostgreSQL < 18, specifying `stored: false` or omitting `stored:` raises ArgumentError.
  consistent with the existing behavior in earlier Rails versions.

Reference: PostgreSQL 18 release notes
https://www.postgresql.org/docs/18/release-18.html

> Allow generated columns to be virtual, and make them the default
> (Peter Eisentraut, Jian He, Richard Guo, Dean Rasheed)
>
> Virtual generated columns generate their values when the columns are read, not written.
> The write behavior can still be specified via the STORED option.

Source:
- https://git.postgresql.org/gitweb/?p=postgresql.git;a=commitdiff;h=83ea6c540
- https://git.postgresql.org/gitweb/?p=postgresql.git;a=commitdiff;h=cdc168ad4
- https://git.postgresql.org/gitweb/?p=postgresql.git;a=commitdiff;h=1e4351af3

Co-authored-by: fatkodima <[email protected]>
Co-authored-by: Ryuta Kamizono <[email protected]>
yahonda added a commit to yahonda/rails that referenced this pull request Jul 3, 2025
PostgreSQL 18 Beta 1 introduces virtual (not persisted) generated columns,
which are now the default unless the STORED option is explicitly specified.

Rails previously supported only stored generated columns on PostgreSQL 12+,
via rails#41856, as only stored generated columns
were supported by PostgreSQL at the time.

This commit adds support for virtual generated columns on PostgreSQL 18 and later:

- `t.virtual ... stored: false` now generates virtual generated columns.
- Omitting `stored:` also creates virtual generated columns on PostgreSQL 18+.
- On PostgreSQL < 18, specifying `stored: false` or omitting `stored:` raises ArgumentError.
  consistent with the existing behavior in earlier Rails versions.

Reference: PostgreSQL 18 release notes
https://www.postgresql.org/docs/18/release-18.html

> Allow generated columns to be virtual, and make them the default
> (Peter Eisentraut, Jian He, Richard Guo, Dean Rasheed)
>
> Virtual generated columns generate their values when the columns are read, not written.
> The write behavior can still be specified via the STORED option.

Source:
- https://git.postgresql.org/gitweb/?p=postgresql.git;a=commitdiff;h=83ea6c540
- https://git.postgresql.org/gitweb/?p=postgresql.git;a=commitdiff;h=cdc168ad4
- https://git.postgresql.org/gitweb/?p=postgresql.git;a=commitdiff;h=1e4351af3

Co-authored-by: fatkodima <[email protected]>
Co-authored-by: Ryuta Kamizono <[email protected]>
yahonda added a commit to yahonda/rails that referenced this pull request Aug 15, 2025
PostgreSQL 18 Beta 1 introduces virtual (not persisted) generated columns,
which are now the default unless the STORED option is explicitly specified.

Rails previously supported only stored generated columns on PostgreSQL 12+,
via rails#41856, as only stored generated columns
were supported by PostgreSQL at the time.

This commit adds support for virtual generated columns on PostgreSQL 18 and later:

- `t.virtual ... stored: false` now generates virtual generated columns.
- Omitting `stored:` also creates virtual generated columns on PostgreSQL 18+.
- On PostgreSQL < 18, specifying `stored: false` or omitting `stored:` raises ArgumentError.
  consistent with the existing behavior in earlier Rails versions.

Reference: PostgreSQL 18 release notes
https://www.postgresql.org/docs/18/release-18.html

> Allow generated columns to be virtual, and make them the default
> (Peter Eisentraut, Jian He, Richard Guo, Dean Rasheed)
>
> Virtual generated columns generate their values when the columns are read, not written.
> The write behavior can still be specified via the STORED option.

Source:
- https://git.postgresql.org/gitweb/?p=postgresql.git;a=commitdiff;h=83ea6c540
- https://git.postgresql.org/gitweb/?p=postgresql.git;a=commitdiff;h=cdc168ad4
- https://git.postgresql.org/gitweb/?p=postgresql.git;a=commitdiff;h=1e4351af3

Co-authored-by: fatkodima <[email protected]>
Co-authored-by: Ryuta Kamizono <[email protected]>
yahonda added a commit to yahonda/rails that referenced this pull request Aug 23, 2025
PostgreSQL 18 Beta 1 introduces virtual (not persisted) generated columns,
which are now the default unless the STORED option is explicitly specified.

Rails previously supported only stored generated columns on PostgreSQL 12+,
via rails#41856, as only stored generated columns
were supported by PostgreSQL at the time.

This commit adds support for virtual generated columns on PostgreSQL 18 and later:

- `t.virtual ... stored: false` now generates virtual generated columns.
- Omitting `stored:` also creates virtual generated columns on PostgreSQL 18+.
- On PostgreSQL < 18, specifying `stored: false` or omitting `stored:` raises ArgumentError.
  consistent with the existing behavior in earlier Rails versions.

Reference: PostgreSQL 18 release notes
https://www.postgresql.org/docs/18/release-18.html

> Allow generated columns to be virtual, and make them the default
> (Peter Eisentraut, Jian He, Richard Guo, Dean Rasheed)
>
> Virtual generated columns generate their values when the columns are read, not written.
> The write behavior can still be specified via the STORED option.

Source:
- https://git.postgresql.org/gitweb/?p=postgresql.git;a=commitdiff;h=83ea6c540
- https://git.postgresql.org/gitweb/?p=postgresql.git;a=commitdiff;h=cdc168ad4
- https://git.postgresql.org/gitweb/?p=postgresql.git;a=commitdiff;h=1e4351af3

Co-authored-by: fatkodima <[email protected]>
Co-authored-by: Ryuta Kamizono <[email protected]>
yahonda added a commit to yahonda/rails that referenced this pull request Sep 2, 2025
PostgreSQL 18 Beta 1 introduces virtual (not persisted) generated columns,
which are now the default unless the STORED option is explicitly specified.

Rails previously supported only stored generated columns on PostgreSQL 12+,
via rails#41856, as only stored generated columns
were supported by PostgreSQL at the time.

This commit adds support for virtual generated columns on PostgreSQL 18 and later:

- `t.virtual ... stored: false` now generates virtual generated columns.
- Omitting `stored:` also creates virtual generated columns on PostgreSQL 18+.
- On PostgreSQL < 18, specifying `stored: false` or omitting `stored:` raises ArgumentError.
  consistent with the existing behavior in earlier Rails versions.

Reference: PostgreSQL 18 release notes
https://www.postgresql.org/docs/18/release-18.html

> Allow generated columns to be virtual, and make them the default
> (Peter Eisentraut, Jian He, Richard Guo, Dean Rasheed)
>
> Virtual generated columns generate their values when the columns are read, not written.
> The write behavior can still be specified via the STORED option.

Source:
- https://git.postgresql.org/gitweb/?p=postgresql.git;a=commitdiff;h=83ea6c540
- https://git.postgresql.org/gitweb/?p=postgresql.git;a=commitdiff;h=cdc168ad4
- https://git.postgresql.org/gitweb/?p=postgresql.git;a=commitdiff;h=1e4351af3

Co-authored-by: fatkodima <[email protected]>
Co-authored-by: Ryuta Kamizono <[email protected]>
yahonda added a commit to yahonda/rails that referenced this pull request Sep 9, 2025
PostgreSQL 18 Beta 1 introduces virtual (not persisted) generated columns,
which are now the default unless the STORED option is explicitly specified.

Rails previously supported only stored generated columns on PostgreSQL 12+,
via rails#41856, as only stored generated columns
were supported by PostgreSQL at the time.

This commit adds support for virtual generated columns on PostgreSQL 18 and later:

- `t.virtual ... stored: false` now generates virtual generated columns.
- Omitting `stored:` also creates virtual generated columns on PostgreSQL 18+.
- On PostgreSQL < 18, specifying `stored: false` or omitting `stored:` raises ArgumentError.
  consistent with the existing behavior in earlier Rails versions.

Reference: PostgreSQL 18 release notes
https://www.postgresql.org/docs/18/release-18.html

> Allow generated columns to be virtual, and make them the default
> (Peter Eisentraut, Jian He, Richard Guo, Dean Rasheed)
>
> Virtual generated columns generate their values when the columns are read, not written.
> The write behavior can still be specified via the STORED option.

Source:
- https://git.postgresql.org/gitweb/?p=postgresql.git;a=commitdiff;h=83ea6c540
- https://git.postgresql.org/gitweb/?p=postgresql.git;a=commitdiff;h=cdc168ad4
- https://git.postgresql.org/gitweb/?p=postgresql.git;a=commitdiff;h=1e4351af3

Co-authored-by: fatkodima <[email protected]>
Co-authored-by: Ryuta Kamizono <[email protected]>
yahonda added a commit to yahonda/rails that referenced this pull request Sep 24, 2025
PostgreSQL 18 Beta 1 introduces virtual (not persisted) generated columns,
which are now the default unless the STORED option is explicitly specified.

Rails previously supported only stored generated columns on PostgreSQL 12+,
via rails#41856, as only stored generated columns
were supported by PostgreSQL at the time.

This commit adds support for virtual generated columns on PostgreSQL 18 and later:

- `t.virtual ... stored: false` now generates virtual generated columns.
- Omitting `stored:` also creates virtual generated columns on PostgreSQL 18+.
- On PostgreSQL < 18, specifying `stored: false` or omitting `stored:` raises ArgumentError.
  consistent with the existing behavior in earlier Rails versions.

Reference: PostgreSQL 18 release notes
https://www.postgresql.org/docs/18/release-18.html

> Allow generated columns to be virtual, and make them the default
> (Peter Eisentraut, Jian He, Richard Guo, Dean Rasheed)
>
> Virtual generated columns generate their values when the columns are read, not written.
> The write behavior can still be specified via the STORED option.

Source:
- https://git.postgresql.org/gitweb/?p=postgresql.git;a=commitdiff;h=83ea6c540
- https://git.postgresql.org/gitweb/?p=postgresql.git;a=commitdiff;h=cdc168ad4
- https://git.postgresql.org/gitweb/?p=postgresql.git;a=commitdiff;h=1e4351af3

Co-authored-by: fatkodima <[email protected]>
Co-authored-by: Ryuta Kamizono <[email protected]>
yahonda added a commit to yahonda/rails that referenced this pull request Sep 26, 2025
PostgreSQL 18 Beta 1 introduces virtual (not persisted) generated columns,
which are now the default unless the STORED option is explicitly specified.

Rails previously supported only stored generated columns on PostgreSQL 12+,
via rails#41856, as only stored generated columns
were supported by PostgreSQL at the time.

This commit adds support for virtual generated columns on PostgreSQL 18 and later:

- `t.virtual ... stored: false` now generates virtual generated columns.
- Omitting `stored:` also creates virtual generated columns on PostgreSQL 18+.
- On PostgreSQL < 18, specifying `stored: false` or omitting `stored:` raises ArgumentError.
  consistent with the existing behavior in earlier Rails versions.

Reference: PostgreSQL 18 release notes
https://www.postgresql.org/docs/18/release-18.html

> Allow generated columns to be virtual, and make them the default
> (Peter Eisentraut, Jian He, Richard Guo, Dean Rasheed)
>
> Virtual generated columns generate their values when the columns are read, not written.
> The write behavior can still be specified via the STORED option.

Source:
- https://git.postgresql.org/gitweb/?p=postgresql.git;a=commitdiff;h=83ea6c540
- https://git.postgresql.org/gitweb/?p=postgresql.git;a=commitdiff;h=cdc168ad4
- https://git.postgresql.org/gitweb/?p=postgresql.git;a=commitdiff;h=1e4351af3

Co-authored-by: fatkodima <[email protected]>
Co-authored-by: Ryuta Kamizono <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

8 participants