GSP
Quick Navigator

Search Site

Unix VPS
A - Starter
B - Basic
C - Preferred
D - Commercial
MPS - Dedicated
Previous VPSs
* Sign Up! *

Support
Contact Us
Online Help
Handbooks
Domain Status
Man Pages

FAQ
Virtual Servers
Pricing
Billing
Technical

Network
Facilities
Connectivity
Topology Map

Miscellaneous
Server Agreement
Year 2038
Credits
 

USA Flag

 

 

Man Pages


Manual Reference Pages  -  DBIX::CLASS::HELPER::SCHEMA::LINTCONTENTS (3)

.ds Aq ’

NAME

DBIx::Class::Helper::Schema::LintContents - suite of methods to find violated "constraints"

CONTENTS

SYNOPSIS



 package MyApp::Schema;

 use parent DBIx::Class::Schema;

 __PACKAGE__->load_components(Helper::Schema::LintContents);

 1;



And later, somewhere else:



 say "Incorrectly Null Users:";
 for ($schema->null_check_source_auto(User)->all) {
    say *  . $_->id
 }

 say "Duplicate Users:";
 my $duplicates = $schema->dup_check_source_auto(User);
 for (keys %$duplicates) {
    say "Constraint: $_";
    for ($duplicates->{$_}->all) {
       say *  . $_->id
    }
 }

 say "Users with invalid FKs:";
 my $invalid_fks = $schema->fk_check_source_auto(User);
 for (keys %$invalid_fks) {
    say "Rel: $_";
    for ($invalid_fks->{$_}->all) {
       say *  . $_->id
    }
 }



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 constraints. To be clear, the constraints I mean are the ones you tell DBIx::Class about, real constraints are fairly sure to be followed.

METHODS

    fk_check_source



 my $busted = $schema->fk_check_source(
   User,
   Group,
   { group_id => id },
 );



fk_check_source takes three arguments, the first is the <B>fromB> source moniker of a relationship. The second is the <B>toB> 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 <B>fromB> source that do not have a corresponding <B>toB> row. To be clear, the example given above would return a resultset of User rows that have a group_id that points to a Group that does not exist.

    fk_check_source_auto



 my $broken = $schema->fk_check_source_auto(User);



fk_check_source_auto takes a single argument: the source to check. It will check all the foreign key (that is, belongs_to) relationships for missing... foreign 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.

    dup_check_source



 my $smashed = $schema->fk_check_source( Group, [id] );



dup_check_source takes two arguments, the first is the source moniker to be checked. The second is an arrayref of columns that should be 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 duplicates of other groups based on id.

    dup_check_source_auto



 my $ruined = $schema->dup_check_source_auto(Group);



dup_check_source_auto 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.

    null_check_source



 my $blarg = $schema->null_check_source(Group, [id]);



null_check_source 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.

    null_check_source_auto



 my $wrecked = $schema->null_check_source_auto(Group);



null_check_source_auto 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 is_nullable set to false.

AUTHOR

Arthur Axel fREW Schmidt <frioux+cpan@gmail.com>

COPYRIGHT AND LICENSE

This software is copyright (c) 2015 by Arthur Axel fREW Schmidt.

This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.

Search for    or go to Top of page |  Section 3 |  Main Index


perl v5.20.3 DBIX::CLASS::HELPER::SCHEMA::LINTCONTENTS (3) 2015-11-07

Powered by GSP Visit the GSP FreeBSD Man Page Interface.
Output converted with manServer 1.07.