Revision history for Perl extension DBIx::DBSchema.
+0.37 unreleased
+ - Patch from Slavin Rezic <srezic@cpan.org> to prevent quoting around
+ numeric defaults in Pg.
+
0.36 Thu Dec 13 17:49:35 PST 2007
- Patch from ISHIGAKI@cpan.org to suppress unnecessary warnings about
undefined local_options, thanks!
use DBIx::DBSchema::ColGroup::Unique;
use DBIx::DBSchema::ColGroup::Index;
-$VERSION = "0.36";
+$VERSION = "0.37_01";
$VERSION = eval $VERSION; # modperlstyle: convert the string into a number
$DEBUG = 0;
use Carp;
use DBIx::DBSchema::_util qw(_load_driver _dbh);
-$VERSION = '0.11';
+$VERSION = '0.12';
=head1 NAME
my($self, $dbh) = ( shift, _dbh(@_) );
my $driver = $dbh ? _load_driver($dbh) : '';
+ my $driver_class = "DBIx::DBSchema::DBD::${driver}";
##
# type mapping
##
my %typemap;
- %typemap = eval "\%DBIx::DBSchema::DBD::${driver}::typemap" if $driver;
+ %typemap = eval "\%${driver_class}::typemap" if $driver;
my $type = defined( $typemap{uc($self->type)} )
? $typemap{uc($self->type)}
: $self->type;
my $default;
my $orig_default = $self->default;
- if ( defined($self->default) && !ref($self->default) && $self->default ne ''
+ if ( $driver_class->can("_column_value_needs_quoting") ) {
+ if ($driver_class->_column_value_needs_quoting($self)) {
+ $default = $dbh->quote($self->default);
+ } else {
+ $default = ref($self->default) ? ${$self->default} : $self->default;
+ }
+ } elsif ( defined($self->default) && !ref($self->default) && $self->default ne ''
&& ref($dbh)
# false laziness: nicked from FS::Record::_quote
&& ( $self->default !~ /^\-?\d+(\.\d+)?$/
use DBD::Pg 1.32;
use DBIx::DBSchema::DBD;
-$VERSION = '0.12';
+$VERSION = '0.13';
@ISA = qw(DBIx::DBSchema::DBD);
die "DBD::Pg version 1.32 or 1.41 (or later) required--".
}
+sub _column_value_needs_quoting {
+ my($proto, $col) = @_;
+ $col->type !~ m{^(
+ int(?:2|4|8)?
+ | smallint
+ | integer
+ | bigint
+ | (?:numeric|decimal)(?:\(\d+(?:\s*\,\s*\d+\))?)?
+ | real
+ | double\s+precision
+ | float(?:\(\d+\))?
+ | serial(?:4|8)?
+ | bigserial
+ )$}x;
+}
+
+
=head1 AUTHOR
Ivan Kohler <ivan-dbix-dbschema@420.am>