Forum: Ruby on Rails Which postgresql adapter to use for rails core? How about pr

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
42172acdf3c6046f84d644cb0b94642c?d=identicon&s=25 Pat Maddox (pergesu)
on 2006-03-05 10:29
(Received via mailing list)
I wanted to fix some things up in the trunk, so I set up the databases
and ran the unit tests.  A bunch fail for postgres, and even more
error out.  I know of two postgresql adapters: postgres-pr and
ruby-postgres.  Strangely, they each fail different tests.  So if I
want to fix things up, which one should I be using?  For that matter,
which adapter should I be using for production?  Finding out that the
Rails unit tests blow up for postgresql is not very reassuring.

Pat
F3dc06f587d1ff4c7366b102bfda9204?d=identicon&s=25 David Mitchell (Guest)
on 2006-03-05 11:29
(Received via mailing list)
postgres-pr works very well for me - I've got a (private) Rails app
that moves loads of data into and out of Postgres with it, and it's
never given me any problem whatsoever.

Regards

Dave M.
5c19f2d52879a1e10670c7334ba4c7e3?d=identicon&s=25 Lugovoi Nikolai (Guest)
on 2006-03-05 11:35
(Received via mailing list)
I use ruby-postgres (C binding) - works well for me :)

Latest available ruby-postgres-20051221 driver by default internally
converts query results and returns Ruby values, not strings.
This is convenient when using it outside Rails w/o ActiveRecord.

As of rev3772 of rails and ruby-postgres-20051221  I had following 11
test failures:
- 8 about type mismatch - expected Time, got DateTime from driver for
TIMESTAMP columns.
- 2 about type mismatch - expected 't', got <true> from driver
- 1 related to this ticket: http://dev.rubyonrails.org/ticket/3114
- Failure in  test_reset_table_with_non_integer_pk(AdapterTest)
[./test/adapter_test.rb:56]

If I add to test/connections/native_postgresql/connection.rb:

require 'postgres'
PGconn.translate_results = false

then driver doesn't parse query results and only one test fails
[./test/adapter_test.rb:56].
59de94a56fd2c198f33d9515d1c05961?d=identicon&s=25 Tom Mornini (Guest)
on 2006-03-05 19:50
(Received via mailing list)
On Mar 5, 2006, at 2:33 AM, Lugovoi Nikolai wrote:

> I use ruby-postgres (C binding) - works well for me :)
>
> Latest available ruby-postgres-20051221 driver by default internally
> converts query results and returns Ruby values, not strings.
> This is convenient when using it outside Rails w/o ActiveRecord.

I just tried to update to the suggested version, and it broke tests.

It seems that version doesn't play nicely with migrations.

Columns defined nullable (either implicitly or explicity) don't get
created as nullable.

I'm curious about your comment on return values. With the release
version of the driver:

http://ruby.scripting.ca/postgres/archive/ruby-pos...

I get true/false for boolean, Date for date columns, and Time for
timestamp with Rail 1.0. Perhaps it's the Rails adapter doing the
conversion as opposed to the driver?

In short, I'm a big believer in using the latest version, but from
my perspective, the release version works perfectly with Rails 1.0,
and the snapshot version does not.

--
-- Tom Mornini
5c19f2d52879a1e10670c7334ba4c7e3?d=identicon&s=25 Lugovoi Nikolai (Guest)
on 2006-03-06 08:51
(Received via mailing list)
On 3/5/06, Tom Mornini <tmornini@infomania.com> wrote:
> It seems that version doesn't play nicely with migrations.
>
> Columns defined nullable (either implicitly or explicity) don't get
> created as nullable.
>

I doubt it is driver problem, as migrations are Rails feature.
What test failures you had except those I mentioned?

> I'm curious about your comment on return values. With the release
> version of the driver:
>
> http://ruby.scripting.ca/postgres/archive/ruby-pos...
>
> I get true/false for boolean, Date for date columns, and Time for
> timestamp with Rail 1.0. Perhaps it's the Rails adapter doing the
> conversion as opposed to the driver?
>

Yes, ActiveRecord performs conversion if the given value (from driver)
is a String.

And here is example of difference in driver behaviour:

ruby-postgres-0.7.1:
 c = PGconn.new; c.query("select true, false, 1, 2.4::float, 'test',
now()::date, now()")
=> [["t", "f", "1", "2.4", "test", "2006-03-06", "2006-03-06
09:39:56.859984+02"]]

ruby-postgres-20051221:
c = PGconn.new; c.query("select true, false, 1, 2.4::float, 'test',
now()::date, now()")
=> [[true, false, 1, 2.4, "test", #<Date: 4907601/2,0,2299161>,
#<DateTime: 212008390801712003/86400000000,1/12,2299161>]]

> In short, I'm a big believer in using the latest version, but from
> my perspective, the release version works perfectly with Rails 1.0,
> and the snapshot version does not.
>

As for me, snapshot version works better outside Rails :)
A63764f318f10379c8b51349b757cf4b?d=identicon&s=25 Jay Levitt (Guest)
on 2006-03-06 14:45
(Received via mailing list)
On Sun, 5 Mar 2006 21:26:55 +1100, David Mitchell wrote:

> postgres-pr works very well for me - I've got a (private) Rails app
> that moves loads of data into and out of Postgres with it, and it's
> never given me any problem whatsoever.

I've had trouble using postgres-pr on Windows with Webrick (development
mode, of course) - left running long enough over my VPN, it eventually
seems to lose its connection.  Of course, I can't say if that's
postgres-pr
or just the protocol itself, since AFAIK Windows still can't run the C
bindings.
59de94a56fd2c198f33d9515d1c05961?d=identicon&s=25 Tom Mornini (Guest)
on 2006-03-06 18:12
(Received via mailing list)
On Mar 5, 2006, at 11:48 PM, Lugovoi Nikolai wrote:

>>
>> It seems that version doesn't play nicely with migrations.
>>
>> Columns defined nullable (either implicitly or explicity) don't get
>> created as nullable.
>
> I doubt it is driver problem, as migrations are Rails feature.
> What test failures you had except those I mentioned?

Well, it's some sort of problem between the driver and Rails. The
same migrations work perfectly with ruby-postgres-0.7.1, but don't
work properly with ruby-postgres-20051221.

> Yes, ActiveRecord performs conversion if the given value (from driver)
> ruby-postgres-20051221:
> c = PGconn.new; c.query("select true, false, 1, 2.4::float, 'test',
> now()::date, now()")
> => [[true, false, 1, 2.4, "test", #<Date: 4907601/2,0,2299161>,
> #<DateTime: 212008390801712003/86400000000,1/12,2299161>]]
>
>> In short, I'm a big believer in using the latest version, but from
>> my perspective, the release version works perfectly with Rails 1.0,
>> and the snapshot version does not.

Yes, outside of Rails having the driver do the conversions would be
wonderful. Inside Rails they're already done, and migrations work
with the older version, so I'd recommend the older version under Rails.

--
-- Tom Mornini
This topic is locked and can not be replied to.