Ruby on Rails Monday, November 22, 2010

I'm still having some problems with SQLserver adapter.

I have a model called Post, and I try to select a single post object
with Post.first in the rails console. But I get an error.

$ rails console
Loading development environment (Rails 3.0.2)
irb(main):001:0> fp = Post.first
ActiveRecord::StatementInvalid: ODBC::Error: 37000 (102) [Microsoft][SQL
Server Native Client 10.0][SQL Server]Incorrect syntax near '1'.: SELECT
[posts].* FROM [posts] LIMIT 1
from
c:/Ruby/lib/ruby/gems/1.8/gems/activerecord-3.0.2/lib/active_record/connection_adapters/abstract_adapter.rb:202:in
`log'
from
c:/Ruby/lib/ruby/gems/1.8/gems/activerecord-sqlserver-adapter-3.0.5/lib/active_record/connection_adapters/sqlserver/database_statements.rb:249:in
`raw_select
'


The correct SQL should be something like this "SELECT TOP (1) [posts].*
FROM [posts]" The LIMIT-part is mySQL-sql if I remember correctly, but
where can I change to use some real SQL?

--
Posted via http://www.ruby-forum.com/.

--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.

No comments:

Post a Comment