| 1 | package Rose::DB::Object::Metadata::Column::Numeric; | ||
| 2 | |||
| 3 | use strict; | ||
| 4 | |||
| 5 | use Rose::Object::MakeMethods::Generic; | ||
| 6 | |||
| 7 | use Rose::DB::Object::Metadata::Column::Scalar; | ||
| 8 | our @ISA = qw(Rose::DB::Object::Metadata::Column::Scalar); | ||
| 9 | |||
| 10 | our $VERSION = '0.812'; | ||
| 11 | |||
| 12 | __PACKAGE__->delete_common_method_maker_argument_names('length'); | ||
| 13 | |||
| 14 | __PACKAGE__->add_common_method_maker_argument_names | ||
| 15 | ( | ||
| 16 | qw(precision scale) | ||
| 17 | ); | ||
| 18 | |||
| 19 | Rose::Object::MakeMethods::Generic->make_methods | ||
| 20 | ( | ||
| 21 | { preserve_existing => 1 }, | ||
| 22 | scalar => [ __PACKAGE__->common_method_maker_argument_names ] | ||
| 23 | ); | ||
| 24 | |||
| 25 | sub type { 'numeric' } | ||
| 26 | |||
| 27 | sub should_inline_value | ||
| 28 | { | ||
| 29 | my($self, $db, $value) = @_; | ||
| 30 | no warnings 'uninitialized'; | ||
| 31 | return (($db->validate_numeric_keyword($value) && $db->should_inline_numeric_keyword($value)) || | ||
| 32 | ($db->keyword_function_calls && $value =~ /^\w+\(.*\)$/)) ? 1 : 0; | ||
| 33 | } | ||
| 34 | |||
| 35 | sub init_with_dbi_column_info | ||
| 36 | { | ||
| 37 | my($self, $col_info) = @_; | ||
| 38 | |||
| 39 | $self->precision(defined $col_info->{'NUMERIC_PRECISION'} ? | ||
| 40 | $col_info->{'NUMERIC_PRECISION'} : $col_info->{'COLUMN_SIZE'}); | ||
| 41 | |||
| 42 | $self->scale(defined $col_info->{'NUMERIC_SCALE'} ? | ||
| 43 | $col_info->{'NUMERIC_SCALE'} : $col_info->{'DECIMAL_DIGITS'}); | ||
| 44 | |||
| 45 | # Prevent COLUMN_SIZE from setting bogus length in superclass | ||
| 46 | delete $col_info->{'COLUMN_SIZE'}; | ||
| 47 | |||
| 48 | $self->SUPER::init_with_dbi_column_info($col_info); | ||
| 49 | |||
| 50 | return; | ||
| 51 | } | ||
| 52 | |||
| 53 | sub perl_column_definition_attributes | ||
| 54 | { | ||
| 55 | grep { $_ ne 'length' } shift->SUPER::perl_column_definition_attributes; | ||
| 56 | } | ||
| 57 | |||
| 58 | 1; | ||
| 59 | |||
| 60 | __END__ |