App-DBCritic
view release on metacpan - search on metacpan
view release on metacpan or search on metacpan
lib/App/DBCritic/Policy/NoPrimaryKey.pm view on Meta::CPAN
package App::DBCritic::Policy::NoPrimaryKey;
# ABSTRACT: Check for DBIx::Class::Schema::ResultSources without primary keys
#pod =head1 SYNOPSIS
#pod
#pod use App::DBCritic;
#pod
#pod my $critic = App::DBCritic->new(
#pod dsn => 'dbi:Oracle:HR', username => 'scott', password => 'tiger');
#pod $critic->critique();
#pod
#pod =head1 DESCRIPTION
#pod
#pod This policy returns a violation if a
#pod L<DBIx::Class::ResultSource|DBIx::Class::ResultSource> has zero primary columns.
#pod
#pod =cut
use strict;
use utf8;
use Modern::Perl '2011'; ## no critic (Modules::ProhibitUseQuotedVersion)
our $VERSION = '0.023'; # VERSION
use Moo;
use Sub::Quote;
use namespace::autoclean -also => qr{\A _}xms;
has description => ( is => 'ro', default => quote_sub q{'No primary key'} );
#pod =attr description
#pod
#pod "No primary key"
#pod
#pod =cut
has explanation => (
is => 'ro',
default => quote_sub
q{'Tables should have one or more columns defined as a primary key.'},
);
#pod =attr explanation
#pod
#pod "Tables should have one or more columns defined as a primary key."
#pod
#pod =cut
sub violates {
my $source = shift->element;
return $source->name . ' has no primary key' if !$source->primary_columns;
return;
}
#pod =method violates
#pod
#pod Returns details if the
#pod L<"current element"|App::DBCritic::Policy>'s C<primary_columns>
#pod method returns nothing.
#pod
#pod =cut
with 'App::DBCritic::PolicyType::ResultSource';
#pod =attr applies_to
#pod
#pod This policy applies to L<ResultSource|DBIx::Class::ResultSource>s.
#pod
#pod =cut
1;
__END__
=pod
=encoding UTF-8
=for :stopwords Mark Gardner cpan testmatrix url annocpan anno bugtracker rt cpants
kwalitee diff irc mailto metadata placeholders metacpan
=head1 NAME
view all matches for this distributionview release on metacpan - search on metacpan
( run in 0.820 second using v1.00-cache-2.02-grep-82fe00e-cpan-72ae3ad1e6da )