Skip to content

Virtual columns support with types #95

Closed
wants to merge 10 commits into from

2 participants

@mkurkov
mkurkov commented Aug 30, 2011

Hi!
I have implemented virtual columns support with new syntax, as we discussed.

Main changes:

  • Virtual column definition goes to :as option instead of :default
  • It is possible to explicitly state type of column via :type option, you could use symbol (like :integer) or string (like "VARCHAR(100)") for native types, :precision, :limit and :scale should work as expected too. One minor consequence of this is that types are always explicitly stated in schema.rb, even if migration was without :type option. It seems to be impossible to distinguish this cases from raw data.
  • Added add_column and change_column migration helpers with support of virtual columns, it respects same options - :as and :type.
  • It is possible to change only type of virtual column if change_column was called without change_option.
  • I also decided to set defaults to nil for virtual columns (it was 0 for integer in previous version, but return definition for string columns).

For tests I have been using Oracle 11 XE (it is now accesible from oracle site as beta), also it works as expected in our current project on Oracle 11, both on 64-bit linux.

@rsim
Owner
rsim commented Aug 30, 2011

I am just thinking that probably it would be good also to check for :default option if :as option is not provided. I would like to include these patches in next 1.4.1 release of adapter and it would be good that in patch releases API is backwards compatible. Is there any other incompatibility with previous version of virtual column support?

@mkurkov
mkurkov commented Aug 31, 2011

I added support for :default option in create_table statement, I think this is the only backward incompatibilty, the other one is minor and merely a bug - in previous version if I didn't save record, virtual column was returning 0 if it was integer, and returned column expression if it was string. Now it return nil in both cases.
Also I didn't add support of :default in other migration helpers, as they was not present in previous version. I added warn message if deprecated option is used, see is it ok with your lib conventions.

@mkurkov
mkurkov commented Aug 31, 2011

Silly bug that was rarely ocuring - only after several sequential database dumps with column_cache = true.

I will be spending my vacation for the next two weeks, so I apologize in advance for the possible delays in responses.

@mkurkov mkurkov closed this Apr 17, 2012
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.