activerecord-oracle_enhanced-adapter 1.4.3 → 5.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/History.md +1162 -2
- data/README.md +567 -155
- data/VERSION +1 -1
- data/lib/active_record/connection_adapters/emulation/oracle_adapter.rb +3 -1
- data/lib/active_record/connection_adapters/oracle_enhanced/column.rb +19 -0
- data/lib/active_record/connection_adapters/oracle_enhanced/connection.rb +132 -0
- data/lib/active_record/connection_adapters/oracle_enhanced/context_index.rb +345 -0
- data/lib/active_record/connection_adapters/oracle_enhanced/database_limits.rb +52 -0
- data/lib/active_record/connection_adapters/oracle_enhanced/database_statements.rb +280 -0
- data/lib/active_record/connection_adapters/oracle_enhanced/database_tasks.rb +64 -0
- data/lib/active_record/connection_adapters/oracle_enhanced/dbms_output.rb +59 -0
- data/lib/active_record/connection_adapters/oracle_enhanced/jdbc_connection.rb +538 -0
- data/lib/active_record/connection_adapters/oracle_enhanced/jdbc_quoting.rb +38 -0
- data/lib/active_record/connection_adapters/oracle_enhanced/lob.rb +46 -0
- data/lib/active_record/connection_adapters/oracle_enhanced/oci_connection.rb +435 -0
- data/lib/active_record/connection_adapters/oracle_enhanced/oci_quoting.rb +44 -0
- data/lib/active_record/connection_adapters/oracle_enhanced/procedures.rb +196 -0
- data/lib/active_record/connection_adapters/oracle_enhanced/quoting.rb +164 -0
- data/lib/active_record/connection_adapters/oracle_enhanced/schema_creation.rb +95 -0
- data/lib/active_record/connection_adapters/oracle_enhanced/schema_definitions.rb +79 -0
- data/lib/active_record/connection_adapters/oracle_enhanced/schema_dumper.rb +194 -0
- data/lib/active_record/connection_adapters/oracle_enhanced/schema_statements.rb +709 -0
- data/lib/active_record/connection_adapters/oracle_enhanced/schema_statements_ext.rb +28 -0
- data/lib/active_record/connection_adapters/oracle_enhanced/structure_dump.rb +353 -0
- data/lib/active_record/connection_adapters/oracle_enhanced/type_metadata.rb +33 -0
- data/lib/active_record/connection_adapters/oracle_enhanced/version.rb +3 -0
- data/lib/active_record/connection_adapters/oracle_enhanced_adapter.rb +385 -1083
- data/lib/active_record/type/oracle_enhanced/boolean.rb +20 -0
- data/lib/active_record/type/oracle_enhanced/integer.rb +15 -0
- data/lib/active_record/type/oracle_enhanced/json.rb +10 -0
- data/lib/active_record/type/oracle_enhanced/national_character_string.rb +26 -0
- data/lib/active_record/type/oracle_enhanced/national_character_text.rb +36 -0
- data/lib/active_record/type/oracle_enhanced/raw.rb +25 -0
- data/lib/active_record/type/oracle_enhanced/string.rb +29 -0
- data/lib/active_record/type/oracle_enhanced/text.rb +32 -0
- data/lib/active_record/type/oracle_enhanced/timestampltz.rb +25 -0
- data/lib/active_record/type/oracle_enhanced/timestamptz.rb +25 -0
- data/lib/activerecord-oracle_enhanced-adapter.rb +5 -13
- data/spec/active_record/connection_adapters/{oracle_enhanced_emulate_oracle_adapter_spec.rb → emulation/oracle_adapter_spec.rb} +5 -4
- data/spec/active_record/connection_adapters/oracle_enhanced/connection_spec.rb +469 -0
- data/spec/active_record/connection_adapters/{oracle_enhanced_context_index_spec.rb → oracle_enhanced/context_index_spec.rb} +140 -128
- data/spec/active_record/connection_adapters/oracle_enhanced/database_tasks_spec.rb +112 -0
- data/spec/active_record/connection_adapters/{oracle_enhanced_dbms_output_spec.rb → oracle_enhanced/dbms_output_spec.rb} +13 -13
- data/spec/active_record/connection_adapters/oracle_enhanced/procedures_spec.rb +365 -0
- data/spec/active_record/connection_adapters/oracle_enhanced/quoting_spec.rb +196 -0
- data/spec/active_record/connection_adapters/oracle_enhanced/schema_dumper_spec.rb +492 -0
- data/spec/active_record/connection_adapters/oracle_enhanced/schema_statements_spec.rb +1433 -0
- data/spec/active_record/connection_adapters/oracle_enhanced/structure_dump_spec.rb +478 -0
- data/spec/active_record/connection_adapters/oracle_enhanced_adapter_spec.rb +385 -550
- data/spec/active_record/connection_adapters/oracle_enhanced_data_types_spec.rb +92 -1249
- data/spec/active_record/oracle_enhanced/type/binary_spec.rb +119 -0
- data/spec/active_record/oracle_enhanced/type/boolean_spec.rb +208 -0
- data/spec/active_record/oracle_enhanced/type/dirty_spec.rb +139 -0
- data/spec/active_record/oracle_enhanced/type/float_spec.rb +48 -0
- data/spec/active_record/oracle_enhanced/type/integer_spec.rb +91 -0
- data/spec/active_record/oracle_enhanced/type/json_spec.rb +57 -0
- data/spec/active_record/oracle_enhanced/type/national_character_string_spec.rb +55 -0
- data/spec/active_record/oracle_enhanced/type/national_character_text_spec.rb +230 -0
- data/spec/active_record/oracle_enhanced/type/raw_spec.rb +122 -0
- data/spec/active_record/oracle_enhanced/type/text_spec.rb +229 -0
- data/spec/active_record/oracle_enhanced/type/timestamp_spec.rb +75 -0
- data/spec/spec_config.yaml.template +11 -0
- data/spec/spec_helper.rb +100 -93
- data/spec/support/alter_system_set_open_cursors.sql +1 -0
- data/spec/support/alter_system_user_password.sql +2 -0
- data/spec/support/create_oracle_enhanced_users.sql +31 -0
- metadata +105 -152
- data/.rspec +0 -2
- data/Gemfile +0 -52
- data/RUNNING_TESTS.md +0 -45
- data/Rakefile +0 -59
- data/activerecord-oracle_enhanced-adapter.gemspec +0 -130
- data/lib/active_record/connection_adapters/oracle_enhanced.rake +0 -105
- data/lib/active_record/connection_adapters/oracle_enhanced_activerecord_patches.rb +0 -41
- data/lib/active_record/connection_adapters/oracle_enhanced_base_ext.rb +0 -121
- data/lib/active_record/connection_adapters/oracle_enhanced_column.rb +0 -151
- data/lib/active_record/connection_adapters/oracle_enhanced_connection.rb +0 -119
- data/lib/active_record/connection_adapters/oracle_enhanced_context_index.rb +0 -359
- data/lib/active_record/connection_adapters/oracle_enhanced_core_ext.rb +0 -25
- data/lib/active_record/connection_adapters/oracle_enhanced_cpk.rb +0 -21
- data/lib/active_record/connection_adapters/oracle_enhanced_dirty.rb +0 -46
- data/lib/active_record/connection_adapters/oracle_enhanced_jdbc_connection.rb +0 -572
- data/lib/active_record/connection_adapters/oracle_enhanced_oci_connection.rb +0 -497
- data/lib/active_record/connection_adapters/oracle_enhanced_procedures.rb +0 -260
- data/lib/active_record/connection_adapters/oracle_enhanced_schema_definitions.rb +0 -227
- data/lib/active_record/connection_adapters/oracle_enhanced_schema_dumper.rb +0 -260
- data/lib/active_record/connection_adapters/oracle_enhanced_schema_statements.rb +0 -428
- data/lib/active_record/connection_adapters/oracle_enhanced_schema_statements_ext.rb +0 -258
- data/lib/active_record/connection_adapters/oracle_enhanced_structure_dump.rb +0 -294
- data/lib/active_record/connection_adapters/oracle_enhanced_tasks.rb +0 -17
- data/lib/active_record/connection_adapters/oracle_enhanced_version.rb +0 -1
- data/spec/active_record/connection_adapters/oracle_enhanced_connection_spec.rb +0 -334
- data/spec/active_record/connection_adapters/oracle_enhanced_core_ext_spec.rb +0 -19
- data/spec/active_record/connection_adapters/oracle_enhanced_cpk_spec.rb +0 -113
- data/spec/active_record/connection_adapters/oracle_enhanced_dirty_spec.rb +0 -141
- data/spec/active_record/connection_adapters/oracle_enhanced_procedures_spec.rb +0 -378
- data/spec/active_record/connection_adapters/oracle_enhanced_schema_dump_spec.rb +0 -440
- data/spec/active_record/connection_adapters/oracle_enhanced_schema_statements_spec.rb +0 -1400
- data/spec/active_record/connection_adapters/oracle_enhanced_structure_dump_spec.rb +0 -339
@@ -1,339 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
describe "OracleEnhancedAdapter structure dump" do
|
4
|
-
include LoggerSpecHelper
|
5
|
-
|
6
|
-
before(:all) do
|
7
|
-
ActiveRecord::Base.establish_connection(CONNECTION_PARAMS)
|
8
|
-
@conn = ActiveRecord::Base.connection
|
9
|
-
@oracle11g = !! @conn.select_value("SELECT * FROM v$version WHERE banner LIKE 'Oracle%11g%'")
|
10
|
-
end
|
11
|
-
describe "structure dump" do
|
12
|
-
before(:each) do
|
13
|
-
@conn.create_table :test_posts, :force => true do |t|
|
14
|
-
t.string :title
|
15
|
-
t.string :foo
|
16
|
-
t.integer :foo_id
|
17
|
-
end
|
18
|
-
@conn.create_table :foos do |t|
|
19
|
-
end
|
20
|
-
class ::TestPost < ActiveRecord::Base
|
21
|
-
end
|
22
|
-
if TestPost.respond_to?(:table_name=)
|
23
|
-
TestPost.table_name = "test_posts"
|
24
|
-
else
|
25
|
-
TestPost.set_table_name "test_posts"
|
26
|
-
end
|
27
|
-
end
|
28
|
-
|
29
|
-
after(:each) do
|
30
|
-
@conn.drop_table :test_posts
|
31
|
-
@conn.drop_table :foos
|
32
|
-
@conn.execute "DROP SEQUENCE test_posts_seq" rescue nil
|
33
|
-
@conn.execute "ALTER TABLE test_posts drop CONSTRAINT fk_test_post_foo" rescue nil
|
34
|
-
@conn.execute "DROP TRIGGER test_post_trigger" rescue nil
|
35
|
-
@conn.execute "DROP TYPE TEST_TYPE" rescue nil
|
36
|
-
@conn.execute "DROP TABLE bars" rescue nil
|
37
|
-
@conn.execute "ALTER TABLE foos drop CONSTRAINT UK_BAZ" rescue nil
|
38
|
-
@conn.execute "ALTER TABLE foos drop CONSTRAINT UK_FOOZ_BAZ" rescue nil
|
39
|
-
@conn.execute "ALTER TABLE foos drop column fooz_id" rescue nil
|
40
|
-
@conn.execute "ALTER TABLE foos drop column baz_id" rescue nil
|
41
|
-
@conn.execute "ALTER TABLE test_posts drop column fooz_id" rescue nil
|
42
|
-
@conn.execute "ALTER TABLE test_posts drop column baz_id" rescue nil
|
43
|
-
end
|
44
|
-
|
45
|
-
it "should dump single primary key" do
|
46
|
-
dump = ActiveRecord::Base.connection.structure_dump
|
47
|
-
dump.should =~ /CONSTRAINT (.+) PRIMARY KEY \(ID\)\n/
|
48
|
-
end
|
49
|
-
|
50
|
-
it "should dump composite primary keys" do
|
51
|
-
pk = @conn.send(:select_one, <<-SQL)
|
52
|
-
select constraint_name from user_constraints where table_name = 'TEST_POSTS' and constraint_type='P'
|
53
|
-
SQL
|
54
|
-
@conn.execute <<-SQL
|
55
|
-
alter table test_posts drop constraint #{pk["constraint_name"]}
|
56
|
-
SQL
|
57
|
-
@conn.execute <<-SQL
|
58
|
-
ALTER TABLE TEST_POSTS
|
59
|
-
add CONSTRAINT pk_id_title PRIMARY KEY (id, title)
|
60
|
-
SQL
|
61
|
-
dump = ActiveRecord::Base.connection.structure_dump
|
62
|
-
dump.should =~ /CONSTRAINT (.+) PRIMARY KEY \(ID,TITLE\)\n/
|
63
|
-
end
|
64
|
-
|
65
|
-
it "should dump foreign keys" do
|
66
|
-
@conn.execute <<-SQL
|
67
|
-
ALTER TABLE TEST_POSTS
|
68
|
-
ADD CONSTRAINT fk_test_post_foo FOREIGN KEY (foo_id) REFERENCES foos(id)
|
69
|
-
SQL
|
70
|
-
dump = ActiveRecord::Base.connection.structure_dump_fk_constraints
|
71
|
-
dump.split('\n').length.should == 1
|
72
|
-
dump.should =~ /ALTER TABLE \"?TEST_POSTS\"? ADD CONSTRAINT \"?FK_TEST_POST_FOO\"? FOREIGN KEY \(\"?FOO_ID\"?\) REFERENCES \"?FOOS\"?\(\"?ID\"?\)/i
|
73
|
-
end
|
74
|
-
|
75
|
-
it "should dump foreign keys when reference column name is not 'id'" do
|
76
|
-
@conn.add_column :foos, :baz_id, :integer
|
77
|
-
|
78
|
-
@conn.execute <<-SQL
|
79
|
-
ALTER TABLE FOOS
|
80
|
-
ADD CONSTRAINT UK_BAZ UNIQUE (BAZ_ID)
|
81
|
-
SQL
|
82
|
-
|
83
|
-
@conn.add_column :test_posts, :baz_id, :integer
|
84
|
-
|
85
|
-
@conn.execute <<-SQL
|
86
|
-
ALTER TABLE TEST_POSTS
|
87
|
-
ADD CONSTRAINT fk_test_post_baz FOREIGN KEY (baz_id) REFERENCES foos(baz_id)
|
88
|
-
SQL
|
89
|
-
|
90
|
-
dump = ActiveRecord::Base.connection.structure_dump_fk_constraints
|
91
|
-
dump.split('\n').length.should == 1
|
92
|
-
dump.should =~ /ALTER TABLE \"?TEST_POSTS\"? ADD CONSTRAINT \"?FK_TEST_POST_BAZ\"? FOREIGN KEY \(\"?BAZ_ID\"?\) REFERENCES \"?FOOS\"?\(\"?BAZ_ID\"?\)/i
|
93
|
-
end
|
94
|
-
|
95
|
-
it "should dump composite foreign keys" do
|
96
|
-
@conn.add_column :foos, :fooz_id, :integer
|
97
|
-
@conn.add_column :foos, :baz_id, :integer
|
98
|
-
|
99
|
-
@conn.execute <<-SQL
|
100
|
-
ALTER TABLE FOOS
|
101
|
-
ADD CONSTRAINT UK_FOOZ_BAZ UNIQUE (BAZ_ID,FOOZ_ID)
|
102
|
-
SQL
|
103
|
-
|
104
|
-
@conn.add_column :test_posts, :fooz_id, :integer
|
105
|
-
@conn.add_column :test_posts, :baz_id, :integer
|
106
|
-
|
107
|
-
@conn.execute <<-SQL
|
108
|
-
ALTER TABLE TEST_POSTS
|
109
|
-
ADD CONSTRAINT fk_test_post_fooz_baz FOREIGN KEY (baz_id,fooz_id) REFERENCES foos(baz_id,fooz_id)
|
110
|
-
SQL
|
111
|
-
|
112
|
-
dump = ActiveRecord::Base.connection.structure_dump_fk_constraints
|
113
|
-
dump.split('\n').length.should == 1
|
114
|
-
dump.should =~ /ALTER TABLE \"?TEST_POSTS\"? ADD CONSTRAINT \"?FK_TEST_POST_FOOZ_BAZ\"? FOREIGN KEY \(\"?BAZ_ID\"?\,\"?FOOZ_ID\"?\) REFERENCES \"?FOOS\"?\(\"?BAZ_ID\"?\,\"?FOOZ_ID\"?\)/i
|
115
|
-
end
|
116
|
-
|
117
|
-
it "should not error when no foreign keys are present" do
|
118
|
-
dump = ActiveRecord::Base.connection.structure_dump_fk_constraints
|
119
|
-
dump.split('\n').length.should == 0
|
120
|
-
dump.should == ''
|
121
|
-
end
|
122
|
-
|
123
|
-
it "should dump triggers" do
|
124
|
-
@conn.execute <<-SQL
|
125
|
-
create or replace TRIGGER TEST_POST_TRIGGER
|
126
|
-
BEFORE INSERT
|
127
|
-
ON TEST_POSTS
|
128
|
-
FOR EACH ROW
|
129
|
-
BEGIN
|
130
|
-
SELECT 'bar' INTO :new.FOO FROM DUAL;
|
131
|
-
END;
|
132
|
-
SQL
|
133
|
-
dump = ActiveRecord::Base.connection.structure_dump_db_stored_code.gsub(/\n|\s+/,' ')
|
134
|
-
dump.should =~ /CREATE OR REPLACE TRIGGER TEST_POST_TRIGGER/
|
135
|
-
end
|
136
|
-
|
137
|
-
it "should dump types" do
|
138
|
-
@conn.execute <<-SQL
|
139
|
-
create or replace TYPE TEST_TYPE AS TABLE OF VARCHAR2(10);
|
140
|
-
SQL
|
141
|
-
dump = ActiveRecord::Base.connection.structure_dump_db_stored_code.gsub(/\n|\s+/,' ')
|
142
|
-
dump.should =~ /CREATE OR REPLACE TYPE TEST_TYPE/
|
143
|
-
end
|
144
|
-
|
145
|
-
it "should dump virtual columns" do
|
146
|
-
pending "Not supported in this database version" unless @oracle11g
|
147
|
-
@conn.execute <<-SQL
|
148
|
-
CREATE TABLE bars (
|
149
|
-
id NUMBER(38,0) NOT NULL,
|
150
|
-
id_plus NUMBER GENERATED ALWAYS AS(id + 2) VIRTUAL,
|
151
|
-
PRIMARY KEY (ID)
|
152
|
-
)
|
153
|
-
SQL
|
154
|
-
dump = ActiveRecord::Base.connection.structure_dump
|
155
|
-
dump.should =~ /\"?ID_PLUS\"? NUMBER GENERATED ALWAYS AS \(ID\+2\) VIRTUAL/
|
156
|
-
end
|
157
|
-
|
158
|
-
it "should dump unique keys" do
|
159
|
-
@conn.execute <<-SQL
|
160
|
-
ALTER TABLE test_posts
|
161
|
-
add CONSTRAINT uk_foo_foo_id UNIQUE (foo, foo_id)
|
162
|
-
SQL
|
163
|
-
dump = ActiveRecord::Base.connection.structure_dump_unique_keys("test_posts")
|
164
|
-
dump.should == ["ALTER TABLE TEST_POSTS ADD CONSTRAINT UK_FOO_FOO_ID UNIQUE (FOO,FOO_ID)"]
|
165
|
-
|
166
|
-
dump = ActiveRecord::Base.connection.structure_dump
|
167
|
-
dump.should =~ /CONSTRAINT UK_FOO_FOO_ID UNIQUE \(FOO,FOO_ID\)/
|
168
|
-
end
|
169
|
-
|
170
|
-
it "should dump indexes" do
|
171
|
-
ActiveRecord::Base.connection.add_index(:test_posts, :foo, :name => :ix_test_posts_foo)
|
172
|
-
ActiveRecord::Base.connection.add_index(:test_posts, :foo_id, :name => :ix_test_posts_foo_id, :unique => true)
|
173
|
-
|
174
|
-
@conn.execute <<-SQL
|
175
|
-
ALTER TABLE test_posts
|
176
|
-
add CONSTRAINT uk_foo_foo_id UNIQUE (foo, foo_id)
|
177
|
-
SQL
|
178
|
-
|
179
|
-
dump = ActiveRecord::Base.connection.structure_dump
|
180
|
-
dump.should =~ /CREATE UNIQUE INDEX "?IX_TEST_POSTS_FOO_ID"? ON "?TEST_POSTS"? \("?FOO_ID"?\)/i
|
181
|
-
dump.should =~ /CREATE INDEX "?IX_TEST_POSTS_FOO\"? ON "?TEST_POSTS"? \("?FOO"?\)/i
|
182
|
-
dump.should_not =~ /CREATE UNIQUE INDEX "?UK_TEST_POSTS_/i
|
183
|
-
end
|
184
|
-
|
185
|
-
it "should dump multi-value and function value indexes" do
|
186
|
-
ActiveRecord::Base.connection.add_index(:test_posts, [:foo, :foo_id], :name => :ix_test_posts_foo_foo_id)
|
187
|
-
|
188
|
-
@conn.execute <<-SQL
|
189
|
-
CREATE INDEX "IX_TEST_POSTS_FUNCTION" ON "TEST_POSTS" (TO_CHAR(LENGTH("FOO"))||"FOO")
|
190
|
-
SQL
|
191
|
-
|
192
|
-
dump = ActiveRecord::Base.connection.structure_dump
|
193
|
-
dump.should =~ /CREATE INDEX "?IX_TEST_POSTS_FOO_FOO_ID\"? ON "?TEST_POSTS"? \("?FOO"?, "?FOO_ID"?\)/i
|
194
|
-
dump.should =~ /CREATE INDEX "?IX_TEST_POSTS_FUNCTION\"? ON "?TEST_POSTS"? \(TO_CHAR\(LENGTH\("?FOO"?\)\)\|\|"?FOO"?\)/i
|
195
|
-
end
|
196
|
-
end
|
197
|
-
describe "temporary tables" do
|
198
|
-
after(:all) do
|
199
|
-
@conn.drop_table :test_comments rescue nil
|
200
|
-
end
|
201
|
-
it "should dump correctly" do
|
202
|
-
@conn.create_table :test_comments, :temporary => true, :id => false do |t|
|
203
|
-
t.integer :post_id
|
204
|
-
end
|
205
|
-
dump = ActiveRecord::Base.connection.structure_dump
|
206
|
-
dump.should =~ /CREATE GLOBAL TEMPORARY TABLE "?TEST_COMMENTS"?/i
|
207
|
-
end
|
208
|
-
end
|
209
|
-
|
210
|
-
describe "database stucture dump extentions" do
|
211
|
-
before(:all) do
|
212
|
-
@conn.execute <<-SQL
|
213
|
-
CREATE TABLE nvarchartable (
|
214
|
-
unq_nvarchar NVARCHAR2(255) DEFAULT NULL
|
215
|
-
)
|
216
|
-
SQL
|
217
|
-
end
|
218
|
-
|
219
|
-
after(:all) do
|
220
|
-
@conn.execute "DROP TABLE nvarchartable"
|
221
|
-
end
|
222
|
-
|
223
|
-
it "should return the character size of nvarchar fields" do
|
224
|
-
if /.*unq_nvarchar nvarchar2\((\d+)\).*/ =~ @conn.structure_dump
|
225
|
-
"#$1".should == "255"
|
226
|
-
end
|
227
|
-
end
|
228
|
-
end
|
229
|
-
|
230
|
-
describe "temp_table_drop" do
|
231
|
-
before(:each) do
|
232
|
-
@conn.create_table :temp_tbl, :temporary => true do |t|
|
233
|
-
t.string :foo
|
234
|
-
end
|
235
|
-
@conn.create_table :not_temp_tbl do |t|
|
236
|
-
t.string :foo
|
237
|
-
end
|
238
|
-
end
|
239
|
-
it "should dump drop sql for just temp tables" do
|
240
|
-
dump = @conn.temp_table_drop
|
241
|
-
dump.should =~ /DROP TABLE "TEMP_TBL"/
|
242
|
-
dump.should_not =~ /DROP TABLE "?NOT_TEMP_TBL"?/i
|
243
|
-
end
|
244
|
-
after(:each) do
|
245
|
-
@conn.drop_table :temp_tbl
|
246
|
-
@conn.drop_table :not_temp_tbl
|
247
|
-
end
|
248
|
-
end
|
249
|
-
|
250
|
-
describe "full drop" do
|
251
|
-
before(:each) do
|
252
|
-
@conn.create_table :full_drop_test do |t|
|
253
|
-
t.integer :id
|
254
|
-
end
|
255
|
-
@conn.create_table :full_drop_test_temp, :temporary => true do |t|
|
256
|
-
t.string :foo
|
257
|
-
end
|
258
|
-
#view
|
259
|
-
@conn.execute <<-SQL
|
260
|
-
create or replace view full_drop_test_view (foo) as select id as "foo" from full_drop_test
|
261
|
-
SQL
|
262
|
-
#materialized view
|
263
|
-
@conn.execute <<-SQL
|
264
|
-
create materialized view full_drop_test_mview (foo) as select id as "foo" from full_drop_test
|
265
|
-
SQL
|
266
|
-
#package
|
267
|
-
@conn.execute <<-SQL
|
268
|
-
create or replace package full_drop_test_package as
|
269
|
-
function test_func return varchar2;
|
270
|
-
end test_package;
|
271
|
-
SQL
|
272
|
-
@conn.execute <<-SQL
|
273
|
-
create or replace package body full_drop_test_package as
|
274
|
-
function test_func return varchar2 is
|
275
|
-
begin
|
276
|
-
return ('foo');
|
277
|
-
end test_func;
|
278
|
-
end test_package;
|
279
|
-
SQL
|
280
|
-
#function
|
281
|
-
@conn.execute <<-SQL
|
282
|
-
create or replace function full_drop_test_function
|
283
|
-
return varchar2
|
284
|
-
is
|
285
|
-
foo varchar2(3);
|
286
|
-
begin
|
287
|
-
return('foo');
|
288
|
-
end;
|
289
|
-
SQL
|
290
|
-
#procedure
|
291
|
-
@conn.execute <<-SQL
|
292
|
-
create or replace procedure full_drop_test_procedure
|
293
|
-
begin
|
294
|
-
delete from full_drop_test where id=1231231231
|
295
|
-
exception
|
296
|
-
when no_data_found then
|
297
|
-
dbms_output.put_line('foo');
|
298
|
-
end;
|
299
|
-
SQL
|
300
|
-
#synonym
|
301
|
-
@conn.execute <<-SQL
|
302
|
-
create or replace synonym full_drop_test_synonym for full_drop_test
|
303
|
-
SQL
|
304
|
-
#type
|
305
|
-
@conn.execute <<-SQL
|
306
|
-
create or replace type full_drop_test_type as table of number
|
307
|
-
SQL
|
308
|
-
end
|
309
|
-
after(:each) do
|
310
|
-
@conn.drop_table :full_drop_test
|
311
|
-
@conn.drop_table :full_drop_test_temp
|
312
|
-
@conn.execute "DROP VIEW FULL_DROP_TEST_VIEW" rescue nil
|
313
|
-
@conn.execute "DROP MATERIALIZED VIEW FULL_DROP_TEST_MVIEW" rescue nil
|
314
|
-
@conn.execute "DROP SYNONYM FULL_DROP_TEST_SYNONYM" rescue nil
|
315
|
-
@conn.execute "DROP PACKAGE FULL_DROP_TEST_PACKAGE" rescue nil
|
316
|
-
@conn.execute "DROP FUNCTION FULL_DROP_TEST_FUNCTION" rescue nil
|
317
|
-
@conn.execute "DROP PROCEDURE FULL_DROP_TEST_PROCEDURE" rescue nil
|
318
|
-
@conn.execute "DROP TYPE FULL_DROP_TEST_TYPE" rescue nil
|
319
|
-
end
|
320
|
-
it "should contain correct sql" do
|
321
|
-
drop = @conn.full_drop
|
322
|
-
drop.should =~ /DROP TABLE "FULL_DROP_TEST" CASCADE CONSTRAINTS/
|
323
|
-
drop.should =~ /DROP SEQUENCE "FULL_DROP_TEST_SEQ"/
|
324
|
-
drop.should =~ /DROP VIEW "FULL_DROP_TEST_VIEW"/
|
325
|
-
drop.should_not =~ /DROP TABLE "?FULL_DROP_TEST_MVIEW"?/i
|
326
|
-
drop.should =~ /DROP MATERIALIZED VIEW "FULL_DROP_TEST_MVIEW"/
|
327
|
-
drop.should =~ /DROP PACKAGE "FULL_DROP_TEST_PACKAGE"/
|
328
|
-
drop.should =~ /DROP FUNCTION "FULL_DROP_TEST_FUNCTION"/
|
329
|
-
drop.should =~ /DROP PROCEDURE "FULL_DROP_TEST_PROCEDURE"/
|
330
|
-
drop.should =~ /DROP SYNONYM "FULL_DROP_TEST_SYNONYM"/
|
331
|
-
drop.should =~ /DROP TYPE "FULL_DROP_TEST_TYPE"/
|
332
|
-
end
|
333
|
-
it "should not drop tables when preserve_tables is true" do
|
334
|
-
drop = @conn.full_drop(true)
|
335
|
-
drop.should =~ /DROP TABLE "FULL_DROP_TEST_TEMP"/
|
336
|
-
drop.should_not =~ /DROP TABLE "?FULL_DROP_TEST"? CASCADE CONSTRAINTS/i
|
337
|
-
end
|
338
|
-
end
|
339
|
-
end
|