has $_ => (
is => 'rw',
default => quote_sub(q{ 0 }),
- coerce => sub { $_[0] ? 1 : 0 },
+ coerce => quote_sub(q{ $_[0] ? 1 : 0 }),
) foreach qw(add_drop_table no_comments show_warnings trace validate);
# quote_identifiers is on by default, use a 0-but-true as indicator
has quote_identifiers => (
is => 'rw',
default => quote_sub(q{ '0E0' }),
- coerce => sub { $_[0] || 0 },
+ coerce => quote_sub(q{ $_[0] || 0 }),
);
sub quote_table_names {
package SQL::Translator::Role::Debug;
use Moo::Role;
+use Sub::Quote qw(quote_sub);
has _DEBUG => (
is => 'rw',
accessor => 'debugging',
init_arg => 'debugging',
- coerce => sub { $_[0] ? 1 : 0 },
+ coerce => quote_sub(q{ $_[0] ? 1 : 0 }),
lazy => 1,
builder => 1,
);
=cut
-has deferrable => ( is => 'rw', coerce => sub { $_[0] ? 1 : 0 }, default => quote_sub(q{ 1 }) );
+has deferrable => ( is => 'rw', coerce => quote_sub(q{ $_[0] ? 1 : 0 }), default => quote_sub(q{ 1 }) );
=head2 expression
has match_type => (
is => 'rw',
default => quote_sub(q{ '' }),
- coerce => sub { lc $_[0] },
+ coerce => quote_sub(q{ lc $_[0] }),
isa => sub {
my $arg = $_[0];
throw("Invalid match type: $arg")
throw("Invalid constraint type: $_[0]")
if $_[0] && !$VALID_CONSTRAINT_TYPE{ $_[0] };
},
- coerce => sub { (my $t = $_[0]) =~ s/_/ /g; uc $t },
+ coerce => quote_sub(q{ (my $t = $_[0]) =~ s/_/ /g; uc $t }),
);
around type => \&ex2err;
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 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,
);
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,
);
=cut
-has name => ( is => 'rw', coerce => sub { defined $_[0] ? $_[0] : '' }, default => quote_sub(q{ '' }) );
+has name => ( is => 'rw', coerce => quote_sub(q{ defined $_[0] ? $_[0] : '' }), default => quote_sub(q{ '' }) );
=head2 options
my $type = uc $_[0] or return;
throw("Invalid index type: $type") unless $VALID_INDEX_TYPE{$type};
},
- coerce => sub { uc $_[0] },
+ coerce => quote_sub(q{ uc $_[0] }),
default => quote_sub(q{ 'NORMAL' }),
);
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 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 perform_action_when => (
is => 'rw',
- coerce => sub { defined $_[0] ? lc $_[0] : $_[0] },
+ coerce => quote_sub(q{ defined $_[0] ? lc $_[0] : $_[0] }),
isa => sub {
throw("Invalid argument '$_[0]' to perform_action_when")
if defined $_[0] and $_[0] !~ m/^(before|after)$/i;
has database_events => (
is => 'rw',
- coerce => sub { [ map { lc } ref $_[0] eq 'ARRAY' ? @{$_[0]} : ($_[0]) ] },
+ coerce => quote_sub(q{ [ map { lc } ref $_[0] eq 'ARRAY' ? @{$_[0]} : ($_[0]) ] }),
isa => sub {
my @args = @{$_[0]};
my %valid = map { $_, 1 } qw[ insert update update_on delete ];