Hi,
Looks like I have to be a member of Google Groups to post....
The issue is that a SELECT statement in a ruby method returns some but not all the fields requested, but the SELECT statement does return all the requested fields if pasted directly into a psql session. The code lines are:
conn = PG::Connection.open( :dbname => 'music' )
conn.exec( 'SELECT p.piece_title, p.piece_number, p.album_id, p.performance,
p.location, f.type, o.orch_name, t.first_name, t.last_name, x.first_name, x.last_name
FROM pieces p, form f, orchestras o, conductors t, composers x
WHERE p.id = 9 AND p.music_form = f.id AND p.orchestra = o.id AND p.conductor = t.id AND p.composer = x.id' ) do |res|
res.each do |row| p row.values
end
end
The fields missing from the output are
'x.first_name' and 'x.last_name'. The rest of the requested data is in the output.
Notice that columns in two of the tables each have names
first_name and
last_name. ALTERing first_name and last_name columns in one table to '
first_name1' and 'last_name1' produces the desired result using the (updated) ruby code.
Am I doing something stupid or wrong? Should I upload a pg_dump of the data?
This happens in Fedora 19 in pg 0.14.1 and pg 0.17.1, using
ruby 2.0.0p353 (2013-11-22 revision 43784) [x86_64-linux] and
postgres (PostgreSQL) 9.2.8.
Thanks for working on the pg gem. I like it a lot.
Stuart