activerecord-oracle_enhanced-adapter 1.6.2 → 1.6.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/History.md +9 -0
- data/VERSION +1 -1
- data/activerecord-oracle_enhanced-adapter.gemspec +2 -2
- data/lib/active_record/connection_adapters/oracle_enhanced/database_statements.rb +10 -7
- data/lib/active_record/connection_adapters/oracle_enhanced/schema_statements.rb +1 -4
- data/lib/active_record/connection_adapters/oracle_enhanced_adapter.rb +1 -1
- data/spec/active_record/connection_adapters/oracle_enhanced_adapter_spec.rb +56 -0
- data/spec/active_record/connection_adapters/oracle_enhanced_data_types_spec.rb +14 -0
- data/spec/active_record/connection_adapters/oracle_enhanced_schema_statements_spec.rb +2 -2
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: eef5dc051a873b8dc75975b556a46a45427f32b0
|
4
|
+
data.tar.gz: b81fefccb9c78bebadde53adc41a5a45746b2637
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 94c87c4500eee69bd24870ebb1306866c85cb6351d38a44d18d1a67660ab022cd39bdcd3905ccd35b4567b6ec16bcb14efce849717a4284ac9117df9d1aa458f
|
7
|
+
data.tar.gz: 504cc8085f6ab6114b7bec94a4363ebdad91e557e601ef9ee9c5242bf674cc567674dea2bc604c0ced037066d6236776d42e69285aff7ece680e2f1e34af00ec
|
data/History.md
CHANGED
@@ -1,3 +1,12 @@
|
|
1
|
+
## 1.6.3 / 2015-08-14
|
2
|
+
|
3
|
+
* Changes and bug fixes since 1.6.2
|
4
|
+
* Set sequence name automatically when new table name is longer than 26 bytes[#676]
|
5
|
+
* Add minimal specs for ActiveRecord::Base.limit() and .order()[#679]
|
6
|
+
* Use type_casted_binds [#681]
|
7
|
+
* Use type_cast_for_database to serialize correctly [#688]
|
8
|
+
* Suppress deprecated message for serialized_attributes [#688, #548, #687]
|
9
|
+
|
1
10
|
## 1.6.2 / 2015-07-20
|
2
11
|
|
3
12
|
* Changes and bug fixes since 1.6.1
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
1.6.
|
1
|
+
1.6.3
|
@@ -5,12 +5,12 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = %q{activerecord-oracle_enhanced-adapter}
|
8
|
-
s.version = "1.6.
|
8
|
+
s.version = "1.6.3"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.license = 'MIT'
|
12
12
|
s.authors = [%q{Raimonds Simanovskis}]
|
13
|
-
s.date = %q{2015-
|
13
|
+
s.date = %q{2015-08-14}
|
14
14
|
s.description = %q{Oracle "enhanced" ActiveRecord adapter contains useful additional methods for working with new and legacy Oracle databases.
|
15
15
|
This adapter is superset of original ActiveRecord Oracle adapter.
|
16
16
|
}
|
@@ -32,9 +32,9 @@ module ActiveRecord
|
|
32
32
|
|
33
33
|
cursor = @statements[sql]
|
34
34
|
|
35
|
-
|
35
|
+
type_casted_binds.each_with_index do |bind, i|
|
36
36
|
col, val = bind
|
37
|
-
cursor.bind_param(i + 1,
|
37
|
+
cursor.bind_param(i + 1, val, col)
|
38
38
|
end
|
39
39
|
|
40
40
|
cached = true
|
@@ -129,14 +129,14 @@ module ActiveRecord
|
|
129
129
|
|
130
130
|
cursor = @statements[sql]
|
131
131
|
|
132
|
-
|
132
|
+
type_casted_binds.each_with_index do |bind, i|
|
133
133
|
col, val = bind
|
134
134
|
if col.returning_id?
|
135
135
|
returning_id_col = [col]
|
136
136
|
returning_id_index = i + 1
|
137
137
|
cursor.bind_returning_param(returning_id_index, Integer)
|
138
138
|
else
|
139
|
-
cursor.bind_param(i + 1,
|
139
|
+
cursor.bind_param(i + 1, val, col)
|
140
140
|
end
|
141
141
|
end
|
142
142
|
end
|
@@ -154,7 +154,10 @@ module ActiveRecord
|
|
154
154
|
|
155
155
|
# New method in ActiveRecord 3.1
|
156
156
|
def exec_update(sql, name, binds)
|
157
|
-
|
157
|
+
type_casted_binds = binds.map { |col, val|
|
158
|
+
[col, type_cast(val, col)]
|
159
|
+
}
|
160
|
+
log(sql, name, type_casted_binds) do
|
158
161
|
cached = false
|
159
162
|
if without_prepared_statement?(binds)
|
160
163
|
cursor = @connection.prepare(sql)
|
@@ -165,9 +168,9 @@ module ActiveRecord
|
|
165
168
|
@statements[sql] = @connection.prepare(sql)
|
166
169
|
end
|
167
170
|
|
168
|
-
|
171
|
+
type_casted_binds.each_with_index do |bind, i|
|
169
172
|
col, val = bind
|
170
|
-
cursor.bind_param(i + 1,
|
173
|
+
cursor.bind_param(i + 1, val, col)
|
171
174
|
end
|
172
175
|
cached = true
|
173
176
|
end
|
@@ -103,11 +103,8 @@ module ActiveRecord
|
|
103
103
|
if new_name.to_s.length > table_name_length
|
104
104
|
raise ArgumentError, "New table name '#{new_name}' is too long; the limit is #{table_name_length} characters"
|
105
105
|
end
|
106
|
-
if "#{new_name}_seq".to_s.length > sequence_name_length
|
107
|
-
raise ArgumentError, "New sequence name '#{new_name}_seq' is too long; the limit is #{sequence_name_length} characters"
|
108
|
-
end
|
109
106
|
execute "RENAME #{quote_table_name(table_name)} TO #{quote_table_name(new_name)}"
|
110
|
-
execute "RENAME #{quote_table_name("#{table_name}_seq")} TO #{
|
107
|
+
execute "RENAME #{quote_table_name("#{table_name}_seq")} TO #{default_sequence_name(new_name)}" rescue nil
|
111
108
|
|
112
109
|
rename_table_indexes(table_name, new_name)
|
113
110
|
end
|
@@ -826,7 +826,7 @@ module ActiveRecord
|
|
826
826
|
value = attributes[col.name]
|
827
827
|
# changed sequence of next two lines - should check if value is nil before converting to yaml
|
828
828
|
next if value.nil? || (value == '')
|
829
|
-
value =
|
829
|
+
value = col.cast_type.type_cast_for_database(value)
|
830
830
|
uncached do
|
831
831
|
sql = is_with_cpk ? "SELECT #{quote_column_name(col.name)} FROM #{quote_table_name(table_name)} WHERE #{klass.composite_where_clause(id)} FOR UPDATE" :
|
832
832
|
"SELECT #{quote_column_name(col.name)} FROM #{quote_table_name(table_name)} WHERE #{quote_column_name(klass.primary_key)} = #{id} FOR UPDATE"
|
@@ -689,4 +689,60 @@ describe "OracleEnhancedAdapter" do
|
|
689
689
|
explain.should include("INDEX UNIQUE SCAN")
|
690
690
|
end
|
691
691
|
end if ENV['RAILS_GEM_VERSION'] >= '3.2'
|
692
|
+
|
693
|
+
describe "using offset and limit" do
|
694
|
+
before(:all) do
|
695
|
+
@conn = ActiveRecord::Base.connection
|
696
|
+
@conn.execute "DROP TABLE test_employees" rescue nil
|
697
|
+
@conn.execute <<-SQL
|
698
|
+
CREATE TABLE test_employees (
|
699
|
+
id NUMBER PRIMARY KEY,
|
700
|
+
sort_order NUMBER(38,0),
|
701
|
+
first_name VARCHAR2(20),
|
702
|
+
last_name VARCHAR2(25),
|
703
|
+
updated_at DATE,
|
704
|
+
created_at DATE
|
705
|
+
)
|
706
|
+
SQL
|
707
|
+
@conn.execute "DROP SEQUENCE test_employees_seq" rescue nil
|
708
|
+
@conn.execute <<-SQL
|
709
|
+
CREATE SEQUENCE test_employees_seq MINVALUE 1
|
710
|
+
INCREMENT BY 1 START WITH 1 CACHE 20 NOORDER NOCYCLE
|
711
|
+
SQL
|
712
|
+
@employee = Class.new(ActiveRecord::Base) do
|
713
|
+
self.table_name = :test_employees
|
714
|
+
end
|
715
|
+
i = 0
|
716
|
+
@employee.create!(sort_order: i+=1, first_name: 'Peter', last_name: 'Parker')
|
717
|
+
@employee.create!(sort_order: i+=1, first_name: 'Tony', last_name: 'Stark')
|
718
|
+
@employee.create!(sort_order: i+=1, first_name: 'Steven', last_name: 'Rogers')
|
719
|
+
@employee.create!(sort_order: i+=1, first_name: 'Bruce', last_name: 'Banner')
|
720
|
+
@employee.create!(sort_order: i+=1, first_name: 'Natasha', last_name: 'Romanova')
|
721
|
+
end
|
722
|
+
|
723
|
+
after(:all) do
|
724
|
+
@conn.execute "DROP TABLE test_employees"
|
725
|
+
@conn.execute "DROP SEQUENCE test_employees_seq"
|
726
|
+
end
|
727
|
+
|
728
|
+
after(:each) do
|
729
|
+
ActiveRecord::Base.connection.clear_ignored_table_columns
|
730
|
+
ActiveRecord::Base.clear_cache! if ActiveRecord::Base.respond_to?(:"clear_cache!")
|
731
|
+
end
|
732
|
+
|
733
|
+
it "should return n records with limit(n)" do
|
734
|
+
@employee.limit(3).to_a.size.should be(3)
|
735
|
+
end
|
736
|
+
|
737
|
+
it "should return less than n records with limit(n) if there exist less than n records" do
|
738
|
+
@employee.limit(10).to_a.size.should be(5)
|
739
|
+
end
|
740
|
+
|
741
|
+
it "should return the records starting from offset n with offset(n)" do
|
742
|
+
expect(@employee.order(:sort_order).first.first_name.should).to eq("Peter")
|
743
|
+
expect(@employee.order(:sort_order).offset(0).first.first_name.should).to eq("Peter")
|
744
|
+
expect(@employee.order(:sort_order).offset(1).first.first_name.should).to eq("Tony")
|
745
|
+
expect(@employee.order(:sort_order).offset(4).first.first_name.should).to eq("Natasha")
|
746
|
+
end
|
747
|
+
end
|
692
748
|
end
|
@@ -1076,6 +1076,20 @@ describe "OracleEnhancedAdapter handling of CLOB columns" do
|
|
1076
1076
|
@employee.comments.should == @char_data
|
1077
1077
|
end
|
1078
1078
|
|
1079
|
+
it "should store serializable ruby data structures" do
|
1080
|
+
ruby_data1 = {"arbitrary1" => ["ruby", :data, 123]}
|
1081
|
+
ruby_data2 = {"arbitrary2" => ["ruby", :data, 123]}
|
1082
|
+
@employee = Test2Employee.create!(
|
1083
|
+
:comments => ruby_data1
|
1084
|
+
)
|
1085
|
+
@employee.reload
|
1086
|
+
@employee.comments.should == ruby_data1
|
1087
|
+
@employee.comments = ruby_data2
|
1088
|
+
@employee.save
|
1089
|
+
@employee.reload
|
1090
|
+
@employee.comments.should == ruby_data2
|
1091
|
+
end
|
1092
|
+
|
1079
1093
|
it "should keep unchanged serialized data when other columns changed" do
|
1080
1094
|
@employee = Test2Employee.create!(
|
1081
1095
|
:first_name => "First",
|
@@ -438,10 +438,10 @@ describe "OracleEnhancedAdapter schema definition" do
|
|
438
438
|
end.should raise_error
|
439
439
|
end
|
440
440
|
|
441
|
-
it "should raise error when new sequence name length is too long" do
|
441
|
+
it "should not raise error when new sequence name length is too long" do
|
442
442
|
lambda do
|
443
443
|
@conn.rename_table("test_employees","a"*27)
|
444
|
-
end.
|
444
|
+
end.should_not raise_error
|
445
445
|
end
|
446
446
|
|
447
447
|
it "should rename table when table has no primary key and sequence" do
|
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.6.
|
4
|
+
version: 1.6.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Raimonds Simanovskis
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-
|
11
|
+
date: 2015-08-14 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: jeweler
|