.\" Automatically generated by Pod::Man 4.14 (Pod::Simple 3.43) .\" .\" Standard preamble: .\" ======================================================================== .de Sp \" Vertical space (when we can't use .PP) .if t .sp .5v .if n .sp .. .de Vb \" Begin verbatim text .ft CW .nf .ne \\$1 .. .de Ve \" End verbatim text .ft R .fi .. .\" Set up some character translations and predefined strings. \*(-- will .\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left .\" double quote, and \*(R" will give a right double quote. \*(C+ will .\" give a nicer C++. Capital omega is used to do unbreakable dashes and .\" therefore won't be available. \*(C` and \*(C' expand to `' in nroff, .\" nothing in troff, for use with C<>. .tr \(*W- .ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p' .ie n \{\ . ds -- \(*W- . ds PI pi . if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch . if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch . ds L" "" . ds R" "" . ds C` "" . ds C' "" 'br\} .el\{\ . ds -- \|\(em\| . ds PI \(*p . ds L" `` . ds R" '' . ds C` . ds C' 'br\} .\" .\" Escape single quotes in literal strings from groff's Unicode transform. .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" .\" If the F register is >0, we'll generate index entries on stderr for .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index .\" entries marked with X<> in POD. Of course, you'll have to process the .\" output yourself in some meaningful fashion. .\" .\" Avoid warning from groff about undefined register 'F'. .de IX .. .nr rF 0 .if \n(.g .if rF .nr rF 1 .if (\n(rF:(\n(.g==0)) \{\ . if \nF \{\ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . if !\nF==2 \{\ . nr % 0 . nr F 2 . \} . \} .\} .rr rF .\" ======================================================================== .\" .IX Title "DBIx::Class::Helper::Schema::LintContents 3pm" .TH DBIx::Class::Helper::Schema::LintContents 3pm "2022-12-06" "perl v5.36.0" "User Contributed Perl Documentation" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l .nh .SH "NAME" DBIx::Class::Helper::Schema::LintContents \- suite of methods to find violated "constraints" .SH "SYNOPSIS" .IX Header "SYNOPSIS" .Vb 1 \& package MyApp::Schema; \& \& use parent \*(AqDBIx::Class::Schema\*(Aq; \& \& _\|_PACKAGE_\|_\->load_components(\*(AqHelper::Schema::LintContents\*(Aq); \& \& 1; .Ve .PP And later, somewhere else: .PP .Vb 4 \& say "Incorrectly Null Users:"; \& for ($schema\->null_check_source_auto(\*(AqUser\*(Aq)\->all) { \& say \*(Aq* \*(Aq . $_\->id \& } \& \& say "Duplicate Users:"; \& my $duplicates = $schema\->dup_check_source_auto(\*(AqUser\*(Aq); \& for (keys %$duplicates) { \& say "Constraint: $_"; \& for ($duplicates\->{$_}\->all) { \& say \*(Aq* \*(Aq . $_\->id \& } \& } \& \& say "Users with invalid FK\*(Aqs:"; \& my $invalid_fks = $schema\->fk_check_source_auto(\*(AqUser\*(Aq); \& for (keys %$invalid_fks) { \& say "Rel: $_"; \& for ($invalid_fks\->{$_}\->all) { \& say \*(Aq* \*(Aq . $_\->id \& } \& } .Ve .SH "DESCRIPTION" .IX Header "DESCRIPTION" Some people think that constraints make their databases slower. As silly as that is, I have been in a similar situation! I'm here to help you, dear developers! Basically this is a suite of methods that allow you to find violated \*(L"constraints.\*(R" To be clear, the constraints I mean are the ones you tell DBIx::Class about, real constraints are fairly sure to be followed. .SH "METHODS" .IX Header "METHODS" .SS "fk_check_source" .IX Subsection "fk_check_source" .Vb 5 \& my $busted = $schema\->fk_check_source( \& \*(AqUser\*(Aq, \& \*(AqGroup\*(Aq, \& { group_id => \*(Aqid\*(Aq }, \& ); .Ve .PP \&\f(CW\*(C`fk_check_source\*(C'\fR takes three arguments, the first is the \fBfrom\fR source moniker of a relationship. The second is the \fBto\fR source or source moniker of a relationship. The final argument is a hash reference representing the columns of the relationship. The return value is a resultset of the \fBfrom\fR source that do not have a corresponding \fBto\fR row. To be clear, the example given above would return a resultset of \f(CW\*(C`User\*(C'\fR rows that have a \f(CW\*(C`group_id\*(C'\fR that points to a \&\f(CW\*(C`Group\*(C'\fR that does not exist. .SS "fk_check_source_auto" .IX Subsection "fk_check_source_auto" .Vb 1 \& my $broken = $schema\->fk_check_source_auto(\*(AqUser\*(Aq); .Ve .PP \&\f(CW\*(C`fk_check_source_auto\*(C'\fR takes a single argument: the source to check. It will check all the foreign key (that is, \f(CW\*(C`belongs_to\*(C'\fR) relationships for missing... \&\f(CW\*(C`foreign\*(C'\fR rows. The return value will be a hashref where the keys are the relationship name and the values are resultsets of the respective violated relationship. .SS "dup_check_source" .IX Subsection "dup_check_source" .Vb 1 \& my $smashed = $schema\->fk_check_source( \*(AqGroup\*(Aq, [\*(Aqid\*(Aq] ); .Ve .PP \&\f(CW\*(C`dup_check_source\*(C'\fR takes two arguments, the first is the source moniker to be checked. The second is an arrayref of columns that \*(L"should be\*(R" unique. The return value is a resultset of the source that duplicate the passed columns. So with the example above the resultset would return all groups that are \*(L"duplicates\*(R" of other groups based on \f(CW\*(C`id\*(C'\fR. .SS "dup_check_source_auto" .IX Subsection "dup_check_source_auto" .Vb 1 \& my $ruined = $schema\->dup_check_source_auto(\*(AqGroup\*(Aq); .Ve .PP \&\f(CW\*(C`dup_check_source_auto\*(C'\fR takes a single argument, which is the name of the resultsource in which to check for duplicates. It will return a hashref where they keys are the names of the unique constraints to be checked. The values will be resultsets of the respective duplicate rows. .SS "null_check_source" .IX Subsection "null_check_source" .Vb 1 \& my $blarg = $schema\->null_check_source(\*(AqGroup\*(Aq, [\*(Aqid\*(Aq]); .Ve .PP \&\f(CW\*(C`null_check_source\*(C'\fR tales two arguments, the first is the name of the source to check. The second is an arrayref of columns that should contain no nulls. The return value is simply a resultset of rows that contain nulls where they shouldn't be. .SS "null_check_source_auto" .IX Subsection "null_check_source_auto" .Vb 1 \& my $wrecked = $schema\->null_check_source_auto(\*(AqGroup\*(Aq); .Ve .PP \&\f(CW\*(C`null_check_source_auto\*(C'\fR takes a single argument, which is the name of the resultsource in which to check for nulls. The return value is simply a resultset of rows that contain nulls where they shouldn't be. This method automatically uses the configured columns that have \f(CW\*(C`is_nullable\*(C'\fR set to false. .SH "AUTHOR" .IX Header "AUTHOR" Arthur Axel \*(L"fREW\*(R" Schmidt .SH "COPYRIGHT AND LICENSE" .IX Header "COPYRIGHT AND LICENSE" This software is copyright (c) 2020 by Arthur Axel \*(L"fREW\*(R" Schmidt. .PP This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.