public
Rubygem
Description: Extras for DataMapper, including bridges to DataObjects::Migrations and Merb::DataMapper
Homepage: http://datamapper.org
Clone URL: git://github.com/sam/dm-more.git
Add spec for operator. Modify to collect diverse query conditions.
foysavas (author)
Wed May 07 16:06:05 -0700 2008
commit  bebac7bec32cc34fbee3cfda20185870a934db87
tree    4d9249a2243c87ae12fb64d87e2b983ba7409590
parent  e3d72a8a9f1dd7fc68500c539e362444d6b118c6
...
3
4
5
6
7
8
9
10
11
 
12
13
14
15
 
 
16
17
18
...
3
4
5
 
 
 
 
 
 
6
7
8
9
10
11
12
13
14
15
0
@@ -3,16 +3,13 @@ module DataMapper
0
     class DataObjectsAdapter
0
       def count(repository, query)
0
         parameters = []
0
- parameters = query.conditions.collect do |prop,value|
0
- case value
0
- when Property then value.name
0
- else value
0
- end
0
- end
0
+ parameters = query.conditions.collect { |condition| condition.last }
0
         row_count = query(count_statement(query),*parameters).first.to_i
0
       end
0
       module SQL
0
         def count_statement(query)
0
+ qualify = query.links.any?
0
+
0
           sql = "SELECT COUNT(*) as row_count"
0
 
0
           sql << " FROM " << quote_table_name(query.model_name)
...
67
68
69
 
 
 
 
 
 
 
70
71
72
...
67
68
69
70
71
72
73
74
75
76
77
78
79
0
@@ -67,6 +67,13 @@ begin
0
         result.should eql(2)
0
       end
0
     end
0
+
0
+ it "should count with conditions with operators" do
0
+ repository(:sqlite3) do
0
+ result = Dragon.count(:toes_on_claw.gt => 3)
0
+ result.should eql(2)
0
+ end
0
+ end
0
   end
0
 
0
 rescue LoadError

Comments

    No one has commented yet.