-
Notifications
You must be signed in to change notification settings - Fork 28
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add support for virtual columns (#163)
One of these changes was support for [virtual/generated columns](https://guides.rubyonrails.org/active_record_postgresql.html#generated-columns). At the moment, the following table would create a slightly confusing annotation ```ruby create_table :users do |t| t.string :name t.virtual :name_upcased, type: :string, as: "upper(name)", stored: true end ``` ```ruby # Table name: users # # name :string # name_upcased :string class User < ApplicationRecord ``` With these changes, this would generate the following: ```ruby # Table name: users # # name :string # name_upcased :virtual(string) class User < ApplicationRecord ``` I wasn't a 100% sure where you'd want these changes exactly. I'm happy to make further changes, or add some more tests. One additional change could be to also place the function in the annotation, but this would maybe better in a further PR. I've tried this in the past and noticed that it can become unwieldy once the function becomes more complicated ```ruby # Table name: users # # name. :string # name_upcased :virtual(string) upcase(name) class User < ApplicationRecord ``` --------- Co-authored-by: Andrew W. Lee <[email protected]>
- Loading branch information
Showing
6 changed files
with
59 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters