hassan
(Hassan Schroeder)
October 22, 2012, 2:31pm
1
What db version and database adapter are you using?
SELECT attnum, attname FROM pg_attribute LIMIT 10
=> [{"attnum"=>1, "attname"=>"proname"}, {"attnum"=>2,
"attname"=>"pronamespace"}, {"attnum"=>3, "attname"=>"proowner"},
{"attnum"=>4, "attname"=>"prolang"}, {"attnum"=>5,
"attname"=>"procost"}, {"attnum"=>6, "attname"=>"prorows"},
{"attnum"=>7, "attname"=>"provariadic"}, {"attnum"=>8,
"attname"=>"proisagg"}, {"attnum"=>9, "attname"=>"proiswindow"},
{"attnum"=>10, "attname"=>"prosecdef"}]
That's a quick test using activerecord-jdbcpostgresql-adapter (1.2.2)
with Rails 3.2.8, JRuby 1.7.0 preview2, postgres 9.1.3.
I’m doing a select_all(“SELECT attnum, attname FROM pg_attribute”) and the
resulting hash has attnum value as string, despite it being an integer
column in the database. Am I missing some switch that would turn on the
conversion?
What db version and database adapter are you using?
Postgres 9.1.6 and postgresql adapter.
SELECT attnum, attname FROM pg_attribute LIMIT 10
=> [{“attnum”=>1, “attname”=>“proname”}, {“attnum”=>2,
“attname”=>“pronamespace”}, {“attnum”=>3, “attname”=>“proowner”},
{“attnum”=>4, “attname”=>“prolang”}, {“attnum”=>5,
“attname”=>“procost”}, {“attnum”=>6, “attname”=>“prorows”},
{“attnum”=>7, “attname”=>“provariadic”}, {“attnum”=>8,
“attname”=>“proisagg”}, {“attnum”=>9, “attname”=>“proiswindow”},
{“attnum”=>10, “attname”=>“prosecdef”}]
That’s a quick test using activerecord-jdbcpostgresql-adapter (1.2.2)
with Rails 3.2.8, JRuby 1.7.0 preview2, postgres 9.1.3.
The adapter you’re using is for JRuby, I’m using native Ruby.
hassan
(Hassan Schroeder)
October 23, 2012, 11:27am
3
Right, just making the point that it's not a PostgreSQL issue, it's that
the adapter you're using is broken. Or at least not behaving as you'd
expect
And I just created a 1.9.3/MRI `rails new -d postgresql` app which
installed the pg 0.14.1 gem, and it returns integers as strings, so
at least the problem is reproducible.