Postgres gem & hashes

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

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

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

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

···

On Feb 26, 11:05 am, jef peeraer <jef.peeraer@somewhere> wrote:

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

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

···

On Mon, 5 Mar 2007, Bertram Scharpf wrote:

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

--
be kind whenever possible... it is always possible.
- the dalai lama

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

···

On Mon, 2007-03-05 at 12:25 +0900, Bertram Scharpf wrote:

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.

Hi Jeff,

> > 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.

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

···

Am Dienstag, 06. Mär 2007, 05:49:30 +0900 schrieb Jeff Davis:

On Mon, 2007-03-05 at 12:25 +0900, Bertram Scharpf wrote:
> Am Montag, 26. Feb 2007, 18:05:38 +0900 schrieb jef peeraer:

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

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

···

On Tue, 2007-03-06 at 10:02 +0900, Bertram Scharpf wrote:

Hi Jeff,

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.

> 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.

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&gt;
  <http://opensource.bertram-scharpf.de/distfiles/ruby-postgres-0.7.1q.tar.gz&gt;

There is a Gentoo overlay at

  <http://opensource.bertram-scharpf.de/layman/bscharpf-overlays.xml&gt;

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

I'm in suspense for your version.

Bertram

···

Am Mittwoch, 07. Mär 2007, 03:38:55 +0900 schrieb Jeff Davis:

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