Google Groups

Queries are returning integer columns as strings

Jim Cain Mar 10, 2012 1:23 PM
Posted in group: ruby-pg
For every table and every query I try that includes integer columns, they are returned as strings instead of numbers.

For example, I have created and populated a table:

create table alpha (id serial, name varchar(30));
insert into alpha (name) values ('Jim');

When I query this table using ruby-pg, the ID column is returned as a string:

irb(main):005:0> db.exec("select id,name from alpha"){|r| r.each {|t| p t}}
{"id"=>"1", "name"=>"Jim"}

What am I missing? Thanks for the help.