# Can anyone see what is wrong with this code?

**URL:** <https://www.ruby-forum.com/t/can-anyone-see-what-is-wrong-with-this-code/89894>\
**Category:** Rails\
**Created:** [March 23, 2007, 4:17pm UTC](https://www.ruby-forum.com/t/can-anyone-see-what-is-wrong-with-this-code/89894 "2007-03-23T16:17:28Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![RJRJRJ](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/8491ac/32.png) [@RJRJRJ](https://www.ruby-forum.com/u/RJRJRJ)\
**Post date:** [March 23, 2007, 4:17pm UTC](https://www.ruby-forum.com/t/can-anyone-see-what-is-wrong-with-this-code/89894/1 "2007-03-23T16:17:28Z")

</div>

Using find by sql to get some results. The error is:

wrong number of arguments (0 for 1)  
#{RAILS\_ROOT}/app/models/result.rb:24:in `find\_by\_sql’

def self.get\_tests\_run(project)  
@project = Project.find(project)  
@builds = []  
@results = []  
@project.testsuite.each do |testsuite|  
testsuite.build.each do | build|  
@builds \<\< build.id  
end  
end  
now = Date.today  
count = 7  
7.times do  
@results \<\< Result.find\_by\_sql[“SELECT count(distinct(tcid)) FROM  
results WHERE build\_id in (?) and daterun \<= ?”, @builds,  
Date.new(now.year,now.month,now.day - count) ]  
count -= 1  
end  
@results  
end

I cannot see what is wrong with that find\_by\_sql statement.

thanks

RJ

---

<div class="post-metadata">

**Author:** ![RJRJRJ](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/8491ac/32.png) [@RJRJRJ](https://www.ruby-forum.com/u/RJRJRJ)\
**Post date:** [March 23, 2007, 5:24pm UTC](https://www.ruby-forum.com/t/can-anyone-see-what-is-wrong-with-this-code/89894/2 "2007-03-23T17:24:43Z")

</div>

Missing parentheses around the argument. You have square brackets for  
the SQL  
parameter substitution but no () for the argument list.

Neha C. wrote:

> ```
> @results = []
> 
> ```
> 
> Date.new(now.year,now.month,now.day - count) ]
> 
> –  
> Posted via [http://www.ruby-forum.com/](http://www.ruby-forum.com/).
> 
> >

–  
View this message in context:  
[http://www.nabble.com/Can-anyone-see-what-is-wrong-with-this-code--tf3454521.html#a9638351](http://www.nabble.com/Can-anyone-see-what-is-wrong-with-this-code--tf3454521.html#a9638351)  
Sent from the RubyOnRails Users mailing list archive at [Nabble.com](http://Nabble.com).
