ActiveRecord::Base.connection => duplicate values

Hello,

I’m trying to implement a free SQL sender, and I’m using this control:

def expert_mode_result

c = ActiveRecord::Base.connection
@result = c.execute(params[:expert_command])
render :partial => "expert_mode_result", :layout =>false

end # expert_mode_result

as a test, I’m sending this SQL:

SELECT nc8, nacer FROM masters LIMIT 1

and, in the web page, if I dump the @result, I get:


  • 0: “02011000”
    1: “1511”
    nc8: “02011000”
    nacer: “1511”

What I don’t understand, is why I’m getting 4 attributes, when I really
asked only for two, the nc8 and the nacer. I don’t know if it’s trying
to get the id.

If I send the same sql with the limit to 5, I’m also getting duplicate
values inside each element, and 4 attributes.

here’s the dump:


  • 0: “02011000”
    1: “1511”
    nc8: “02011000”
    nacer: “1511”
  • 0: “02011010”
    1: “1511”
    nc8: “02011010”
    nacer: “1511”
  • 0: 02011090
    1: “1511”
    nc8: 02011090
    nacer: “1511”
  • 0: “02012011”
    1: “1511”
    nc8: “02012011”
    nacer: “1511”
  • 0: 02012019
    1: “1511”
    nc8: 02012019
    nacer: “1511”

any idea ?

thanks,

rai

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs