Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

rails4: merges commits done at master branch into rails4 branch #251

Merged
merged 23 commits into from

7 participants

Yasuo Honda Billy Reisinger Benjamin Ortega Tomas Varneckas Edgars Beigarts Ankit Dhingra Toshinori Kajihara
Yasuo Honda
Collaborator

This pull request merges several commits which had been done at master branch, into rails4 branch.

Conflict resolutions

  • 1 lib/active_record/connection_adapters/oracle_enhanced_base_ext.rb

This file has been removed in rails4 branch at

  • 9369d15 "Initial support for ActiveRecord 4. Dropping support for older versions."

Several changes done with 3fad716c0132af0e833b2da26738642500326408 are
merged to lib/active_record/connection_adapters/oracle_enhanced_model.rb

  • 2 lib/active_record/connection_adapters/oracle_enhanced_schema_statements.rb

These two commits at master branch conflict with 166bcb2

Two commits at master branch

  • 305283a "Remove_column should raise an ArgumentError when no columns are passed"

  • 38e7b72 "Fix broken column remove inside a change_table block."

A commit at rails4 branch

  • 166bcb2 "Support refactored remove_column"

  • 3 spec/active_record/connection_adapters/oracle_enhanced_schema_dump_spec.rb

This commit done at master branch conflict with rails4.

  • e35a4a0 "Fix pending specs on Oracle 10g properly"
Yasuo Honda
Collaborator

Thanks!

ebeigarts and others added some commits
Edgars Beigarts ebeigarts Release 1.4.2.rc1 c80560a
Yasuo Honda yahonda Remove_column should raise an ArgumentError when no columns are passed 305283a
Yasuo Honda yahonda Address 2 failues since numeric_changes_from_zero_to_string? method i…
…mplemented at Rails.
9b65f00
Yasuo Honda yahonda Address test_integer_zero_to_integer_zero_not_marked_as_changed failure
See rails issue #7237.
8d838f4
Yasuo Honda yahonda Merge pull request #246 from yahonda/remove_column_should_have_columns
Remove_column should raise an ArgumentError when no columns are passed
6fd6f20
Yasuo Honda yahonda Merge pull request #247 from yahonda/numeric_column_changes_v142
Address numeric column changes failures
2ba2b90
Toshinori Kajihara kennyj Fix rails issue 6819. a5b4dbf
Yasuo Honda yahonda Address 2 failures since c460117 merged. 2781f04
Yasuo Honda yahonda Merge pull request #248 from yahonda/rails6819_v142
Address schema dumper test failure
dd4eafa
Yasuo Honda yahonda Merge branch 'master' into rails4_merges_master
Conflicts:
	lib/active_record/connection_adapters/oracle_enhanced_base_ext.rb
	lib/active_record/connection_adapters/oracle_enhanced_schema_statements.rb
	spec/active_record/connection_adapters/oracle_enhanced_schema_dump_spec.rb

Conflict resolutions

  #1 lib/active_record/connection_adapters/oracle_enhanced_base_ext.rb

  This file has been removed in rails4 branch at 9369d15
  "Initial support for ActiveRecord 4. Dropping support for older versions."

  Several changes done with 3fad716c0132af0e833b2da26738642500326408 are
  merged to `lib/active_record/connection_adapters/oracle_enhanced_model.rb`

  #2 lib/active_record/connection_adapters/oracle_enhanced_schema_statements.rb

  These two commits at master branch conflict with 166bcb2

  -- Two commits at master branch
  305283a
  "Remove_column should raise an ArgumentError when no columns are passed"

  38e7b72
  "Fix broken column remove inside a change_table block."

  -- A commit at rails4 branch
  166bcb2
  "Support refactored remove_column"

  #3 spec/active_record/connection_adapters/oracle_enhanced_schema_dump_spec.rb

  This commit done at master branch conflict with rails4.
  e35a4a0
  "Fix pending specs on Oracle 10g properly"
3ae8245
Yasuo Honda
Collaborator

This pull request/commits has been created as follows.

  • checkout current rails4 branch
    git checkout rails4

  • create a topic branch to merge
    git checkout -b rails4_merges_master

  • merges master branch commits into rails4_merges_master branch
    git merge master

  • push rails4_merges_master to origin at github
    git push origin rails4_merges_master

This pull request works except for #250 and rails/rails#7334. Second one already exist before this merge.

Yasuo Honda yahonda merged commit c23332f into from
Yasuo Honda yahonda deleted the branch
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Aug 27, 2012
  1. Billy Reisinger

    Dump indexes on virtual columns using the column's name instead of th…

    unclebilly authored
    …e column expression, such that a test clone does not result in ORA-54018.
  2. Benjamin Ortega Billy Reisinger
Commits on Sep 12, 2012
  1. Tomas Varneckas
Commits on Sep 13, 2012
  1. Yasuo Honda

    Merge pull request #216 from tomasv/master

    yahonda authored
    Fix broken column remove in change_table block
Commits on Oct 1, 2012
  1. Yasuo Honda

    Merge pull request #211 from govdelivery/virt_col_index

    yahonda authored
    Index support for virtual columns
  2. Edgars Beigarts

    Merge pull request #212 from govdelivery/lob_write_caching2

    ebeigarts authored
    don't update lobs that haven't changed or are attr_readonly
Commits on Oct 29, 2012
  1. Ankit Dhingra

    Update README.md

    ankitdhingra authored
    The require 'activerecord' was not working for me, on searching I found the solution
    here http://stackoverflow.com/questions/8981576/error-loading-active-record-gem-with-sinatra-app-using-rvm
    I have proposed the changes for the same.
Commits on Oct 31, 2012
  1. Edgars Beigarts

    Support dirty tracking with rails 3.2.9.rc1

    ebeigarts authored
    Starting with rails 3.2.9.rc1 the method #field_changed?
    was renamed to #_field_changed?
    
    rails/rails#3544
  2. Edgars Beigarts

    Merge pull request #237 from ankitdhingra/patch-1

    ebeigarts authored
    Update README.md
  3. Edgars Beigarts
  4. Edgars Beigarts
  5. Edgars Beigarts
Commits on Nov 6, 2012
  1. Edgars Beigarts

    Update History.md

    ebeigarts authored
Commits on Nov 13, 2012
  1. Edgars Beigarts

    Release 1.4.2.rc1

    ebeigarts authored
  2. Yasuo Honda
  3. Yasuo Honda
  4. Yasuo Honda
  5. Yasuo Honda

    Merge pull request #246 from yahonda/remove_column_should_have_columns

    yahonda authored
    Remove_column should raise an ArgumentError when no columns are passed
  6. Yasuo Honda

    Merge pull request #247 from yahonda/numeric_column_changes_v142

    yahonda authored
    Address numeric column changes failures
  7. Toshinori Kajihara Yasuo Honda

    Fix rails issue 6819.

    kennyj authored yahonda committed
  8. Yasuo Honda
  9. Yasuo Honda

    Merge pull request #248 from yahonda/rails6819_v142

    yahonda authored
    Address schema dumper test failure
Commits on Nov 20, 2012
  1. Yasuo Honda

    Merge branch 'master' into rails4_merges_master

    yahonda authored
    Conflicts:
    	lib/active_record/connection_adapters/oracle_enhanced_base_ext.rb
    	lib/active_record/connection_adapters/oracle_enhanced_schema_statements.rb
    	spec/active_record/connection_adapters/oracle_enhanced_schema_dump_spec.rb
    
    Conflict resolutions
    
      #1 lib/active_record/connection_adapters/oracle_enhanced_base_ext.rb
    
      This file has been removed in rails4 branch at 9369d15
      "Initial support for ActiveRecord 4. Dropping support for older versions."
    
      Several changes done with 3fad716c0132af0e833b2da26738642500326408 are
      merged to `lib/active_record/connection_adapters/oracle_enhanced_model.rb`
    
      #2 lib/active_record/connection_adapters/oracle_enhanced_schema_statements.rb
    
      These two commits at master branch conflict with 166bcb2
    
      -- Two commits at master branch
      305283a
      "Remove_column should raise an ArgumentError when no columns are passed"
    
      38e7b72
      "Fix broken column remove inside a change_table block."
    
      -- A commit at rails4 branch
      166bcb2
      "Support refactored remove_column"
    
      #3 spec/active_record/connection_adapters/oracle_enhanced_schema_dump_spec.rb
    
      This commit done at master branch conflict with rails4.
      e35a4a0
      "Fix pending specs on Oracle 10g properly"
This page is out of date. Refresh to see the latest.
17 History.md
View
@@ -1,4 +1,19 @@
-### 1.4.1 / 2011-01-27
+### 1.4.2.rc1 / 2012-11-13
+
+* Enhancements:
+ * Wordlist option for context index [#154]
+ * Fall back to directly connecting via OracleDriver on JRuby [#163]
+ * Allow slash-prefixed database name in database.yml for using a service [#201]
+* Bug fixes:
+ * Fixed explain plans to work with JDBC and OCI8 [#146]
+ * Fixed various issues with virtual columns [#159]
+ * Fixed SQL structure dump with function indexes [#161]
+ * Fixed broken column remove inside a change_table block [#216]
+ * Dump indexes on virtual columns using the column's name instead of the column expression [#211]
+ * Don't update lobs that haven't changed or are attr_readonly [#212]
+ * Support dirty tracking with rails 3.2.9
+
+### 1.4.1 / 2012-01-27
* Enhancements:
* Support for Rails 3.2
5 README.md
View
@@ -302,9 +302,6 @@ For example it can be used to force foreign key constraint on polymorphic associ
add_foreign_key :comments, :photos, :column => :subject_photo_id
add_foreign_key :comments, :events, :column => :subject_event_id
-In the current adapter version it is not possible to set index on virtual column, because it is not correctly dumped to schema.rb.
-This restriction will be removed in the future version.
-
For backward compatibility reasons it is possible to use `:default` option in the `create_table` instead of `:as` option.
But this is deprecated and may be removed in the future version.
@@ -344,7 +341,7 @@ Please verify that
require 'rubygems'
gem 'activerecord'
gem 'activerecord-oracle_enhanced-adapter'
- require 'activerecord'
+ require 'active_record'
ActiveRecord::Base.establish_connection(:adapter => "oracle_enhanced", :database => "database",:username => "user",:password => "password")
and see if it is successful (use your correct database, username and password)
13 Rakefile
View
@@ -33,6 +33,19 @@ RSpec::Core::RakeTask.new(:rcov) do |t|
t.rcov_opts = ['--exclude', '/Library,spec/']
end
+desc "Clear test database"
+task :clear do
+ require "./spec/spec_helper"
+ ActiveRecord::Base.establish_connection(CONNECTION_PARAMS)
+ require "active_support/core_ext"
+ ActiveRecord::Base.connection.execute_structure_dump(ActiveRecord::Base.connection.full_drop)
+ ActiveRecord::Base.connection.execute("PURGE RECYCLEBIN") rescue nil
+end
+
+# Clear test database before running spec and rcov
+task :spec => :clear
+task :rcov => :clear
+
task :default => :spec
require 'rdoc/task'
2  VERSION
View
@@ -1 +1 @@
-1.4.1
+1.4.2.rc1
4 activerecord-oracle_enhanced-adapter.gemspec
View
@@ -5,11 +5,11 @@
Gem::Specification.new do |s|
s.name = %q{activerecord-oracle_enhanced-adapter}
- s.version = "1.4.1"
+ s.version = "1.4.2.rc1"
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
s.authors = [%q{Raimonds Simanovskis}]
- s.date = %q{2012-01-27}
+ s.date = %q{2012-11-13}
s.description = %q{Oracle "enhanced" ActiveRecord adapter contains useful additional methods for working with new and legacy Oracle databases.
This adapter is superset of original ActiveRecord Oracle adapter.
}
24 lib/active_record/connection_adapters/oracle_enhanced_adapter.rb
View
@@ -890,12 +890,12 @@ def insert_fixture(fixture, table_name) #:nodoc:
klass = klass.constantize rescue nil
if klass.respond_to?(:ancestors) && klass.ancestors.include?(ActiveRecord::Base)
- write_lobs(table_name, klass, fixture)
+ write_lobs(table_name, klass, fixture, klass.lob_columns)
end
end
- # Writes LOB values from attributes, as indicated by the LOB columns of klass.
- def write_lobs(table_name, klass, attributes) #:nodoc:
+ # Writes LOB values from attributes for specified columns
+ def write_lobs(table_name, klass, attributes, columns) #:nodoc:
# is class with composite primary key>
is_with_cpk = klass.respond_to?(:composite?) && klass.composite?
if is_with_cpk
@@ -903,7 +903,7 @@ def write_lobs(table_name, klass, attributes) #:nodoc:
else
id = quote(attributes[klass.primary_key])
end
- klass.columns.select { |col| col.sql_type =~ /LOB$/i }.each do |col|
+ columns.each do |col|
value = attributes[col.name]
# changed sequence of next two lines - should check if value is nil before converting to yaml
next if value.nil? || (value == '')
@@ -965,11 +965,14 @@ def indexes(table_name, name = nil) #:nodoc:
SELECT LOWER(i.table_name) AS table_name, LOWER(i.index_name) AS index_name, i.uniqueness,
i.index_type, i.ityp_owner, i.ityp_name, i.parameters,
LOWER(i.tablespace_name) AS tablespace_name,
- LOWER(c.column_name) AS column_name, e.column_expression
+ LOWER(c.column_name) AS column_name, e.column_expression,
+ atc.virtual_column
FROM all_indexes#{db_link} i
JOIN all_ind_columns#{db_link} c ON c.index_name = i.index_name AND c.index_owner = i.owner
LEFT OUTER JOIN all_ind_expressions#{db_link} e ON e.index_name = i.index_name AND
e.index_owner = i.owner AND e.column_position = c.column_position
+ LEFT OUTER JOIN all_tab_cols#{db_link} atc ON i.table_name = atc.table_name AND
+ c.column_name = atc.column_name AND i.owner = atc.owner AND atc.hidden_column = 'NO'
WHERE i.owner = '#{owner}'
AND i.table_owner = '#{owner}'
AND NOT EXISTS (SELECT uc.index_name FROM all_constraints uc
@@ -1004,7 +1007,16 @@ def indexes(table_name, name = nil) #:nodoc:
row['tablespace_name'] == default_tablespace_name ? nil : row['tablespace_name'], [])
current_index = row['index_name']
end
- all_schema_indexes.last.columns << (row['column_expression'] || row['column_name'].downcase)
+
+ # Functional index columns and virtual columns both get stored as column expressions,
+ # but re-creating a virtual column index as an expression (instead of using the virtual column's name)
+ # results in a ORA-54018 error. Thus, we only want the column expression value returned
+ # when the column is not virtual.
+ if row['column_expression'] && row['virtual_column'] != 'YES'
+ all_schema_indexes.last.columns << row['column_expression']
+ else
+ all_schema_indexes.last.columns << row['column_name'].downcase
+ end
end
end
4 lib/active_record/connection_adapters/oracle_enhanced_column.rb
View
@@ -26,6 +26,10 @@ def virtual?
@virtual
end
+ def lob?
+ self.sql_type =~ /LOB$/i
+ end
+
# convert something to a boolean
# added y as boolean value
def self.value_to_boolean(value) #:nodoc:
5 lib/active_record/connection_adapters/oracle_enhanced_dirty.rb
View
@@ -37,5 +37,10 @@ def _field_changed?(attr, old, value)
if ActiveRecord::Base.method_defined?(:changed?)
ActiveRecord::Base.class_eval do
include ActiveRecord::ConnectionAdapters::OracleEnhancedDirty::InstanceMethods
+ # Starting with rails 3.2.9 the method #field_changed?
+ # was renamed to #_field_changed?
+ if private_method_defined?(:field_changed?)
+ alias_method :field_changed?, :_field_changed?
+ end
end
end
25 lib/active_record/connection_adapters/oracle_enhanced_model.rb
View
@@ -51,6 +51,12 @@ def table_comment
connection.table_comment(self.table_name)
end
+ def lob_columns
+ columns.select do |column|
+ column.respond_to?(:lob?) && column.lob?
+ end
+ end
+
def virtual_columns
columns.select do |column|
column.respond_to?(:virtual?) && column.virtual?
@@ -71,16 +77,23 @@ def arel_attributes_with_values(attribute_names)
private
+ def record_changed_lobs
+ @changed_lob_columns = self.class.lob_columns.select{|col| self.send(:"#{col.name}_changed?") && !self.class.readonly_attributes.to_a.include?(col.name)}
+ end
+
# After setting large objects to empty, select the OCI8::LOB
# and write back the data.
def update
- super
if connection.is_a?(ConnectionAdapters::OracleEnhancedAdapter) &&
- !(
- (self.class.respond_to?(:custom_create_method) && self.class.custom_create_method) ||
- (self.class.respond_to?(:custom_update_method) && self.class.custom_update_method)
- )
- connection.write_lobs(self.class.table_name, self.class, attributes)
+ !(
+ (self.class.respond_to?(:custom_create_method) && self.class.custom_create_method) ||
+ (self.class.respond_to?(:custom_update_method) && self.class.custom_update_method)
+ )
+ record_changed_lobs
+ super
+ connection.write_lobs(self.class.table_name, self.class, attributes, @changed_lob_columns || self.class.lob_columns)
+ else
+ super
end
end
end
BIN  lib/ojdbc6.jar
View
Binary file not shown
24 spec/active_record/connection_adapters/oracle_enhanced_data_types_spec.rb
View
@@ -917,6 +917,14 @@ class ::TestEmployee < ActiveRecord::Base; end
class ::Test2Employee < ActiveRecord::Base
serialize :comments
end
+ class ::TestEmployeeReadOnlyClob < ActiveRecord::Base
+ if self.respond_to?(:table_name=)
+ self.table_name = "test_employees"
+ else
+ set_table_name = "test_employees"
+ end
+ attr_readonly :comments
+ end
end
after(:all) do
@@ -926,6 +934,7 @@ class ::Test2Employee < ActiveRecord::Base
@conn.execute "DROP SEQUENCE test2_employees_seq"
Object.send(:remove_const, "TestEmployee")
Object.send(:remove_const, "Test2Employee")
+ Object.send(:remove_const, "TestEmployeeReadOnlyClob")
ActiveRecord::Base.clear_cache! if ActiveRecord::Base.respond_to?(:"clear_cache!")
end
@@ -944,6 +953,21 @@ class ::Test2Employee < ActiveRecord::Base
@employee.should be_valid
end
+ it "should respect attr_readonly setting for CLOB column" do
+ @employee = TestEmployeeReadOnlyClob.create!(
+ :first_name => "First",
+ :comments => "initial"
+ )
+ @employee.should be_valid
+ @employee.reload
+ @employee.comments.should == 'initial'
+ @employee.comments = "changed"
+ @employee.save.should == true
+ @employee.reload
+ @employee.comments.should == 'initial'
+ end
+
+
it "should create record with CLOB data" do
@employee = TestEmployee.create!(
:first_name => "First",
18 spec/active_record/connection_adapters/oracle_enhanced_dirty_spec.rb
View
@@ -118,6 +118,24 @@ class TestEmployee < ActiveRecord::Base
@employee.should_not be_changed
end
+ it "should not update unchanged CLOBs" do
+ @employee = TestEmployee.create!(
+ :comments => "initial"
+ )
+ @employee.save!.should be_true
+ @employee.reload
+ @employee.comments.should == 'initial'
+
+ oci_conn = @conn.instance_variable_get('@connection')
+ class << oci_conn
+ def write_lob(lob, value, is_binary = false); raise "don't do this'"; end
+ end
+ @employee.save!.should_not raise_exception(RuntimeError, "don't do this'")
+ class << oci_conn
+ remove_method :write_lob
+ end
+ end
+
end
end
62 spec/active_record/connection_adapters/oracle_enhanced_schema_dump_spec.rb
View
@@ -347,33 +347,40 @@ def drop_test_posts_table
describe 'virtual columns' do
before(:all) do
- pending "Not supported in this database version" unless @oracle11g
- schema_define do
- create_table :test_names, force: true do |t|
- t.string :first_name
- t.string :last_name
- t.virtual :full_name, as: "first_name || ', ' || last_name"
- t.virtual :short_name, as: "COALESCE(first_name, last_name)", type: :string, limit: 300
- t.virtual :abbrev_name, as: "SUBSTR(first_name,1,50) || ' ' || SUBSTR(last_name,1,1) || '.'", type: "VARCHAR(100)"
- t.column :full_name_length, :virtual, as: "length(first_name || ', ' || last_name)", type: :integer
- t.virtual :field_with_leading_space, as: "' ' || first_name || ' '", limit: 300, type: :string
+ if @oracle11g
+ schema_define do
+ create_table :test_names, :force => true do |t|
+ t.string :first_name
+ t.string :last_name
+ t.virtual :full_name, :as => "first_name || ', ' || last_name"
+ t.virtual :short_name, :as => "COALESCE(first_name, last_name)", :type => :string, :limit => 300
+ t.virtual :abbrev_name, :as => "SUBSTR(first_name,1,50) || ' ' || SUBSTR(last_name,1,1) || '.'", :type => "VARCHAR(100)"
+ t.column :full_name_length, :virtual, :as => "length(first_name || ', ' || last_name)", :type => :integer
+ t.virtual :field_with_leading_space, :as => "' ' || first_name || ' '", :limit => 300, :type => :string
+ end
end
+ else
+ pending "Not supported in this database version"
end
end
before(:each) do
- class ::TestName < ActiveRecord::Base
- if self.respond_to?(:table_name=)
- self.table_name = "test_names"
- else
- set_table_name "test_names"
+ if @oracle11g
+ class ::TestName < ActiveRecord::Base
+ if self.respond_to?(:table_name=)
+ self.table_name = "test_names"
+ else
+ set_table_name "test_names"
+ end
end
end
end
after(:all) do
- schema_define do
- drop_table :test_names
+ if @oracle11g
+ schema_define do
+ drop_table :test_names
+ end
end
end
@@ -405,6 +412,27 @@ class ::TestName < ActiveRecord::Base
col.virtual_column_data_default.should_not =~ /:as/
end
end
+
+ context "with index on virtual column" do
+ before(:all) do
+ if @oracle11g
+ schema_define do
+ add_index 'test_names', 'field_with_leading_space', :name => "index_on_virtual_col"
+ end
+ end
+ end
+ after(:all) do
+ if @oracle11g
+ schema_define do
+ remove_index 'test_names', :name => 'index_on_virtual_col'
+ end
+ end
+ end
+ it 'should dump correctly' do
+ standard_dump.should_not =~ /add_index "test_names".+FIRST_NAME.+$/
+ standard_dump.should =~ /add_index "test_names".+field_with_leading_space.+$/
+ end
+ end
end
end
34 spec/active_record/connection_adapters/oracle_enhanced_schema_statements_spec.rb
View
@@ -931,6 +931,7 @@ class ::TestPost < ActiveRecord::Base
schema_define do
create_table :test_posts, :force => true do |t|
t.string :title, :null => false
+ t.string :content
end
end
class ::TestPost < ActiveRecord::Base; end
@@ -992,10 +993,30 @@ class ::TestPost < ActiveRecord::Base; end
TestPost.columns_hash['title'].should be_nil
end
+ it "should remove column when using change_table" do
+ schema_define do
+ change_table :test_posts do |t|
+ t.remove :title
+ end
+ end
+ TestPost.reset_column_information
+ TestPost.columns_hash['title'].should be_nil
+ end
+
+ it "should remove multiple columns when using change_table" do
+ schema_define do
+ change_table :test_posts do |t|
+ t.remove :title, :content
+ end
+ end
+ TestPost.reset_column_information
+ TestPost.columns_hash['title'].should be_nil
+ TestPost.columns_hash['content'].should be_nil
+ end
end
describe 'virtual columns in create_table' do
- before(:all) do
+ before(:each) do
pending "Not supported in this database version" unless @oracle11g
end
@@ -1045,11 +1066,8 @@ class ::TestFraction < ActiveRecord::Base
end
describe 'virtual columns' do
- before(:all) do
- pending "Not supported in this database version" unless @oracle11g
- end
-
before(:each) do
+ pending "Not supported in this database version" unless @oracle11g
expr = "( numerator/NULLIF(denominator,0) )*100"
schema_define do
create_table :test_fractions, :force => true do |t|
@@ -1069,8 +1087,10 @@ class ::TestFraction < ActiveRecord::Base
end
after(:each) do
- schema_define do
- drop_table :test_fractions
+ if @oracle11g
+ schema_define do
+ drop_table :test_fractions
+ end
end
end
Something went wrong with that request. Please try again.