use Moo;
use SQL::Translator::Schema::Constants;
use SQL::Translator::Types qw(schema_obj);
-use SQL::Translator::Utils qw(parse_list_arg ex2err throw);
+use SQL::Translator::Utils qw(parse_list_arg ex2err throw carp_ro);
use Sub::Quote qw(quote_sub);
extends 'SQL::Translator::Schema::Object';
use DBI qw(:sql_types);
-# Mapping from string to sql contstant
+# Mapping from string to sql constant
our %type_mapping = (
integer => SQL_INTEGER,
int => SQL_INTEGER,
+ tinyint => SQL_TINYINT,
smallint => SQL_SMALLINT,
- bigint => 9999, # DBI doesn't export a constatn for this. Le suck
+ bigint => SQL_BIGINT,
double => SQL_DOUBLE,
has comments => (
is => 'rw',
- coerce => sub { ref($_[0]) eq 'ARRAY' ? $_[0] : [$_[0]] },
+ coerce => quote_sub(q{ ref($_[0]) eq 'ARRAY' ? $_[0] : [$_[0]] }),
default => quote_sub(q{ [] }),
);
has default_value => ( is => 'rw' );
-=head2 extra
-
-Get or set the field's "extra" attibutes (e.g., "ZEROFILL" for MySQL).
-Accepts a hash(ref) of name/value pairs to store; returns a hash.
-
- $field->extra( qualifier => 'ZEROFILL' );
- my %extra = $field->extra;
-
-=cut
-
=head2 foreign_key_reference
Get or set the field's foreign key reference;
has is_auto_increment => (
is => 'rw',
- coerce => sub { $_[0] ? 1 : 0 },
+ coerce => quote_sub(q{ $_[0] ? 1 : 0 }),
builder => 1,
lazy => 1,
);
has is_foreign_key => (
is => 'rw',
- coerce => sub { $_[0] ? 1 : 0 },
+ coerce => quote_sub(q{ $_[0] ? 1 : 0 }),
builder => 1,
lazy => 1,
);
Get or set whether the field can be null. If not defined, then
returns "1" (assumes the field can be null). The argument is evaluated
-by Perl for True or False, so the following are eqivalent:
+by Perl for True or False, so the following are equivalent:
$is_nullable = $field->is_nullable(0);
$is_nullable = $field->is_nullable('');
has is_nullable => (
is => 'rw',
- coerce => sub { $_[0] ? 1 : 0 },
+ coerce => quote_sub(q{ $_[0] ? 1 : 0 }),
default => quote_sub(q{ 1 }),
);
has is_primary_key => (
is => 'rw',
- coerce => sub { $_[0] ? 1 : 0 },
+ coerce => quote_sub(q{ $_[0] ? 1 : 0 }),
lazy => 1,
builder => 1,
);
has is_unique => ( is => 'lazy', init_arg => undef );
+around is_unique => carp_ro('is_unique');
+
sub _build_is_unique {
my ( $self ) = @_;
around table => \&ex2err;
-=head2
+=head2 parsed_field
Returns the field exactly as the parser found it