4

Add support for generated columns in PostgreSQL (Redux) by MSNexploder · Pull Re...

 2 years ago
source link: https://github.com/rails/rails/pull/41856
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.

New issue

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

Conversation

Copy link

Contributor

MSNexploder commented on Apr 6

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.

if options[:stored]

sql << " STORED"

else

raise ArgumentError, <<~MSG

Copy link

Contributor

Author

@MSNexploder MSNexploder on Apr 6

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

force-pushed the virtual-columns

branch 3 times, most recently from 6e1b337 to 4233c97 5 months ago

MSNexploder

force-pushed the virtual-columns

branch 2 times, most recently from 89d5577 to 249e327 5 months ago

Copy link

Contributor

fschwahn commented on Jul 14

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

Copy link

Contributor

luizkowalski commented 3 days ago

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

Copy link

Member

matthewd commented 2 days ago

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).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

No reviews

Assignees

No one assigned

Projects

None yet

Milestone

No milestone

Linked issues

Successfully merging this pull request may close these issues.

None yet

5 participants

About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK