partitioned 0.8.0
Sign up to get free protection for your applications and to get access to all the features.
- data/Gemfile +17 -0
- data/LICENSE +30 -0
- data/PARTITIONING_EXPLAINED.txt +351 -0
- data/README +111 -0
- data/Rakefile +27 -0
- data/examples/README +23 -0
- data/examples/company_id.rb +417 -0
- data/examples/company_id_and_created_at.rb +689 -0
- data/examples/created_at.rb +590 -0
- data/examples/created_at_referencing_awards.rb +1000 -0
- data/examples/id.rb +475 -0
- data/examples/lib/by_company_id.rb +11 -0
- data/examples/lib/command_line_tool_mixin.rb +71 -0
- data/examples/lib/company.rb +29 -0
- data/examples/lib/get_options.rb +44 -0
- data/examples/lib/roman.rb +41 -0
- data/examples/start_date.rb +621 -0
- data/init.rb +1 -0
- data/lib/monkey_patch_activerecord.rb +92 -0
- data/lib/monkey_patch_postgres.rb +73 -0
- data/lib/partitioned.rb +26 -0
- data/lib/partitioned/active_record_overrides.rb +34 -0
- data/lib/partitioned/bulk_methods_mixin.rb +288 -0
- data/lib/partitioned/by_created_at.rb +13 -0
- data/lib/partitioned/by_foreign_key.rb +21 -0
- data/lib/partitioned/by_id.rb +35 -0
- data/lib/partitioned/by_integer_field.rb +32 -0
- data/lib/partitioned/by_monthly_time_field.rb +23 -0
- data/lib/partitioned/by_time_field.rb +65 -0
- data/lib/partitioned/by_weekly_time_field.rb +30 -0
- data/lib/partitioned/multi_level.rb +20 -0
- data/lib/partitioned/multi_level/configurator/data.rb +14 -0
- data/lib/partitioned/multi_level/configurator/dsl.rb +32 -0
- data/lib/partitioned/multi_level/configurator/reader.rb +162 -0
- data/lib/partitioned/multi_level/partition_manager.rb +47 -0
- data/lib/partitioned/partitioned_base.rb +354 -0
- data/lib/partitioned/partitioned_base/configurator.rb +6 -0
- data/lib/partitioned/partitioned_base/configurator/data.rb +62 -0
- data/lib/partitioned/partitioned_base/configurator/dsl.rb +628 -0
- data/lib/partitioned/partitioned_base/configurator/reader.rb +209 -0
- data/lib/partitioned/partitioned_base/partition_manager.rb +138 -0
- data/lib/partitioned/partitioned_base/sql_adapter.rb +286 -0
- data/lib/partitioned/version.rb +3 -0
- data/lib/tasks/desirable_tasks.rake +4 -0
- data/partitioned.gemspec +21 -0
- data/spec/dummy/.rspec +1 -0
- data/spec/dummy/README.rdoc +261 -0
- data/spec/dummy/Rakefile +7 -0
- data/spec/dummy/app/assets/javascripts/application.js +9 -0
- data/spec/dummy/app/assets/stylesheets/application.css +7 -0
- data/spec/dummy/app/controllers/application_controller.rb +3 -0
- data/spec/dummy/app/helpers/application_helper.rb +2 -0
- data/spec/dummy/app/views/layouts/application.html.erb +14 -0
- data/spec/dummy/config.ru +4 -0
- data/spec/dummy/config/application.rb +51 -0
- data/spec/dummy/config/boot.rb +10 -0
- data/spec/dummy/config/database.yml +32 -0
- data/spec/dummy/config/environment.rb +5 -0
- data/spec/dummy/config/environments/development.rb +30 -0
- data/spec/dummy/config/environments/production.rb +60 -0
- data/spec/dummy/config/environments/test.rb +39 -0
- data/spec/dummy/config/initializers/backtrace_silencers.rb +7 -0
- data/spec/dummy/config/initializers/inflections.rb +10 -0
- data/spec/dummy/config/initializers/mime_types.rb +5 -0
- data/spec/dummy/config/initializers/secret_token.rb +7 -0
- data/spec/dummy/config/initializers/session_store.rb +8 -0
- data/spec/dummy/config/initializers/wrap_parameters.rb +14 -0
- data/spec/dummy/config/locales/en.yml +5 -0
- data/spec/dummy/config/routes.rb +58 -0
- data/spec/dummy/public/404.html +26 -0
- data/spec/dummy/public/422.html +26 -0
- data/spec/dummy/public/500.html +26 -0
- data/spec/dummy/public/favicon.ico +0 -0
- data/spec/dummy/script/rails +6 -0
- data/spec/dummy/spec/spec_helper.rb +27 -0
- data/spec/monkey_patch_posgres_spec.rb +176 -0
- data/spec/partitioned/bulk_methods_mixin_spec.rb +512 -0
- data/spec/partitioned/by_created_at_spec.rb +62 -0
- data/spec/partitioned/by_foreign_key_spec.rb +95 -0
- data/spec/partitioned/by_id_spec.rb +97 -0
- data/spec/partitioned/by_integer_field_spec.rb +143 -0
- data/spec/partitioned/by_monthly_time_field_spec.rb +100 -0
- data/spec/partitioned/by_time_field_spec.rb +182 -0
- data/spec/partitioned/by_weekly_time_field_spec.rb +100 -0
- data/spec/partitioned/multi_level/configurator/dsl_spec.rb +88 -0
- data/spec/partitioned/multi_level/configurator/reader_spec.rb +147 -0
- data/spec/partitioned/partitioned_base/configurator/dsl_spec.rb +459 -0
- data/spec/partitioned/partitioned_base/configurator/reader_spec.rb +513 -0
- data/spec/partitioned/partitioned_base/sql_adapter_spec.rb +204 -0
- data/spec/partitioned/partitioned_base_spec.rb +173 -0
- data/spec/spec_helper.rb +32 -0
- data/spec/support/shared_example_spec_helper_for_integer_key.rb +137 -0
- data/spec/support/shared_example_spec_helper_for_time_key.rb +147 -0
- data/spec/support/tables_spec_helper.rb +47 -0
- metadata +250 -0
@@ -0,0 +1,513 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
module Partitioned
|
4
|
+
class PartitionedBase
|
5
|
+
module Configurator
|
6
|
+
describe Reader do
|
7
|
+
|
8
|
+
before(:all) do
|
9
|
+
class Employee < ById
|
10
|
+
def self.partition_field
|
11
|
+
:id
|
12
|
+
end
|
13
|
+
def self.foreign_key_field
|
14
|
+
:company_id
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
after(:all) do
|
20
|
+
Partitioned::PartitionedBase::Configurator.send(:remove_const, :Employee)
|
21
|
+
end
|
22
|
+
|
23
|
+
let!(:dsl) { Partitioned::PartitionedBase::Configurator::Dsl.new(Employee) }
|
24
|
+
let!(:default_reader) { Partitioned::PartitionedBase::Configurator::Reader.new(Employee) }
|
25
|
+
let!(:reader) do
|
26
|
+
reader = Partitioned::PartitionedBase::Configurator::Reader.new(Employee)
|
27
|
+
reader.stub!(:configurators).and_return([dsl])
|
28
|
+
reader
|
29
|
+
end
|
30
|
+
|
31
|
+
describe "configurators" do
|
32
|
+
|
33
|
+
context "checking arrays length" do
|
34
|
+
|
35
|
+
it "returns 3" do
|
36
|
+
default_reader.send(:configurators).length.should == 3
|
37
|
+
end
|
38
|
+
|
39
|
+
end # checking array length
|
40
|
+
|
41
|
+
context "checking models class for each of configurators" do
|
42
|
+
|
43
|
+
it "returns 'Partitioned::ById'" do
|
44
|
+
default_reader.send(:configurators)[0].model.to_s.should == "Partitioned::ById"
|
45
|
+
end
|
46
|
+
|
47
|
+
it "returns 'Partitioned::ByIntegerField'" do
|
48
|
+
default_reader.send(:configurators)[1].model.to_s.should == "Partitioned::ByIntegerField"
|
49
|
+
end
|
50
|
+
|
51
|
+
it "returns 'Partitioned::PartitionedBase'" do
|
52
|
+
default_reader.send(:configurators)[2].model.to_s.should == "Partitioned::PartitionedBase"
|
53
|
+
end
|
54
|
+
|
55
|
+
end # checking models class for each of configurators
|
56
|
+
|
57
|
+
end # configurators
|
58
|
+
|
59
|
+
describe "schema_name" do
|
60
|
+
|
61
|
+
context "when schema_name value is set by default" do
|
62
|
+
|
63
|
+
it "returns 'employees_partitions'" do
|
64
|
+
default_reader.schema_name.should == "employees_partitions"
|
65
|
+
end
|
66
|
+
|
67
|
+
end # when schema_name value is set by default
|
68
|
+
|
69
|
+
context "when schema_name value is set by value" do
|
70
|
+
|
71
|
+
it "returns 'employees_partitions'" do
|
72
|
+
dsl.schema_name("employees_partitions")
|
73
|
+
reader.schema_name.should == "employees_partitions"
|
74
|
+
end
|
75
|
+
|
76
|
+
end # when schema_name value is set by value
|
77
|
+
|
78
|
+
context "when schema_name value is set by string" do
|
79
|
+
|
80
|
+
it "returns 'employees_partitions'" do
|
81
|
+
dsl.schema_name('#{model.table_name}_partitions')
|
82
|
+
reader.schema_name.should == "employees_partitions"
|
83
|
+
end
|
84
|
+
|
85
|
+
end # when schema_name value is set by string
|
86
|
+
|
87
|
+
context "when schema_name value is set by proc" do
|
88
|
+
|
89
|
+
let(:lmd) do
|
90
|
+
lambda {|model, *value|
|
91
|
+
return "#{model.table_name}_partitions"
|
92
|
+
}
|
93
|
+
end
|
94
|
+
|
95
|
+
it "returns 'employees_partitions'" do
|
96
|
+
dsl.schema_name lmd
|
97
|
+
reader.schema_name.should == "employees_partitions"
|
98
|
+
end
|
99
|
+
|
100
|
+
end # when schema_name value is set by proc
|
101
|
+
|
102
|
+
end # schema_name
|
103
|
+
|
104
|
+
describe "on_fields" do
|
105
|
+
|
106
|
+
context "when on_field value is set by default" do
|
107
|
+
|
108
|
+
it "returns [:id]" do
|
109
|
+
default_reader.on_fields.should == [:id]
|
110
|
+
end
|
111
|
+
|
112
|
+
end # when on_filed value is set by default
|
113
|
+
|
114
|
+
context "when on_field value is set by symbol" do
|
115
|
+
|
116
|
+
it "returns [:company_id]" do
|
117
|
+
dsl.on :company_id
|
118
|
+
reader.on_fields.should == [:company_id]
|
119
|
+
end
|
120
|
+
|
121
|
+
end # "when on_field value is set by symbol
|
122
|
+
|
123
|
+
context "when on_field value is set by string" do
|
124
|
+
|
125
|
+
it "returns [:id]" do
|
126
|
+
dsl.on '#{model.partition_field}'
|
127
|
+
reader.on_fields.should == [:id]
|
128
|
+
end
|
129
|
+
|
130
|
+
end # "when on_field value is set by string
|
131
|
+
|
132
|
+
context "when on_field value is set by proc" do
|
133
|
+
|
134
|
+
let(:lmd) do
|
135
|
+
lambda { |model| model.partition_field }
|
136
|
+
end
|
137
|
+
|
138
|
+
it "returns [:id]" do
|
139
|
+
dsl.on lmd
|
140
|
+
reader.on_fields.should == [:id]
|
141
|
+
end
|
142
|
+
|
143
|
+
end # "when on_field value is set by proc
|
144
|
+
|
145
|
+
end # on_fields
|
146
|
+
|
147
|
+
describe "indexes" do
|
148
|
+
|
149
|
+
context "when indexes value is set by default" do
|
150
|
+
|
151
|
+
it "returns { :id => { :unique => true } }" do
|
152
|
+
default_reader.indexes.should == { :id => { :unique => true } }
|
153
|
+
end
|
154
|
+
|
155
|
+
end # when indexes value is set by default
|
156
|
+
|
157
|
+
context "when indexes value is set by values" do
|
158
|
+
|
159
|
+
it "returns { :id => { :unique => false } }" do
|
160
|
+
dsl.index(:id, { :unique => false })
|
161
|
+
reader.indexes.should == { :id => { :unique => false } }
|
162
|
+
end
|
163
|
+
|
164
|
+
end # when indexes value is set by values
|
165
|
+
|
166
|
+
context "when indexes value is set by proc" do
|
167
|
+
|
168
|
+
let(:lmd) do
|
169
|
+
lambda { |model, *partition_key_values|
|
170
|
+
return Partitioned::PartitionedBase::Configurator::Data::Index.new(model.partition_field, {})
|
171
|
+
}
|
172
|
+
end
|
173
|
+
|
174
|
+
it "returns { :id => {} }" do
|
175
|
+
dsl.index lmd
|
176
|
+
reader.indexes.should == { :id => {} }
|
177
|
+
end
|
178
|
+
|
179
|
+
end # when indexes value is set by proc
|
180
|
+
|
181
|
+
end # indexes
|
182
|
+
|
183
|
+
describe "foreign_keys" do
|
184
|
+
|
185
|
+
context "when foreign_keys value is set by symbol" do
|
186
|
+
|
187
|
+
it "returns foreign_keys" do
|
188
|
+
dsl.foreign_key(:company_id)
|
189
|
+
reader.foreign_keys.first.referenced_field.should == :id
|
190
|
+
reader.foreign_keys.first.referenced_table.should == "companies"
|
191
|
+
reader.foreign_keys.first.referencing_field.should == :company_id
|
192
|
+
end
|
193
|
+
|
194
|
+
end # when foreign_keys value is set by symbol
|
195
|
+
|
196
|
+
context "when foreign_keys value is set by proc" do
|
197
|
+
|
198
|
+
let(:lmd) do
|
199
|
+
lambda { |model, *partition_key_values|
|
200
|
+
return Partitioned::PartitionedBase::Configurator::Data::ForeignKey.new(model.foreign_key_field)
|
201
|
+
}
|
202
|
+
end
|
203
|
+
|
204
|
+
it "returns foreign_keys" do
|
205
|
+
dsl.foreign_key lmd
|
206
|
+
reader.foreign_keys.first.referenced_field.should == :id
|
207
|
+
reader.foreign_keys.first.referenced_table.should == "companies"
|
208
|
+
reader.foreign_keys.first.referencing_field.should == :company_id
|
209
|
+
end
|
210
|
+
|
211
|
+
end # when foreign_keys value is set by proc
|
212
|
+
|
213
|
+
end # foreign_keys
|
214
|
+
|
215
|
+
describe "check_constraint" do
|
216
|
+
|
217
|
+
context "when check_constraint value is set by string" do
|
218
|
+
|
219
|
+
it "returns 'company_id = 1'" do
|
220
|
+
dsl.check_constraint('company_id = #{field_value}')
|
221
|
+
reader.check_constraint(1).should == "company_id = 1"
|
222
|
+
end
|
223
|
+
|
224
|
+
end # when check_constraint value is set by string
|
225
|
+
|
226
|
+
context "when check_constraint value is set by proc" do
|
227
|
+
|
228
|
+
let(:lmd) do
|
229
|
+
lambda {|model, value|
|
230
|
+
return "#{model.partition_field} = #{value}"
|
231
|
+
}
|
232
|
+
end
|
233
|
+
|
234
|
+
it "returns 'id = 1'" do
|
235
|
+
dsl.check_constraint lmd
|
236
|
+
reader.check_constraint(1).should == "id = 1"
|
237
|
+
end
|
238
|
+
|
239
|
+
end # when check_constraint value is set by proc
|
240
|
+
|
241
|
+
end # check_constraint
|
242
|
+
|
243
|
+
describe "parent_table_name" do
|
244
|
+
|
245
|
+
context "when parent_table_name value is set by default" do
|
246
|
+
|
247
|
+
it "returns employees" do
|
248
|
+
default_reader.parent_table_name.should == "employees"
|
249
|
+
end
|
250
|
+
|
251
|
+
end # when parent_table_name value is set by default
|
252
|
+
|
253
|
+
context "when parent_table_name value is set by value" do
|
254
|
+
|
255
|
+
it "returns employees" do
|
256
|
+
dsl.parent_table_name("employees")
|
257
|
+
reader.parent_table_name.should == "employees"
|
258
|
+
end
|
259
|
+
|
260
|
+
end # when parent_table_name value is set by value
|
261
|
+
|
262
|
+
context "when parent_table_name value is set by string" do
|
263
|
+
|
264
|
+
it "returns employees" do
|
265
|
+
dsl.parent_table_name('#{model.table_name}')
|
266
|
+
reader.parent_table_name.should == "employees"
|
267
|
+
end
|
268
|
+
|
269
|
+
end # when parent_table_name value is set by string
|
270
|
+
|
271
|
+
context "when parent_table_name value is set by proc" do
|
272
|
+
|
273
|
+
let(:lmd) do
|
274
|
+
lambda {|model, *partition_key_values|
|
275
|
+
return "#{model.table_name}"
|
276
|
+
}
|
277
|
+
end
|
278
|
+
|
279
|
+
it "returns employees" do
|
280
|
+
dsl.parent_table_name lmd
|
281
|
+
reader.parent_table_name.should == "employees"
|
282
|
+
end
|
283
|
+
|
284
|
+
end # when parent_table_name value is set by proc
|
285
|
+
|
286
|
+
end # parent_table_name
|
287
|
+
|
288
|
+
describe "parent_table_schema_name" do
|
289
|
+
|
290
|
+
context "when parent_table_schema_name value is set by default" do
|
291
|
+
|
292
|
+
it "returns public" do
|
293
|
+
default_reader.parent_table_schema_name.should == "public"
|
294
|
+
end
|
295
|
+
|
296
|
+
end # when parent_table_schema_name value is set by default
|
297
|
+
|
298
|
+
context "when parent_table_schema_name value is set by value" do
|
299
|
+
|
300
|
+
it "returns employees" do
|
301
|
+
dsl.parent_table_schema_name("employees")
|
302
|
+
reader.parent_table_schema_name.should == "employees"
|
303
|
+
end
|
304
|
+
|
305
|
+
end # when parent_table_schema_name value is set by value
|
306
|
+
|
307
|
+
context "when parent_table_schema_name value is set by string" do
|
308
|
+
|
309
|
+
it "returns employees" do
|
310
|
+
dsl.parent_table_schema_name('#{model.table_name}')
|
311
|
+
reader.parent_table_schema_name.should == "employees"
|
312
|
+
end
|
313
|
+
|
314
|
+
end # when parent_table_schema_name value is set by string
|
315
|
+
|
316
|
+
context "when parent_table_schema_name value is set by proc" do
|
317
|
+
|
318
|
+
let(:lmd) do
|
319
|
+
lambda {|model, *partition_key_values|
|
320
|
+
return "#{model.table_name}"
|
321
|
+
}
|
322
|
+
end
|
323
|
+
|
324
|
+
it "returns employees" do
|
325
|
+
dsl.parent_table_schema_name lmd
|
326
|
+
reader.parent_table_schema_name.should == "employees"
|
327
|
+
end
|
328
|
+
|
329
|
+
end # when parent_table_schema_name value is set by proc
|
330
|
+
|
331
|
+
end # parent_table_schema_name
|
332
|
+
|
333
|
+
describe "table_name" do
|
334
|
+
|
335
|
+
context "when table_name value is set by default" do
|
336
|
+
|
337
|
+
it "returns employees_partitions.p10000000" do
|
338
|
+
default_reader.table_name(10000000).should == "employees_partitions.p10000000"
|
339
|
+
end
|
340
|
+
|
341
|
+
end # when table_name value is set by default
|
342
|
+
|
343
|
+
context "when table_name value is set by value" do
|
344
|
+
|
345
|
+
it "returns employees_partitions.p42" do
|
346
|
+
dsl.table_name("employees_partitions.p42")
|
347
|
+
reader.table_name.should == "employees_partitions.p42"
|
348
|
+
end
|
349
|
+
|
350
|
+
end # when table_name value is set by value
|
351
|
+
|
352
|
+
context "when table_name value is set by string" do
|
353
|
+
|
354
|
+
it "returns employees_partitions.employees_child_10000000" do
|
355
|
+
dsl.table_name('#{model.table_name}_partitions.#{model.table_name}_child_#{model.partition_normalize_key_value(field_value)}')
|
356
|
+
reader.table_name(10000000).should == "employees_partitions.employees_child_10000000"
|
357
|
+
end
|
358
|
+
|
359
|
+
end # when table_name value is set by string
|
360
|
+
|
361
|
+
context "when table_name value is set by proc" do
|
362
|
+
|
363
|
+
let(:lmd) do
|
364
|
+
lambda {|model, *partition_key_values|
|
365
|
+
return "#{model.table_name}_partitions.#{model.table_name}_child_#{model.partition_normalize_key_value(partition_key_values.first)}"
|
366
|
+
}
|
367
|
+
end
|
368
|
+
|
369
|
+
it "returns employees_partitions.employees_child_10000000" do
|
370
|
+
dsl.table_name lmd
|
371
|
+
reader.table_name(10000000).should == "employees_partitions.employees_child_10000000"
|
372
|
+
end
|
373
|
+
|
374
|
+
end # when table_name value is set by proc
|
375
|
+
|
376
|
+
end # table_name
|
377
|
+
|
378
|
+
describe "base_name" do
|
379
|
+
|
380
|
+
context "when base_name value is set by value" do
|
381
|
+
|
382
|
+
it "returns 42" do
|
383
|
+
dsl.base_name("42")
|
384
|
+
reader.base_name.should == "42"
|
385
|
+
end
|
386
|
+
|
387
|
+
end # when base_name value is set by value
|
388
|
+
|
389
|
+
context "when base_name value is set by string" do
|
390
|
+
|
391
|
+
it "returns 10000000" do
|
392
|
+
dsl.base_name('#{model.partition_normalize_key_value(field_value)}')
|
393
|
+
reader.base_name(10000000).should == "10000000"
|
394
|
+
end
|
395
|
+
|
396
|
+
end # when base_name value is set by string
|
397
|
+
|
398
|
+
context "when base_name value is set by proc" do
|
399
|
+
|
400
|
+
let(:lmd) do
|
401
|
+
lambda {|model, *partition_key_values|
|
402
|
+
return model.partition_normalize_key_value(*partition_key_values).to_s
|
403
|
+
}
|
404
|
+
end
|
405
|
+
|
406
|
+
it "returns 10000000" do
|
407
|
+
dsl.base_name lmd
|
408
|
+
reader.base_name(10000000).should == "10000000"
|
409
|
+
end
|
410
|
+
|
411
|
+
end # when base_name value is set by proc
|
412
|
+
|
413
|
+
end # base_name
|
414
|
+
|
415
|
+
describe "name_prefix" do
|
416
|
+
|
417
|
+
context "when name_prefix value is set by default" do
|
418
|
+
|
419
|
+
it "returns 'p'" do
|
420
|
+
default_reader.name_prefix.should == "p"
|
421
|
+
end
|
422
|
+
|
423
|
+
end # when name_prefix value is set by default
|
424
|
+
|
425
|
+
context "when name_prefix value is set by value" do
|
426
|
+
|
427
|
+
it "returns 'p'" do
|
428
|
+
dsl.name_prefix("p")
|
429
|
+
reader.name_prefix.should == "p"
|
430
|
+
end
|
431
|
+
|
432
|
+
end # when name_prefix value is set by value
|
433
|
+
|
434
|
+
context "when name_prefix value is set by string" do
|
435
|
+
|
436
|
+
it "returns 'employees_child_'" do
|
437
|
+
dsl.name_prefix('#{model.table_name}_child_')
|
438
|
+
reader.name_prefix.should == "employees_child_"
|
439
|
+
end
|
440
|
+
|
441
|
+
end # when name_prefix value is set by string
|
442
|
+
|
443
|
+
context "when name_prefix value is set by proc" do
|
444
|
+
|
445
|
+
let(:lmd) do
|
446
|
+
lambda {|model, *value|
|
447
|
+
return "#{model.table_name}_child_"
|
448
|
+
}
|
449
|
+
end
|
450
|
+
|
451
|
+
it "returns 'employees_child_'" do
|
452
|
+
dsl.name_prefix lmd
|
453
|
+
reader.name_prefix.should == "employees_child_"
|
454
|
+
end
|
455
|
+
|
456
|
+
end # when name_prefix value is set by proc
|
457
|
+
|
458
|
+
end # name_prefix
|
459
|
+
|
460
|
+
describe "part_name" do
|
461
|
+
|
462
|
+
context "when part_name value is set by value" do
|
463
|
+
|
464
|
+
it "returns 'p42'" do
|
465
|
+
dsl.part_name("p42")
|
466
|
+
reader.part_name.should == "p42"
|
467
|
+
end
|
468
|
+
|
469
|
+
end # when part_name value is set by value
|
470
|
+
|
471
|
+
context "when part_name value is set by string" do
|
472
|
+
|
473
|
+
it "returns 'employees_child_10000000'" do
|
474
|
+
dsl.part_name('#{model.table_name}_child_#{model.partition_normalize_key_value(field_value)}')
|
475
|
+
reader.part_name(10000000).should == "employees_child_10000000"
|
476
|
+
end
|
477
|
+
|
478
|
+
end # when part_name value is set by string
|
479
|
+
|
480
|
+
context "when part_name value is set by proc" do
|
481
|
+
|
482
|
+
let(:lmd) do
|
483
|
+
lambda {|model, *partition_key_values|
|
484
|
+
return "#{model.table_name}_child_#{model.partition_normalize_key_value(partition_key_values.first)}"
|
485
|
+
}
|
486
|
+
end
|
487
|
+
|
488
|
+
it "returns 'employees_child_10000000'" do
|
489
|
+
dsl.part_name lmd
|
490
|
+
reader.part_name(10000000).should == "employees_child_10000000"
|
491
|
+
end
|
492
|
+
|
493
|
+
end # when part_name value is set by proc
|
494
|
+
|
495
|
+
end # part_name
|
496
|
+
|
497
|
+
describe "last_partitions_order_by_clause" do
|
498
|
+
|
499
|
+
context "when order value is set by value" do
|
500
|
+
|
501
|
+
it "returns 'tablename desc'" do
|
502
|
+
dsl.order('tablename desc')
|
503
|
+
reader.last_partitions_order_by_clause.should == "tablename desc"
|
504
|
+
end
|
505
|
+
|
506
|
+
end # when order value is set by value
|
507
|
+
|
508
|
+
end # last_partitions_order_by_clause
|
509
|
+
|
510
|
+
end # Reader
|
511
|
+
end # Configurator
|
512
|
+
end # PartitionedBase
|
513
|
+
end # Partitioned
|