[freeside-commits] freeside/FS/FS Record.pm,1.112,1.113
Ivan,,,
ivan at wavetail.420.am
Tue Mar 14 20:17:11 PST 2006
Update of /home/cvs/cvsroot/freeside/FS/FS
In directory wavetail:/tmp/cvs-serv28349
Modified Files:
Record.pm
Log Message:
handle BIGSERIAL like SERIAL for the cdr table, and normalize canadian zip codes as well as us ones
Index: Record.pm
===================================================================
RCS file: /home/cvs/cvsroot/freeside/FS/FS/Record.pm,v
retrieving revision 1.112
retrieving revision 1.113
diff -u -d -r1.112 -r1.113
--- Record.pm 31 Jan 2006 02:59:59 -0000 1.112
+++ Record.pm 15 Mar 2006 04:17:08 -0000 1.113
@@ -285,7 +285,7 @@
if ( $op eq '=' ) {
if ( driver_name eq 'Pg' ) {
my $type = dbdef->table($table)->column($column)->type;
- if ( $type =~ /(int|serial)/i ) {
+ if ( $type =~ /(int|(big)?serial)/i ) {
qq-( $column IS NULL )-;
} else {
qq-( $column IS NULL OR $column = '' )-;
@@ -296,7 +296,7 @@
} elsif ( $op eq '!=' ) {
if ( driver_name eq 'Pg' ) {
my $type = dbdef->table($table)->column($column)->type;
- if ( $type =~ /(int|serial)/i ) {
+ if ( $type =~ /(int|(big)?serial)/i ) {
qq-( $column IS NOT NULL )-;
} else {
qq-( $column IS NOT NULL AND $column != '' )-;
@@ -365,7 +365,7 @@
grep defined( $record->{$_} ) && $record->{$_} ne '', @real_fields
) {
if ( $record->{$field} =~ /^\d+(\.\d+)?$/
- && dbdef->table($table)->column($field)->type =~ /(int|serial)/i
+ && dbdef->table($table)->column($field)->type =~ /(int|(big)?serial)/i
) {
$sth->bind_param($bind++, $record->{$field}, { TYPE => SQL_INTEGER } );
} else {
@@ -695,7 +695,7 @@
my $col = $self->dbdef_table->column($primary_key);
$db_seq =
- uc($col->type) eq 'SERIAL'
+ uc($col->type) =~ /^(BIG)?SERIAL\d?/
|| ( driver_name eq 'Pg'
&& defined($col->default)
&& $col->default =~ /^nextval\(/i
@@ -1026,7 +1026,7 @@
#false laziness w/qsearch
if ( driver_name eq 'Pg' ) {
my $type = $old->dbdef_table->column($_)->type;
- if ( $type =~ /(int|serial)/i ) {
+ if ( $type =~ /(int|(big)?serial)/i ) {
qq-( $_ IS NULL )-;
} else {
qq-( $_ IS NULL OR $_ = '' )-;
@@ -1498,12 +1498,23 @@
sub ut_zip {
my( $self, $field, $country ) = @_;
+
if ( $country eq 'US' ) {
- $self->getfield($field) =~ /\s*(\d{5}(\-\d{4})?)\s*$/
+
+ $self->getfield($field) =~ /^\s*(\d{5}(\-\d{4})?)\s*$/
or return gettext('illegal_zip'). " $field for country $country: ".
$self->getfield($field);
- $self->setfield($field,$1);
+ $self->setfield($field, $1);
+
+ } elsif ( $country eq 'CA' ) {
+
+ $self->getfield($field) =~ /^\s*([A-Z]\d[A-Z])\s*(\d[A-Z]\d)\s*$/i
+ or return gettext('illegal_zip'). " $field for country $country: ".
+ $self->getfield($field);
+ $self->setfield($field, "$1 $2");
+
} else {
+
if ( $self->getfield($field) =~ /^\s*$/
&& ( !$country || ! grep { $_ eq $country } @zip_reqd_countries )
)
@@ -1514,7 +1525,9 @@
or return gettext('illegal_zip'). " $field: ". $self->getfield($field);
$self->setfield($field,$1);
}
+
}
+
'';
}
More information about the freeside-commits
mailing list