On Nov 17, 8:17 am, Filipe A de Assis Moreira <[email protected]>
wrote:
> Hi,
>
> First of all thank you very much for the wonderful and well designed
> ORM library you guys have built. I'm building an sinatra app using
> Jruby(1.5.5), DataMapper (1.0.2) and querying a legacy database (SQL
> Server 2000).
>
> The problem I'm having is when I try to do a raw SQL query using:
>     results = repository.adapter.select("SELECT TOP 10 DET_STOCK_CODE,
> SUM(DET_GROSS) FROM [Table name] GROUP BY DET_STOCK_CODE")
>
> I get the following error:
>
>   interning empty string
> ArgumentError: interning empty string
>         from /home/guto/.rvm/gems/jruby-1....@report-sinatra/gems/dm-do-
> adapter-1.0.2/lib/dm-do-adapter/adapter.rb:270:in `select_fields'
>         from /home/guto/.rvm/gems/jruby-1....@report-sinatra/gems/dm-do-
> adapter-1.0.2/lib/dm-do-adapter/adapter.rb:270:in `map'
>         from /home/guto/.rvm/gems/jruby-1....@report-sinatra/gems/dm-do-
> adapter-1.0.2/lib/dm-do-adapter/adapter.rb:270:in `select_fields'
>         from /home/guto/.rvm/gems/jruby-1....@report-sinatra/gems/dm-do-
> adapter-1.0.2/lib/dm-do-adapter/adapter.rb:39:in `select'
>         from /home/guto/.rvm/gems/jruby-1....@report-sinatra/gems/dm-do-
> adapter-1.0.2/lib/dm-do-adapter/adapter.rb:260:in `with_connection'
>         from /home/guto/.rvm/gems/jruby-1....@report-sinatra/gems/dm-do-
> adapter-1.0.2/lib/dm-do-adapter/adapter.rb:33:in `select'
>         from (irb):4
>
> Anyone has any ideas of what maybe happening?

You probably need to alias the SUM call:

  results = repository.adapter.select("SELECT TOP 10 DET_STOCK_CODE,
  SUM(DET_GROSS) AS SUM FROM [Table name] GROUP BY DET_STOCK_CODE")

One could argue that DataMapper should check whether the string is
empty before attempting to intern it, as Sequel does.

Jeremy

-- 
You received this message because you are subscribed to the Google Groups 
"DataMapper" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/datamapper?hl=en.

Reply via email to