activerecord-oracle_enhanced-adapter 1.7.3 → 1.7.4

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 8d1b4bd554898d5bc0e1eb9d5d5ee7d234132c11
4
- data.tar.gz: 96f3480896225af451693db4d8eb4554e3ad2ab9
3
+ metadata.gz: 124c0346c9616607a37e143f3cd4dcbd8a6413d5
4
+ data.tar.gz: 23188503c1dcf33c756b3f2d9eff3e858505b21b
5
5
  SHA512:
6
- metadata.gz: ee52bda6c519c796a33671a46e0f15ed64e138c20212977e22cae620e1ac98d825d9091de20314fc58db1beca058671cc5eb6aa6c62e2d8f3fba47575b3c073d
7
- data.tar.gz: a8851fbdf4b8fdac1faf736f7e4be8a086ec7ad84ad94764c7c635b9a0b8bab0bbcd2f1dc1a00a937e6673ec1dca5143efc617c8daddc038526ed680ff29f572
6
+ metadata.gz: 7f87365212531e4c7e038977482a7a879dd105711444b690881856f1a85485c2d8654d21235045b6bf455bd6199db1d90ac89d55239c1cdc0b4e39461c4198aa
7
+ data.tar.gz: ceaad6ba9776513ad0faaf760eb7c9fde8f0d0ff0db712f93bbe989437c183688eaecc9d453d1d91d2b59345320e395854aea07b0ab13db6e899af8aaaf70846
data/Gemfile CHANGED
@@ -2,12 +2,12 @@ source 'http://rubygems.org'
2
2
 
3
3
  group :development do
4
4
  gem 'rspec', '~> 3.3'
5
- gem 'rdoc'
5
+ gem 'rdoc', '~> 5.0.0.beta2'
6
6
  gem 'rake'
7
7
 
8
8
  gem 'activerecord', github: 'rails/rails', branch: '5-0-stable'
9
9
  gem 'rack', github: 'rack/rack', branch: 'master'
10
- gem 'arel', github: 'rails/arel', branch: 'master'
10
+ gem 'arel', github: 'rails/arel', branch: '7-1-stable'
11
11
 
12
12
  gem 'ruby-plsql', '>=0.5.0'
13
13
 
data/History.md CHANGED
@@ -1,3 +1,25 @@
1
+ ## 1.7.4 / 2016-10-14
2
+
3
+ * Changes and bug fixes
4
+
5
+ * Bump Arel 7.1.4 or higher [#1010, #848, #946]
6
+ * NoMethodError: undefined method `write' for nil:NilClass for serialized column [#798, #1007]
7
+ * Quote table name in disable_referential_integrity [#1012, #1014]
8
+ * Rails 5 : undefined method `to_i' for #<Arel::Nodes::BindParam:0x00000002c92910> [#848, rails/arel#438, rails/arel#450]
9
+ * Add UPGRADE section : Upgrade Rails 4.2 or older version to Rails 5 [#1011, #993]
10
+ * add docker to RUNNING_TEST.md [#1006]
11
+ * Add executable test cases using Minitest or RSpec [#1002]
12
+
13
+ * Known issues
14
+
15
+ - Only with JRuby
16
+ * Rails 5 : explain should explain query with binds got Java::JavaSql::SQLException: Invalid column index [#908]
17
+ * Workaround: execute explain without bind or use CRuby
18
+ - CRuby and JRuby
19
+ * Rails 5 : custom methods for create record when exception is raised in after_create callback fails [#944]
20
+ * Rails 5 : specs need update to emulate_booleans_from_strings [#942]
21
+ * #998 causes regression for `TIMESTAMP WITH LOCAL TIME ZONE` [#1001]
22
+
1
23
  ## 1.7.3 / 2016-10-03
2
24
 
3
25
  * Changes and bug fixes
data/README.md CHANGED
@@ -619,6 +619,30 @@ development:
619
619
  )"
620
620
  ```
621
621
 
622
+ UPGRADE
623
+ ---------------
624
+ ### Upgrade Rails 4.2 or older version to Rails 5
625
+
626
+ If your Oracle table columns have been created for Rails `:datetime` attributes in Rails 4.2 or earlier,
627
+ they need to migrate to `:datetime` in Rails 5 using one of two following ways:
628
+
629
+ * Rails migration code example:
630
+ ```ruby
631
+ change_column :posts, :created_at, :datetime
632
+ change_column :posts, :updated_at, :datetime
633
+ ```
634
+
635
+ or
636
+
637
+ * SQL statement example
638
+ ```sql
639
+ ALTER TABLE "POSTS" MODIFY "CREATED_AT" TIMESTAMP
640
+ ALTER TABLE "POSTS" MODIFY "UPDATED_AT" TIMESTAMP
641
+ ```
642
+
643
+ In Rails 5 without running this migration or sql statement,
644
+ these attributes will be handled as Rails `:date` type.
645
+
622
646
  TROUBLESHOOTING
623
647
  ---------------
624
648
 
@@ -13,6 +13,39 @@ If you are getting ORA-12520 errors when running tests then it means that Oracle
13
13
 
14
14
  to increase process limit and then restart the database (this will be necessary if Oracle XE will be used as default processes limit is 40).
15
15
 
16
+ ### Docker
17
+ If no Oracle database with SYS and SYSTEM user access is available, try the docker approach.
18
+
19
+ Install [Docker](https://docker.github.io/engine/installation/)
20
+
21
+ Pull [docker-oracle-xe-11g](https://hub.docker.com/r/wnameless/oracle-xe-11g/) image from docker hub
22
+
23
+ docker pull wnameless/oracle-xe-11g
24
+
25
+ Start a Oracle database docker container with mapped ports. Use port `49161` to access the database.
26
+
27
+ docker run -d -p 49160:22 -p 49161:1521 wnameless/oracle-xe-11g
28
+
29
+ Check connection to the database with `sqlplus`. The user is `system`, the password is `oracle`.
30
+
31
+ sqlplus64 system/oracle@localhost:49161
32
+
33
+ The oracle enhanced configuration file `spec/spec_config.yaml` should look like:
34
+
35
+ ```yaml
36
+ # copy this file to spec/config.yaml and set appropriate values
37
+ # you can also use environment variables, see spec_helper.rb
38
+ database:
39
+ name: 'xe'
40
+ host: 'localhost'
41
+ port: 49161
42
+ user: 'oracle_enhanced'
43
+ password: 'oracle_enhanced'
44
+ sys_password: 'oracle'
45
+ non_default_tablespace: 'SYSTEM'
46
+ timezone: 'Europe/Riga'
47
+ ```
48
+
16
49
  Ruby versions
17
50
  -------------
18
51
 
@@ -40,7 +73,7 @@ Running tests
40
73
  * Install necessary gems with
41
74
 
42
75
  bundle install
43
-
76
+
44
77
  * Configure database credentials in one of two ways:
45
78
  * copy spec/spec_config.yaml.template to spec/config.yaml and modify as needed
46
79
  * set required environment variables (see DATABASE_NAME in spec_helper.rb)
data/VERSION CHANGED
@@ -1 +1 @@
1
- 1.7.3
1
+ 1.7.4
@@ -1,12 +1,12 @@
1
1
  Gem::Specification.new do |s|
2
2
  s.name = %q{activerecord-oracle_enhanced-adapter}
3
- s.version = "1.7.3"
3
+ s.version = "1.7.4"
4
4
 
5
5
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
6
6
  s.required_ruby_version = '>= 2.2.2'
7
7
  s.license = 'MIT'
8
8
  s.authors = [%q{Raimonds Simanovskis}]
9
- s.date = %q{2016-10-03}
9
+ s.date = %q{2016-10-14}
10
10
  s.description = %q{Oracle "enhanced" ActiveRecord adapter contains useful additional methods for working with new and legacy Oracle databases.
11
11
  This adapter is superset of original ActiveRecord Oracle adapter.
12
12
  }
@@ -88,7 +88,7 @@ This adapter is superset of original ActiveRecord Oracle adapter.
88
88
  "spec/spec_helper.rb"
89
89
  ]
90
90
  s.add_runtime_dependency(%q<activerecord>, ["~> 5.0.0"])
91
- s.add_runtime_dependency(%q<arel>, ["~> 7.1.0"])
91
+ s.add_runtime_dependency(%q<arel>, ["~> 7.1.4"])
92
92
  s.add_runtime_dependency(%q<ruby-plsql>, [">= 0.5.0"])
93
93
  s.license = 'MIT'
94
94
  end
@@ -434,12 +434,12 @@ module ActiveRecord
434
434
  old_constraints = select_all(sql_constraints)
435
435
  begin
436
436
  old_constraints.each do |constraint|
437
- execute "ALTER TABLE #{constraint["table_name"]} DISABLE CONSTRAINT #{constraint["constraint_name"]}"
437
+ execute "ALTER TABLE #{quote_table_name(constraint["table_name"])} DISABLE CONSTRAINT #{quote_table_name(constraint["constraint_name"])}"
438
438
  end
439
439
  yield
440
440
  ensure
441
441
  old_constraints.each do |constraint|
442
- execute "ALTER TABLE #{constraint["table_name"]} ENABLE CONSTRAINT #{constraint["constraint_name"]}"
442
+ execute "ALTER TABLE #{quote_table_name(constraint["table_name"])} ENABLE CONSTRAINT #{quote_table_name(constraint["constraint_name"])}"
443
443
  end
444
444
  end
445
445
  end
@@ -700,7 +700,7 @@ module ActiveRecord
700
700
  columns.each do |col|
701
701
  value = attributes[col.name]
702
702
  # changed sequence of next two lines - should check if value is nil before converting to yaml
703
- next if value.nil? || (value == '')
703
+ next if value.blank?
704
704
  if klass.attribute_types[col.name].is_a? ActiveRecord::Type::Serialized
705
705
  value = klass.attribute_types[col.name].serialize(value)
706
706
  end
@@ -960,8 +960,8 @@ module ActiveRecord
960
960
  @@do_not_prefetch_primary_key[table_name] = nil
961
961
 
962
962
  table_cols = <<-SQL.strip.gsub(/\s+/, ' ')
963
- SELECT cols.column_name AS name, cols.data_type AS sql_type,
964
- cols.data_default, cols.nullable, cols.virtual_column, cols.hidden_column,
963
+ SELECT cols.column_name AS name, cols.data_type AS sql_type,
964
+ cols.data_default, cols.nullable, cols.virtual_column, cols.hidden_column,
965
965
  cols.data_type_owner AS sql_type_owner,
966
966
  DECODE(cols.data_type, 'NUMBER', data_precision,
967
967
  'FLOAT', data_precision,
@@ -30,7 +30,7 @@ describe "OracleEnhancedAdapter establish connection" do
30
30
  ActiveRecord::Base.connection.reconnect!
31
31
  expect(ActiveRecord::Base.connection).to be_active
32
32
  end
33
-
33
+
34
34
  end
35
35
 
36
36
  describe "OracleEnhancedAdapter" do
@@ -40,7 +40,7 @@ describe "OracleEnhancedAdapter" do
40
40
  before(:all) do
41
41
  ActiveRecord::Base.establish_connection(CONNECTION_PARAMS)
42
42
  end
43
-
43
+
44
44
  describe "ignore specified table columns" do
45
45
  before(:all) do
46
46
  @conn = ActiveRecord::Base.connection
@@ -377,19 +377,19 @@ describe "OracleEnhancedAdapter" do
377
377
  expect(@adapter.valid_table_name?("aBc")).to be_falsey
378
378
  expect(@adapter.valid_table_name?("abC")).to be_falsey
379
379
  end
380
-
380
+
381
381
  it "should not be valid for names > 30 characters" do
382
382
  expect(@adapter.valid_table_name?("a" * 31)).to be_falsey
383
383
  end
384
-
384
+
385
385
  it "should not be valid for schema names > 30 characters" do
386
386
  expect(@adapter.valid_table_name?(("a" * 31) + ".validname")).to be_falsey
387
387
  end
388
-
388
+
389
389
  it "should not be valid for database links > 128 characters" do
390
390
  expect(@adapter.valid_table_name?("name@" + "a" * 129)).to be_falsey
391
391
  end
392
-
392
+
393
393
  it "should not be valid for names that do not begin with alphabetic characters" do
394
394
  expect(@adapter.valid_table_name?("1abc")).to be_falsey
395
395
  expect(@adapter.valid_table_name?("_abc")).to be_falsey
@@ -457,7 +457,7 @@ describe "OracleEnhancedAdapter" do
457
457
 
458
458
  cc = CamelCase.create!(:name => "Foo", :foo => 2)
459
459
  expect(cc.id).not_to be_nil
460
-
460
+
461
461
  expect(@conn.tables).to include("CamelCase")
462
462
  end
463
463
 
@@ -719,8 +719,6 @@ describe "OracleEnhancedAdapter" do
719
719
  @employee.create!(sort_order: i+=1, first_name: 'Steven', last_name: 'Rogers')
720
720
  @employee.create!(sort_order: i+=1, first_name: 'Bruce', last_name: 'Banner')
721
721
  @employee.create!(sort_order: i+=1, first_name: 'Natasha', last_name: 'Romanova')
722
- @oracle11g_or_lower = !! @conn.select_value(
723
- "select * from product_component_version where product like 'Oracle%' and to_number(substr(version,1,2)) <= 11")
724
722
  end
725
723
 
726
724
  after(:all) do
@@ -742,7 +740,6 @@ describe "OracleEnhancedAdapter" do
742
740
  end
743
741
 
744
742
  it "should return the records starting from offset n with offset(n)" do
745
- skip "Skipped until #848 or rails/arel#438 resolved " if @oracle11g_or_lower
746
743
  expect(@employee.order(:sort_order).first.first_name).to eq("Peter")
747
744
  expect(@employee.order(:sort_order).offset(0).first.first_name).to eq("Peter")
748
745
  expect(@employee.order(:sort_order).offset(1).first.first_name).to eq("Tony")
@@ -773,4 +770,50 @@ describe "OracleEnhancedAdapter" do
773
770
  expect(@conn.valid_type?(:foobar)).to be false
774
771
  end
775
772
  end
773
+
774
+ describe 'serialized column' do
775
+ before(:all) do
776
+ schema_define do
777
+ create_table :test_serialized_columns do |t|
778
+ t.text :serialized
779
+ end
780
+ end
781
+ class ::TestSerializedColumn < ActiveRecord::Base
782
+ serialize :serialized, Array
783
+ end
784
+ end
785
+
786
+ after(:all) do
787
+ schema_define do
788
+ drop_table :test_serialized_columns
789
+ end
790
+ Object.send(:remove_const, 'TestSerializedColumn')
791
+ ActiveRecord::Base.table_name_prefix = nil
792
+ ActiveRecord::Base.clear_cache! if ActiveRecord::Base.respond_to?(:"clear_cache!")
793
+ end
794
+
795
+ before(:each) do
796
+ set_logger
797
+ end
798
+
799
+ after(:each) do
800
+ clear_logger
801
+ end
802
+
803
+ it 'should serialize' do
804
+ new_value = 'new_value'
805
+ serialized_column = TestSerializedColumn.new
806
+
807
+ expect(serialized_column.serialized).to eq([])
808
+ serialized_column.serialized << new_value
809
+ expect(serialized_column.serialized).to eq([new_value])
810
+ serialized_column.save
811
+ expect(serialized_column.save!).to eq(true)
812
+
813
+ serialized_column.reload
814
+ expect(serialized_column.serialized).to eq([new_value])
815
+ serialized_column.serialized = []
816
+ expect(serialized_column.save!).to eq(true)
817
+ end
818
+ end
776
819
  end
@@ -917,11 +917,16 @@ end
917
917
  t.string :body, :limit => 4000
918
918
  t.references :test_post, :foreign_key => true
919
919
  end
920
+ create_table "test_Mixed_Comments", :force => true do |t|
921
+ t.string :body, :limit => 4000
922
+ t.references :test_post, :foreign_key => true
923
+ end
920
924
  end
921
925
  end
922
926
 
923
927
  after(:each) do
924
928
  schema_define do
929
+ drop_table "test_Mixed_Comments" rescue nil
925
930
  drop_table :test_comments rescue nil
926
931
  drop_table :test_posts rescue nil
927
932
  end
@@ -933,6 +938,7 @@ end
933
938
  end.to raise_error(ActiveRecord::InvalidForeignKey)
934
939
  @conn.disable_referential_integrity do
935
940
  expect do
941
+ @conn.execute "INSERT INTO \"test_Mixed_Comments\" (id, body, test_post_id) VALUES (2, 'test', 2)"
936
942
  @conn.execute "INSERT INTO test_comments (id, body, test_post_id) VALUES (2, 'test', 2)"
937
943
  @conn.execute "INSERT INTO test_posts (id, title) VALUES (2, 'test')"
938
944
  end.not_to raise_error
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: activerecord-oracle_enhanced-adapter
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.7.3
4
+ version: 1.7.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Raimonds Simanovskis
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-10-03 00:00:00.000000000 Z
11
+ date: 2016-10-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activerecord
@@ -30,14 +30,14 @@ dependencies:
30
30
  requirements:
31
31
  - - "~>"
32
32
  - !ruby/object:Gem::Version
33
- version: 7.1.0
33
+ version: 7.1.4
34
34
  type: :runtime
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
38
  - - "~>"
39
39
  - !ruby/object:Gem::Version
40
- version: 7.1.0
40
+ version: 7.1.4
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: ruby-plsql
43
43
  requirement: !ruby/object:Gem::Requirement
@@ -133,7 +133,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
133
133
  version: '0'
134
134
  requirements: []
135
135
  rubyforge_project:
136
- rubygems_version: 2.5.1
136
+ rubygems_version: 2.6.6
137
137
  signing_key:
138
138
  specification_version: 4
139
139
  summary: Oracle enhanced adapter for ActiveRecord