postgres gem & hashes

J

jef peeraer

hi,

i am a real postgresql addict so i installed postgres gem ( which is
version 0.7.1, i think). Everything works like a charm, but there is
some basic functionality i miss : i want to return tupples in a hash
instead of an array. As an former PHP user, this was a basic thing to
do. I googled a bit, and found some posts about a new version ( 0.8 ),
which could handle these hashes. But the actual gem is 0.7.1 .
What can i do ?


jef peeraer
 
B

Bertram Scharpf

Hi,

Am Montag, 26. Feb 2007, 18:05:38 +0900 schrieb jef peeraer:
i am a real postgresql addict so i installed postgres gem ( which is
version 0.7.1, i think). Everything works like a charm, but there is
some basic functionality i miss : i want to return tupples in a hash
instead of an array. As an former PHP user, this was a basic thing to
do. I googled a bit, and found some posts about a new version ( 0.8 ),
which could handle these hashes. But the actual gem is 0.7.1 .
What can i do ?

Write your own patch. I really mean it; it's not so
difficult.

I don't actually understand what the feature is you are
missing. Could you describe it more precisely? Maybe one of
my patches is appropriate.

Bertram
 
A

ara.t.howard

Hi,

Am Montag, 26. Feb 2007, 18:05:38 +0900 schrieb jef peeraer:

Write your own patch. I really mean it; it's not so
difficult.

I don't actually understand what the feature is you are
missing. Could you describe it more precisely? Maybe one of
my patches is appropriate.

Bertram

arrayfields makes this very easy:


fortytwo :~ > cat a.rb
require 'rubygems'
require 'postgres'
require 'arrayfields'

pgconn = PGconn.new

pgconn.exec <<-sql
drop table t
sql

pgconn.exec <<-sql
create table t(
x text,
y text
)
sql

pgconn.exec <<-sql
insert into t values ('foo', 'bar');
insert into t values ('a', 'b');
sql

result = pgconn.exec <<-sql
select * from t;
sql

result.each do |row|
row.fields = result.fields
p row.values_at('x', 'y')
p row['x']
p row['y']
end


fortyytwo :~ > ruby a.rb
["foo", "bar"]
"foo"
"bar"
["a", "b"]
"a"
"b"


in fact, it was for the postgres library that i coded it.

regards.

-a
 
J

Jeff Davis

Hi,

Am Montag, 26. Feb 2007, 18:05:38 +0900 schrieb jef peeraer:

Write your own patch. I really mean it; it's not so
difficult.

It's not difficult to write the patch, I have patches of my own that I
would like accepted, but the maintainer is not being responsive.

Regards,
Jeff Davis
 
B

Bertram Scharpf

Hi Jeff,

Am Dienstag, 06. M=E4r 2007, 05:49:30 +0900 schrieb Jeff Davis:
=20
It's not difficult to write the patch, I have patches of my own that I
would like accepted, but the maintainer is not being responsive.

(Concerning the OP's request there is some code in `plruby'
that easiliy could be transposed.)

Dave Lee wrote me that my patch proposals sound reasonable.
One and a half years later I see they were meant well but
they were implemented poorly, then. The least I would have
expected is a request for an improvement. Now I ask myself
how to go forth.

Dave, if you read this, who decides when what patches to
include? If he doesn't, what about to fork the project?

Bertram


--=20
Bertram Scharpf
Stuttgart, Deutschland/Germany
http://www.bertram-scharpf.de
 
J

Jeff Davis

Bertram,

(Concerning the OP's request there is some code in `plruby'
that easiliy could be transposed.)

For some reason I don't see the reference to "plruby". But I think it's
a good idea to look there for code, and to share code between projects
(if the licenses permit it).
Dave Lee wrote me that my patch proposals sound reasonable.
One and a half years later I see they were meant well but
they were implemented poorly, then. The least I would have
expected is a request for an improvement. Now I ask myself
how to go forth.

Are you saying you submitted patches or suggestions for improvement to
Dave Lee over a year ago?
Dave, if you read this, who decides when what patches to
include? If he doesn't, what about to fork the project?

It looks like a fork is the most likely outcome.

Regards,
Jeff Davis
 
S

Sharon Rosner

Hey Jef

You night want to take a look at Sequel - a new ORM library I released
a few days ago. It supports postgresql and does what you want (i.e.
fetching records as hashes). The docs are here:

http://sequel.rubyforge.org

It's alpha quality but it works pretty good for me. Let me know if you
need help getting started.

Sharon
 
B

Bertram Scharpf

Hi Jeff,

Am Mittwoch, 07. M=E4r 2007, 03:38:55 +0900 schrieb Jeff Davis:
Are you saying you submitted patches or suggestions for improvement to
Dave Lee over a year ago?

Dave's answer is from March 1st, 2006.
=20
It looks like a fork is the most likely outcome.

If you like, you may have a look at my versions. I made them
temporarily available at

<http://opensource.bertram-scharpf.de/distfiles/ruby-postgres-0.7.1p.tar.=
gz>
<http://opensource.bertram-scharpf.de/distfiles/ruby-postgres-0.7.1q.tar.=
gz>

There is a Gentoo overlay at

<http://opensource.bertram-scharpf.de/layman/bscharpf-overlays.xml>

Change log and documentation are not up-to-date.

I'm in suspense for your version.

Bertram


--=20
Bertram Scharpf
Stuttgart, Deutschland/Germany
http://www.bertram-scharpf.de
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,778
Messages
2,569,605
Members
45,238
Latest member
Top CryptoPodcasts

Latest Threads

Top