[Rt-commit] r4270 - in DBIx-SearchBuilder/trunk: . SearchBuilder
SearchBuilder/Handle
jesse at bestpractical.com
jesse at bestpractical.com
Thu Dec 8 15:59:28 EST 2005
Author: jesse
Date: Thu Dec 8 15:59:26 2005
New Revision: 4270
Modified:
DBIx-SearchBuilder/trunk/ (props changed)
DBIx-SearchBuilder/trunk/Changes
DBIx-SearchBuilder/trunk/META.yml
DBIx-SearchBuilder/trunk/SIGNATURE
DBIx-SearchBuilder/trunk/SearchBuilder.pm
DBIx-SearchBuilder/trunk/SearchBuilder/Handle/Pg.pm
DBIx-SearchBuilder/trunk/SearchBuilder/Record.pm
Log:
Modified: DBIx-SearchBuilder/trunk/Changes
==============================================================================
--- DBIx-SearchBuilder/trunk/Changes (original)
+++ DBIx-SearchBuilder/trunk/Changes Thu Dec 8 15:59:26 2005
@@ -1,5 +1,14 @@
Revision history for Perl extension DBIx::SearchBuilder.
+1.37_01 Thu Dec 8 15:56:50 EST 2005
+* Switched Postgres sequence lookups to use CURRVAL, rather than OIDs
+
+1.36 Fri Dec 2 18:04:21 EST 2005
+
+* Change to how we resolve virtual columns to deal with a
+ "no such attribute" bug in RT
+
+
1.35 Wed Nov 2 22:36:02 EST 2005
* Doc fixes and OrderBy cleanup from ruslan
Modified: DBIx-SearchBuilder/trunk/META.yml
==============================================================================
--- DBIx-SearchBuilder/trunk/META.yml (original)
+++ DBIx-SearchBuilder/trunk/META.yml Thu Dec 8 15:59:26 2005
@@ -1,5 +1,5 @@
name: DBIx-SearchBuilder
-version: 1.35
+version: 1.37_01
license: perl
distribution_type: module
build_requires:
Modified: DBIx-SearchBuilder/trunk/SIGNATURE
==============================================================================
--- DBIx-SearchBuilder/trunk/SIGNATURE (original)
+++ DBIx-SearchBuilder/trunk/SIGNATURE Thu Dec 8 15:59:26 2005
@@ -14,23 +14,23 @@
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
-SHA1 0931d3b2127e99ec1fb79af5a9e1791d857ddf46 Changes
+SHA1 461bb4c0cd03a13609519f18d27b5a729cb0ec6b Changes
SHA1 a71ea5816fa4a8c39c4bcf788e40e255fa8157cd MANIFEST
-SHA1 454a73d0e4c706506128a44ba6743510eca915dd META.yml
+SHA1 bd47f10b33fd1fdd5cbe0e8a4817e3b42def6457 META.yml
SHA1 9e2b77ea1e98ae5fb9cca3942c3ef34148778c00 Makefile.PL
SHA1 d7a41642c368f2a587587e09f9e815d434feebff README
SHA1 5a53d12d5cccd94845a6a7cc105cd9be34e20f1c ROADMAP
-SHA1 b153b49ea0e20795d013343377ff6863bdd8495a SearchBuilder.pm
-SHA1 cad09fba893819afb6606447d6af718d4cdd93e8 SearchBuilder/Handle.pm
-SHA1 3ae0584e86c7573b6bfda4d025193c970ba30b40 SearchBuilder/Handle/Informix.pm
-SHA1 861cee4205d1f367af5cc68b561fd37e38c1acf0 SearchBuilder/Handle/ODBC.pm
-SHA1 50069f9fbfec254371f4c295f517fb73e1c006b2 SearchBuilder/Handle/Oracle.pm
-SHA1 cc978e63ce39bd3166e4a33f64988e0909e1bfe6 SearchBuilder/Handle/Pg.pm
+SHA1 316134cb5afde591377f8e348ce85e3d8bafb5a5 SearchBuilder.pm
+SHA1 8ccaf1666c7a59bbae0f0236092d81bd8f3f687f SearchBuilder/Handle.pm
+SHA1 38b773e6069d3dc91308ea9e4f2ef322ddef9419 SearchBuilder/Handle/Informix.pm
+SHA1 25d73426d93cece304b6eea8c786b224e14e1b5c SearchBuilder/Handle/ODBC.pm
+SHA1 59871a88e8228ed27d216af9e9af0b76184fd41d SearchBuilder/Handle/Oracle.pm
+SHA1 3560138d8d201be5087bf97d90d2895799e99318 SearchBuilder/Handle/Pg.pm
SHA1 b2efe7b5c8fe4016dcbcfb4c0617b9123fa31934 SearchBuilder/Handle/SQLite.pm
-SHA1 494edbdaf8c9ba7c36fec4809d595051594a9c47 SearchBuilder/Handle/Sybase.pm
+SHA1 088e3584eb431d1467ef7ef45a1863da52b40ea6 SearchBuilder/Handle/Sybase.pm
SHA1 7fac6d8e867781f7d2007f8cc91bb7d9eadb1bfe SearchBuilder/Handle/mysql.pm
SHA1 f4f6ea88631e6310243b6351e8df11e1ec88b261 SearchBuilder/Handle/mysqlPP.pm
-SHA1 4c120acb54ab2f9f9531cb38a12e7d3eacf40d37 SearchBuilder/Record.pm
+SHA1 ba110977e392c87703c374e2268f4ef429c6e633 SearchBuilder/Record.pm
SHA1 a5201fbeca07c19669ce920a4d48e39634626c46 SearchBuilder/Record/Cachable.pm
SHA1 a15065e472797e2bfe8149f04d3bdc58f67a7a6d SearchBuilder/SchemaGenerator.pm
SHA1 446f59a1fa8fa631c908f1fe3ea671c7178c9270 SearchBuilder/Union.pm
@@ -60,7 +60,7 @@
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.1 (GNU/Linux)
-iD8DBQFDaYXQEi9d9xCOQEYRAkAvAJ0VDPBBu6L8ExC1tOwf3fvS8U8HrACdEtSu
-iAW6AGpQJw/NPloLG/JZgdg=
-=x3C0
+iD8DBQFDmJ4tEi9d9xCOQEYRAtADAKC7JDErn0+h05pckN9Hv492CGRgAQCfSGyL
+RYkalOJuBAgDZCniv6oMqyE=
+=e1m7
-----END PGP SIGNATURE-----
Modified: DBIx-SearchBuilder/trunk/SearchBuilder.pm
==============================================================================
--- DBIx-SearchBuilder/trunk/SearchBuilder.pm (original)
+++ DBIx-SearchBuilder/trunk/SearchBuilder.pm Thu Dec 8 15:59:26 2005
@@ -4,7 +4,7 @@
use strict;
use vars qw($VERSION);
-$VERSION = "1.35";
+$VERSION = "1.37_01";
use Clone qw();
Modified: DBIx-SearchBuilder/trunk/SearchBuilder/Handle/Pg.pm
==============================================================================
--- DBIx-SearchBuilder/trunk/SearchBuilder/Handle/Pg.pm (original)
+++ DBIx-SearchBuilder/trunk/SearchBuilder/Handle/Pg.pm Thu Dec 8 15:59:26 2005
@@ -58,27 +58,64 @@
sub Insert {
- my $self = shift;
+ my $self = shift;
my $table = shift;
-
- my $sth = $self->SUPER::Insert($table, @_ );
-
+ my %args = (@_);
+ my $sth = $self->SUPER::Insert( $table, %args );
+
unless ($sth) {
- return ($sth);
+ return ($sth);
+ }
+
+ if ( $args{'id'} || $args{'Id'} ) {
+ $self->{'id'} = $args{'id'} || $args{'Id'};
+ return ( $self->{'id'} );
+ }
+
+ my $sequence_name = $self->IdSequenceName($table);
+ unless ($sequence_name) { return ($sequence_name) } # Class::ReturnValue
+ my $seqsth = $self->dbh->prepare(
+ qq{SELECT CURRVAL('} . $sequence_name . qq{')} );
+ $seqsth->execute;
+ $self->{'id'} = $seqsth->fetchrow_array();
+
+ return ( $self->{'id'} );
+}
+
+
+=head2 IdSequenceName TABLE
+
+Takes a TABLE name and returns the name of the sequence of the primary key for that table.
+
+=cut
+
+sub IdSequenceName {
+ my $self = shift;
+ my $table = shift;
+
+ return $self->{'_sequences'}{$table} if (exists $self->{'_sequences'}{$table});
+ #Lets get the id of that row we just inserted
+ my $seq;
+ my $colinfosth = $self->dbh->column_info( undef, undef, lc($table), '%' );
+ while ( my $foo = $colinfosth->fetchrow_hashref ) {
+
+ # Regexp from DBIx::Class's Pg handle. Thanks to Marcus Ramberg
+ if ( defined $foo->{'COLUMN_DEF'}
+ && $foo->{'COLUMN_DEF'}
+ =~ m!^nextval\('"?([^"']+)"?'::(?:text|regclass)\)!i )
+ {
+ return $self->{'_sequences'}{$table} = $1;
+ }
+
}
+ my $ret = Class::ReturnValue->new();
+ $ret->as_error(
+ errno => '-1',
+ message => "Found no sequence for $table",
+ do_backtrace => undef
+ );
+ return ( $ret->return_value );
- #Lets get the id of that row we just inserted
- my $oid = $sth->{'pg_oid_status'};
- my $sql = "SELECT id FROM $table WHERE oid = ?";
- my @row = $self->FetchResult($sql, $oid);
- # TODO: Propagate Class::ReturnValue up here.
- unless ($row[0]) {
- print STDERR "Can't find $table.id for OID $oid";
- return(undef);
- }
- $self->{'id'} = $row[0];
-
- return ($self->{'id'});
}
Modified: DBIx-SearchBuilder/trunk/SearchBuilder/Record.pm
==============================================================================
--- DBIx-SearchBuilder/trunk/SearchBuilder/Record.pm (original)
+++ DBIx-SearchBuilder/trunk/SearchBuilder/Record.pm Thu Dec 8 15:59:26 2005
@@ -703,7 +703,7 @@
my $self = shift;
my $field = lc shift;
- $field = $self->_Accessible($field, "column") while $self->_Accessible($field, "column");
+ $field = $self->_Accessible($field, "column") if $self->_Accessible($field, "column");
if (!$self->{'fetched'}{$field} and my $id = $self->id() ) {
my $pkey = $self->_PrimaryKey();
More information about the Rt-commit
mailing list