smql 0.0.4.4 → 0.0.4.5

Sign up to get free protection for your applications and to get access to all the features.
data/TODO CHANGED
@@ -1 +1,3 @@
1
1
  1) gem-plugin
2
+ 2) deprecated-warnings rails 3.1:
3
+ * DEPRECATION WARNING: primary_key_name is deprecated and will be removed from Rails 3.2 (use foreign_key instead).
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.0.4.4
1
+ 0.0.4.5
@@ -99,7 +99,7 @@ class SmqlToAR
99
99
  # Versuche das Objekt zu erkennen. Operator und Expected muessen passen.
100
100
  # Passt das Object, die Klasse instanzieren.
101
101
  def try_parse model, cols, op, val
102
- #p :self => name, :try_parse => op, :cols => cols, :with => self::Operator, :value => val, :expected => self::Expected, :model => model.name
102
+ #p :class => self, :self => name, :try_parse => op, :cols => cols, :with => self::Operator, :value => val, :expected => self::Expected, :model => model.name
103
103
  new model, cols, val if self::Operator === op and self::Expected.any?( &it === val)
104
104
  end
105
105
 
@@ -109,6 +109,7 @@ class SmqlToAR
109
109
  end
110
110
 
111
111
  def initialize model, cols, val
112
+ #p init: self, caller: caller
112
113
  @model, @cols = model, cols
113
114
  @value = case val
114
115
  when Hash, Range then val
@@ -151,7 +152,7 @@ class SmqlToAR
151
152
  # #=> ( givenname = 'Peter' OR surname = 'Peter' ) AND ( givenname = 'Mueller' OR surname = 'Mueller' )
152
153
  def build builder, table
153
154
  values = Hash[ @value.collect {|value| [ builder.vid, value ] } ]
154
- values.each {|k, v| builder.wobs k.sym => v }
155
+ values.each {|k, v| builder.wobs k.to_sym => v }
155
156
  if 1 == @cols.length
156
157
  @cols.each do |col|
157
158
  col.joins builder, table
@@ -177,7 +178,7 @@ class SmqlToAR
177
178
  Where = "%s NOT BETWEEN %s AND %s"
178
179
  Expected = [Range, lambda {|val| Array === val && 2 == val.length } ]
179
180
 
180
- def initialze model, cols, val
181
+ def initialize model, cols, val
181
182
  if Array === val && 2 == val.length
182
183
  f, l = val
183
184
  f, l = Time.parse(f), Time.parse(l) if f.kind_of? String
@@ -187,7 +188,7 @@ class SmqlToAR
187
188
  end
188
189
 
189
190
  def build builder, table
190
- builder.wobs (v1 = builder.vid) => @value.begin, (v2 = builder.vid) => @value.end
191
+ builder.wobs (v1 = builder.vid).to_sym => @value.begin, (v2 = builder.vid).to_sym => @value.end
191
192
  @cols.each do |col|
192
193
  col.joins builder, table
193
194
  builder.where self.class::Where % [ builder.column( table+col.path, col.col), v1, v2]
@@ -242,13 +243,19 @@ class SmqlToAR
242
243
  end
243
244
 
244
245
  def build builder, table
246
+ if 2 < @cols.first.second.length
247
+ b2, b3 = And, Or
248
+ else
249
+ b2, b3 = Or, And
250
+ end
251
+ b2 = b2.new builder
245
252
  @cols.each do |col, sub|
246
253
  model, *sub = sub
247
254
  t = table + col.path + [col.col]
248
255
  col.joins.each {|j, m| builder.joins table+j, m }
249
256
  builder.joins t, model
250
- b2 = 1 == sub.length ? builder : Or.new( builder)
251
- sub.each {|i| i.collect( &it.build( And.new( b2), t)) }
257
+ b4 = b3.new( b2)
258
+ sub.each {|i| i.collect( &it.build( And.new( b4), t)) }
252
259
  end
253
260
  self
254
261
  end
@@ -26,6 +26,9 @@ class SmqlToAR
26
26
  def to_sym() "smql_c#{@vid}".to_sym end
27
27
  alias sym to_sym
28
28
  def to_i() @vid end
29
+ def === other
30
+ to_s === other || to_sym === other || to_i === other || self == other || self === other
31
+ end
29
32
  end
30
33
 
31
34
  class Aliases < Hash
metadata CHANGED
@@ -6,8 +6,8 @@ version: !ruby/object:Gem::Version
6
6
  - 0
7
7
  - 0
8
8
  - 4
9
- - 4
10
- version: 0.0.4.4
9
+ - 5
10
+ version: 0.0.4.5
11
11
  platform: ruby
12
12
  authors:
13
13
  - Denis Knauf
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2011-11-22 00:00:00 +01:00
18
+ date: 2011-11-28 00:00:00 +01:00
19
19
  default_executable:
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency