pg.ddx.io pgsql-interfaces@postgresql.org mailing list archive
help / color / mirror / Atom feedDBD::Pg returns 1/0 for boolean field ...
2+ messages / 2 participants
[nested] [flat]
* DBD::Pg returns 1/0 for boolean field ...
@ 2005-11-07 05:17 Marc G. Fournier <scrappy@hub.org>
0 siblings, 1 reply; 2+ messages in thread
From: Marc G. Fournier @ 2005-11-07 05:17 UTC (permalink / raw)
To: pgsql-interfaces
'k, not sure if I'm overlooking something obvious here, but the query
below, when run through psql, returns 't' or 'f', as I'd expect:
SELECT vm.path, vm.company_id, vs.ip_address_id, vm.path AS root_path,
vm.vm_template_id, vt.mount_union
FROM vm_status vs
LEFT JOIN virtual_machine vm ON (vs.virtual_machine_id = vm.id)
LEFT JOIN vm_template vt ON (vm.vm_template_id = vt.id)
WHERE vs.stop_date IS NULL
AND vs.server_id IN (SELECT id
FROM server
WHERE server_name = ?
AND status_id = '1' );
But, when I run it DBI/DBD::Pg, I'm getting 1's and 0's ...
I'm reading the results as:
$get_hosts->execute($hostname);
$host_array = $get_hosts->fetchall_arrayref({});
foreach my $row (@$host_array) {
and printing the results as:
print $row->{'mount_union'} . "\n";
next;
Am I doing something wrong, that DBD::Pg is "converting" it to 1's and
0's? Or is this expected?
----
Marc G. Fournier Hub.Org Networking Services (http://www.hub.org)
Email: scrappy@hub.org Yahoo!: yscrappy ICQ: 7615664
^ permalink raw reply [nested|flat] 2+ messages in thread
* Re: DBD::Pg returns 1/0 for boolean field ...
@ 2005-11-07 13:01 Greg Sabino Mullane <greg@turnstep.com>
parent: Marc G. Fournier <scrappy@hub.org>
0 siblings, 0 replies; 2+ messages in thread
From: Greg Sabino Mullane @ 2005-11-07 13:01 UTC (permalink / raw)
To: pgsql-interfaces
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
> Am I doing something wrong, that DBD::Pg is "converting" it
> to 1's and 0's? Or is this expected?
That's expected: in Perl (and many other languages), both raw 't'
and 'f' are considered "true", so DBD::Pg does some mapping. Very
handy when you are passing things back and forth. You can turn this
behavior off with the pg_bool_tf attribute like this:
$dbh->{pg_bool_tf} = 1;
The default is 0. I'm going to move the explanation for this higher
up on the DBD::Pg docs page.
- --
Greg Sabino Mullane greg@turnstep.com
PGP Key: 0x14964AC8 200511070758
http://biglumber.com/x/web?pk=2529DF6AB8F79407E94445B4BC9B906714964AC8
-----BEGIN PGP SIGNATURE-----
iD8DBQFDb1AZvJuQZxSWSsgRAj5VAKDSgrNIeTUAlDNEjs1mfQ7ygqkSewCfdkEv
A8jdzpObzN5D8xA4dYIjmZ8=
=l8T8
-----END PGP SIGNATURE-----
^ permalink raw reply [nested|flat] 2+ messages in thread
end of thread, other threads:[~2005-11-07 13:01 UTC | newest]
Thread overview: 2+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2005-11-07 05:17 DBD::Pg returns 1/0 for boolean field ... Marc G. Fournier <scrappy@hub.org>
2005-11-07 13:01 ` Greg Sabino Mullane <greg@turnstep.com>
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox