X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=lib%2FSQL%2FTranslator%2FSchema%2FField.pm;h=d8680cb721021202d928d4d8632f62175913791b;hb=dd13bc8b07104583c80d8352bc51a0331a1b0547;hp=4adc293c3f0ab2ec3f7b6ef5d6cd4d25574d0e8a;hpb=68d75205c6994eb347f51726cea9bf3dbf28b498;p=dbsrgits%2FSQL-Translator.git diff --git a/lib/SQL/Translator/Schema/Field.pm b/lib/SQL/Translator/Schema/Field.pm index 4adc293..d8680cb 100644 --- a/lib/SQL/Translator/Schema/Field.pm +++ b/lib/SQL/Translator/Schema/Field.pm @@ -25,7 +25,7 @@ C is the field object. 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'; @@ -98,7 +98,7 @@ all the comments joined on newlines. 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{ [] }), ); @@ -201,7 +201,7 @@ Get or set the field's C attribute. has is_auto_increment => ( is => 'rw', - coerce => sub { $_[0] ? 1 : 0 }, + coerce => quote_sub(q{ $_[0] ? 1 : 0 }), builder => 1, lazy => 1, ); @@ -232,7 +232,7 @@ Returns whether or not the field is a foreign key. has is_foreign_key => ( is => 'rw', - coerce => sub { $_[0] ? 1 : 0 }, + coerce => quote_sub(q{ $_[0] ? 1 : 0 }), builder => 1, lazy => 1, ); @@ -273,7 +273,7 @@ foreign keys; checks) are represented as table constraints. has is_nullable => ( is => 'rw', - coerce => sub { $_[0] ? 1 : 0 }, + coerce => quote_sub(q{ $_[0] ? 1 : 0 }), default => quote_sub(q{ 1 }), ); @@ -294,7 +294,7 @@ a table constraint (should it?). has is_primary_key => ( is => 'rw', - coerce => sub { $_[0] ? 1 : 0 }, + coerce => quote_sub(q{ $_[0] ? 1 : 0 }), lazy => 1, builder => 1, ); @@ -321,6 +321,8 @@ Determine whether the field has a UNIQUE constraint or not. has is_unique => ( is => 'lazy', init_arg => undef ); +around is_unique => carp_ro('is_unique'); + sub _build_is_unique { my ( $self ) = @_;