}
}
-has sizeless_types => (
- is => 'lazy',
-);
-
sub _build_sizeless_types {
+{ map { $_ => 1 }
qw( tinyint smallint int integer bigint text bit image datetime ) }
$self->field_default($field),
}
-sub field_type_size {
- my ($self, $field) = @_;
-
- ($field->size && !$self->sizeless_types->{$field->data_type}
- ? '(' . $field->size . ')'
- : ''
- )
-}
-
sub field_autoinc { ( $_[1]->is_auto_increment ? 'IDENTITY' : () ) }
sub primary_key_constraint {
}
}
-has sizeless_types => (
- is => 'lazy',
-);
-
sub _build_sizeless_types { +{ text => 1 } }
sub _build_numeric_types { +{ int => 1, tinyint => 1 } }
$self->field_default($field),
}
-sub field_type_size {
- my ($self, $field) = @_;
-
- ($field->size && !$self->sizeless_types->{$field->data_type}
- ? '(' . $field->size . ')'
- : ''
- )
-}
-
1;
requires '_build_type_map';
requires '_build_numeric_types';
requires '_build_unquoted_defaults';
-requires 'field_type_size';
+requires '_build_sizeless_types';
requires 'quote';
has type_map => (
is => 'lazy',
);
+has sizeless_types => (
+ is => 'lazy',
+);
+
has unquoted_defaults => (
is => 'lazy',
);
($self->type_map->{$field_type} || $field_type).$self->field_type_size($field)
}
+sub field_type_size {
+ my ($self, $field) = @_;
+
+ ($field->size && !$self->sizeless_types->{$field->data_type}
+ ? '(' . $field->size . ')'
+ : ''
+ )
+}
+
sub fields {
my ($self, $table) = @_;
( map $self->field($_), $table->get_fields )