active_repository 0.2.1 → 0.2.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +8 -8
- data/lib/active_repository/adapters/default_adapter.rb +1 -0
- data/lib/active_repository/base.rb +1 -1
- data/lib/active_repository/sql_query_executor.rb +3 -3
- data/lib/active_repository/version.rb +1 -1
- data/lib/active_repository/writers.rb +1 -0
- data/spec/support/sql_query_shared_examples.rb +7 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
---
|
2
2
|
!binary "U0hBMQ==":
|
3
3
|
metadata.gz: !binary |-
|
4
|
-
|
4
|
+
MjliYTU5ODNhMzMyZThjNWI4MGRjYmJkMTI2ZmRmYzgyOTFkZGQ4OA==
|
5
5
|
data.tar.gz: !binary |-
|
6
|
-
|
6
|
+
NWJjYzEwNmVjN2NlYjVkNTM0ZTI1NjczYTZhOTA2MGU2Y2JhMjc1YQ==
|
7
7
|
!binary "U0hBNTEy":
|
8
8
|
metadata.gz: !binary |-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
NWFlMDExYTJmOGFmYzY1NzAxZmFjMDJiZDIwYmI5ZWNhMzhjMjI2NzkwM2Ey
|
10
|
+
NmVmODhlMzljMzAzYmU4YmJjNzZhNzAzYmVjOWZlMzhmYmIyNmZmOTk0NGNl
|
11
|
+
OTE2NDQxOGUzMzY4ZjM5MjZiYWM0MDEyMjk3ZmIwYTg5MmJjNDQ=
|
12
12
|
data.tar.gz: !binary |-
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
YWZkYTZjMGU2ODQ4OGNhNWJjMGZlMTY0ZWJkYTY0YTk0Y2EwNjFjN2JhOTFm
|
14
|
+
ODI3NzdjNDliMmQ4N2NkZjVhZmExNzU4ODdlNTEwZTNmYTdmZmVlZDk2MTY2
|
15
|
+
ZTIyNDNmNjVlMjQzMjliNjE4NzJlZWIyOTYwZmJkODRjOGUxNWQ=
|
@@ -150,7 +150,7 @@ module ActiveRepository
|
|
150
150
|
super(query)
|
151
151
|
else
|
152
152
|
objects = []
|
153
|
-
args = args.first.is_a?(Hash) ? args.first : args
|
153
|
+
args = args.first.is_a?(Hash) ? args.first : (args.first.is_a?(Array) ? args.first : args)
|
154
154
|
|
155
155
|
PersistenceAdapter.where(self, args).each do |object|
|
156
156
|
objects << self.serialize!(object.attributes)
|
@@ -7,7 +7,7 @@ module ActiveHash #:nodoc:
|
|
7
7
|
return args.first if args.size == 1
|
8
8
|
|
9
9
|
query = args.first
|
10
|
-
param = args.
|
10
|
+
param = args.delete_at(1)
|
11
11
|
|
12
12
|
param = convert_param(param)
|
13
13
|
|
@@ -24,7 +24,7 @@ module ActiveHash #:nodoc:
|
|
24
24
|
@operator.nil? ? @objects : @objects.send(@operator, execute(klass, @sub_query)).sort_by{ |o| o.id }
|
25
25
|
end
|
26
26
|
|
27
|
-
|
27
|
+
private
|
28
28
|
# Splits the first sub query from the rest of the query and returns it.
|
29
29
|
def divide_query
|
30
30
|
array = @query.split(" ")
|
@@ -87,7 +87,7 @@ module ActiveHash #:nodoc:
|
|
87
87
|
# Executes the #sub_quey defined operator filter
|
88
88
|
def execute_operator(klass, sub_query)
|
89
89
|
klass.all.select do |o|
|
90
|
-
field, attribute = convert_attrs(o.send(sub_query.first), sub_query[2])
|
90
|
+
field, attribute = convert_attrs(o.send(sub_query.first.gsub(/[\(\)]/, "")), sub_query[2])
|
91
91
|
|
92
92
|
field.blank? ? false : field.send(@operator, attribute)
|
93
93
|
end
|
@@ -306,6 +306,13 @@ shared_examples "and" do
|
|
306
306
|
records.first.id.should == 2
|
307
307
|
records.should == [Country.find(2), Country.find(4)]
|
308
308
|
end
|
309
|
+
|
310
|
+
it "integer attribute and condition" do
|
311
|
+
records = Country.where("id = 2 and language = 'English'")
|
312
|
+
records.count.should == 2
|
313
|
+
records.first.id.should == 2
|
314
|
+
records.should == [Country.find(2), Country.find(4)]
|
315
|
+
end
|
309
316
|
end
|
310
317
|
|
311
318
|
shared_examples "or" do
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: active_repository
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Caio Torres
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2013-
|
11
|
+
date: 2013-05-28 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: active_hash
|