arel 0.2.1 → 0.3.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (54) hide show
  1. data/History.txt +8 -0
  2. data/README.markdown +0 -2
  3. data/Rakefile +2 -2
  4. data/arel.gemspec +13 -3
  5. data/lib/arel.rb +2 -2
  6. data/lib/arel/algebra/relations/relation.rb +3 -2
  7. data/lib/arel/engines/sql/compilers/ibm_db_compiler.rb +62 -0
  8. data/lib/arel/engines/sql/compilers/mysql_compiler.rb +11 -0
  9. data/lib/arel/engines/sql/compilers/oracle_compiler.rb +95 -0
  10. data/lib/arel/engines/sql/compilers/postgresql_compiler.rb +42 -0
  11. data/lib/arel/engines/sql/compilers/sqlite_compiler.rb +9 -0
  12. data/lib/arel/engines/sql/engine.rb +17 -3
  13. data/lib/arel/engines/sql/formatters.rb +3 -3
  14. data/lib/arel/engines/sql/relations.rb +1 -0
  15. data/lib/arel/engines/sql/relations/compiler.rb +118 -0
  16. data/lib/arel/engines/sql/relations/relation.rb +38 -63
  17. data/lib/arel/engines/sql/relations/table.rb +23 -3
  18. data/lib/arel/engines/sql/relations/utilities/externalization.rb +1 -1
  19. data/lib/arel/engines/sql/relations/writes.rb +4 -71
  20. data/spec/arel/algebra/unit/relations/relation_spec.rb +1 -2
  21. data/spec/arel/algebra/unit/relations/table_spec.rb +0 -1
  22. data/spec/arel/engines/memory/integration/joins/cross_engine_spec.rb +9 -4
  23. data/spec/arel/engines/sql/integration/joins/with_adjacency_spec.rb +68 -19
  24. data/spec/arel/engines/sql/integration/joins/with_aggregations_spec.rb +74 -20
  25. data/spec/arel/engines/sql/integration/joins/with_compounds_spec.rb +33 -3
  26. data/spec/arel/engines/sql/unit/predicates/binary_spec.rb +22 -2
  27. data/spec/arel/engines/sql/unit/predicates/equality_spec.rb +15 -3
  28. data/spec/arel/engines/sql/unit/predicates/in_spec.rb +59 -5
  29. data/spec/arel/engines/sql/unit/predicates/predicates_spec.rb +12 -0
  30. data/spec/arel/engines/sql/unit/primitives/attribute_spec.rb +24 -1
  31. data/spec/arel/engines/sql/unit/primitives/expression_spec.rb +5 -1
  32. data/spec/arel/engines/sql/unit/primitives/literal_spec.rb +10 -2
  33. data/spec/arel/engines/sql/unit/relations/alias_spec.rb +11 -1
  34. data/spec/arel/engines/sql/unit/relations/delete_spec.rb +23 -3
  35. data/spec/arel/engines/sql/unit/relations/from_spec.rb +16 -2
  36. data/spec/arel/engines/sql/unit/relations/group_spec.rb +18 -2
  37. data/spec/arel/engines/sql/unit/relations/having_spec.rb +12 -3
  38. data/spec/arel/engines/sql/unit/relations/insert_spec.rb +37 -1
  39. data/spec/arel/engines/sql/unit/relations/join_spec.rb +53 -11
  40. data/spec/arel/engines/sql/unit/relations/lock_spec.rb +25 -0
  41. data/spec/arel/engines/sql/unit/relations/order_spec.rb +52 -4
  42. data/spec/arel/engines/sql/unit/relations/project_spec.rb +38 -5
  43. data/spec/arel/engines/sql/unit/relations/skip_spec.rb +10 -1
  44. data/spec/arel/engines/sql/unit/relations/table_spec.rb +26 -5
  45. data/spec/arel/engines/sql/unit/relations/take_spec.rb +18 -1
  46. data/spec/arel/engines/sql/unit/relations/update_spec.rb +47 -1
  47. data/spec/arel/engines/sql/unit/relations/where_spec.rb +18 -2
  48. data/spec/connections/oracle_connection.rb +19 -0
  49. data/spec/schemas/mysql_schema.rb +2 -1
  50. data/spec/schemas/oracle_schema.rb +20 -0
  51. data/spec/schemas/postgresql_schema.rb +2 -1
  52. data/spec/schemas/sqlite3_schema.rb +2 -1
  53. data/spec/spec_helper.rb +16 -7
  54. metadata +31 -9
@@ -0,0 +1,20 @@
1
+ ActiveRecord::Schema.define do
2
+ suppress_messages do
3
+ create_table :users, :primary_key_trigger => true, :force => true do |t|
4
+ t.string :name, :limit => 255, :null => false
5
+ end
6
+
7
+ create_table :photos, :primary_key_trigger => true, :force => true do |t|
8
+ t.integer :user_id
9
+ t.integer :camera_id
10
+ end
11
+
12
+ create_table :developers, :primary_key_trigger => true, :force => true do |t|
13
+ t.string :name, :limit => 255, :null => false
14
+ t.integer :salary
15
+ t.string :department, :limit => 255, :null => false
16
+ t.timestamp :created_at, :null => false
17
+ end
18
+
19
+ end
20
+ end
@@ -16,7 +16,8 @@ sql = <<-SQL
16
16
  id SERIAL PRIMARY KEY NOT NULL,
17
17
  name VARCHAR(255) NOT NULL,
18
18
  salary INTEGER NOT NULL,
19
- department VARCHAR(255) NOT NULL
19
+ department VARCHAR(255) NOT NULL,
20
+ created_at TIMESTAMP NOT NULL
20
21
  );
21
22
  SQL
22
23
 
@@ -16,7 +16,8 @@ sql = <<-SQL
16
16
  id INTEGER NOT NULL PRIMARY KEY,
17
17
  name VARCHAR(255) NOT NULL,
18
18
  salary INTEGER NOT NULL,
19
- department VARCHAR(255) NOT NULL
19
+ department VARCHAR(255) NOT NULL,
20
+ created_at TIMESTAMP NOT NULL
20
21
  );
21
22
  SQL
22
23
 
data/spec/spec_helper.rb CHANGED
@@ -12,18 +12,21 @@ require 'arel'
12
12
  end
13
13
 
14
14
  module AdapterGuards
15
- def adapter_is(name)
16
- verify_adapter_name(name)
17
- yield if name.to_s == adapter_name
15
+ def adapter_is(*names)
16
+ names = names.map(&:to_s)
17
+ names.each{|name| verify_adapter_name(name)}
18
+ yield if names.include? adapter_name
18
19
  end
19
20
 
20
- def adapter_is_not(name)
21
- verify_adapter_name(name)
22
- yield if name.to_s != adapter_name
21
+ def adapter_is_not(*names)
22
+ names = names.map(&:to_s)
23
+ names.each{|name| verify_adapter_name(name)}
24
+ yield unless names.include? adapter_name
23
25
  end
24
26
 
25
27
  def adapter_name
26
28
  name = ActiveRecord::Base.configurations["unit"][:adapter]
29
+ name = 'oracle' if name == 'oracle_enhanced'
27
30
  verify_adapter_name(name)
28
31
  name
29
32
  end
@@ -33,7 +36,7 @@ module AdapterGuards
33
36
  end
34
37
 
35
38
  def valid_adapters
36
- %w[mysql postgresql sqlite3]
39
+ %w[mysql postgresql sqlite3 oracle]
37
40
  end
38
41
  end
39
42
 
@@ -53,3 +56,9 @@ Spec::Runner.configure do |config|
53
56
  Arel::Table.engine = Arel::Sql::Engine.new(ActiveRecord::Base)
54
57
  end
55
58
  end
59
+
60
+ # load corresponding adapter using ADAPTER environment variable when running single *_spec.rb file
61
+ if adapter = ENV['ADAPTER']
62
+ require "#{dir}/connections/#{adapter}_connection.rb"
63
+ require "#{dir}/schemas/#{adapter}_schema.rb"
64
+ end
metadata CHANGED
@@ -1,7 +1,12 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: arel
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.1
4
+ prerelease: false
5
+ segments:
6
+ - 0
7
+ - 3
8
+ - 0
9
+ version: 0.3.0
5
10
  platform: ruby
6
11
  authors:
7
12
  - Bryan Helmkamp
@@ -11,19 +16,24 @@ autorequire:
11
16
  bindir: bin
12
17
  cert_chain: []
13
18
 
14
- date: 2010-02-05 00:00:00 -05:00
19
+ date: 2010-03-10 00:00:00 -03:00
15
20
  default_executable:
16
21
  dependencies:
17
22
  - !ruby/object:Gem::Dependency
18
23
  name: activesupport
19
- type: :runtime
20
- version_requirement:
21
- version_requirements: !ruby/object:Gem::Requirement
24
+ prerelease: false
25
+ requirement: &id001 !ruby/object:Gem::Requirement
22
26
  requirements:
23
27
  - - ">="
24
28
  - !ruby/object:Gem::Version
29
+ segments:
30
+ - 3
31
+ - 0
32
+ - 0
33
+ - beta
25
34
  version: 3.0.0.beta
26
- version:
35
+ type: :runtime
36
+ version_requirements: *id001
27
37
  description: |-
28
38
  Arel is a Relational Algebra for Ruby. It 1) simplifies the generation complex
29
39
  of SQL queries and it 2) adapts to various RDBMS systems. It is intended to be
@@ -90,6 +100,11 @@ files:
90
100
  - lib/arel/engines/memory/relations/writes.rb
91
101
  - lib/arel/engines/sql.rb
92
102
  - lib/arel/engines/sql/christener.rb
103
+ - lib/arel/engines/sql/compilers/ibm_db_compiler.rb
104
+ - lib/arel/engines/sql/compilers/mysql_compiler.rb
105
+ - lib/arel/engines/sql/compilers/oracle_compiler.rb
106
+ - lib/arel/engines/sql/compilers/postgresql_compiler.rb
107
+ - lib/arel/engines/sql/compilers/sqlite_compiler.rb
93
108
  - lib/arel/engines/sql/core_extensions.rb
94
109
  - lib/arel/engines/sql/core_extensions/array.rb
95
110
  - lib/arel/engines/sql/core_extensions/nil_class.rb
@@ -100,6 +115,7 @@ files:
100
115
  - lib/arel/engines/sql/predicates.rb
101
116
  - lib/arel/engines/sql/primitives.rb
102
117
  - lib/arel/engines/sql/relations.rb
118
+ - lib/arel/engines/sql/relations/compiler.rb
103
119
  - lib/arel/engines/sql/relations/operations/alias.rb
104
120
  - lib/arel/engines/sql/relations/operations/join.rb
105
121
  - lib/arel/engines/sql/relations/relation.rb
@@ -167,6 +183,7 @@ files:
167
183
  - spec/arel/engines/sql/unit/relations/update_spec.rb
168
184
  - spec/arel/engines/sql/unit/relations/where_spec.rb
169
185
  - spec/connections/mysql_connection.rb
186
+ - spec/connections/oracle_connection.rb
170
187
  - spec/connections/postgresql_connection.rb
171
188
  - spec/connections/sqlite3_connection.rb
172
189
  - spec/doubles/hash.rb
@@ -174,6 +191,7 @@ files:
174
191
  - spec/matchers/disambiguate_attributes.rb
175
192
  - spec/matchers/hash_the_same_as.rb
176
193
  - spec/schemas/mysql_schema.rb
194
+ - spec/schemas/oracle_schema.rb
177
195
  - spec/schemas/postgresql_schema.rb
178
196
  - spec/schemas/sqlite3_schema.rb
179
197
  - spec/spec.opts
@@ -191,18 +209,20 @@ required_ruby_version: !ruby/object:Gem::Requirement
191
209
  requirements:
192
210
  - - ">="
193
211
  - !ruby/object:Gem::Version
212
+ segments:
213
+ - 0
194
214
  version: "0"
195
- version:
196
215
  required_rubygems_version: !ruby/object:Gem::Requirement
197
216
  requirements:
198
217
  - - ">="
199
218
  - !ruby/object:Gem::Version
219
+ segments:
220
+ - 0
200
221
  version: "0"
201
- version:
202
222
  requirements: []
203
223
 
204
224
  rubyforge_project: arel
205
- rubygems_version: 1.3.5
225
+ rubygems_version: 1.3.6
206
226
  signing_key:
207
227
  specification_version: 3
208
228
  summary: Arel is a relational algebra engine for Ruby
@@ -264,6 +284,7 @@ test_files:
264
284
  - spec/arel/engines/sql/unit/relations/update_spec.rb
265
285
  - spec/arel/engines/sql/unit/relations/where_spec.rb
266
286
  - spec/connections/mysql_connection.rb
287
+ - spec/connections/oracle_connection.rb
267
288
  - spec/connections/postgresql_connection.rb
268
289
  - spec/connections/sqlite3_connection.rb
269
290
  - spec/doubles/hash.rb
@@ -271,6 +292,7 @@ test_files:
271
292
  - spec/matchers/disambiguate_attributes.rb
272
293
  - spec/matchers/hash_the_same_as.rb
273
294
  - spec/schemas/mysql_schema.rb
295
+ - spec/schemas/oracle_schema.rb
274
296
  - spec/schemas/postgresql_schema.rb
275
297
  - spec/schemas/sqlite3_schema.rb
276
298
  - spec/spec_helper.rb