Interchange6-Schema

 view release on metacpan or  search on metacpan

CHANGES  view on Meta::CPAN

   * Replace count method with has_rows in Message class (Peter Mottram).
   * Add ResultSet class for products including listing method (Peter Mottram).
   * Add priority column to NavigationProduct (Peter Mottram).
   * Add role 'user' to user on insert (Peter Mottram).
   * Remove anonymous and authenticated roles and adjust selling_price and
     tier_pricing (Peter Mottram).
   * Add DateTime and QuoteNames helpers to schema (Peter Mottram).

   [BUG FIXES]

   * Fix cascade relationships between User and UserRole classes (Peter Mottram).
   * Use left join for state relationship of Address class
     (Jeff Boes, Peter Mottram).
   * Fix problems with path method in Product class
     (Peter Mottram, GH #133, #145).
   * Overload delete in Address and OrderlinesShipping classes (Peter Mottram).

   [DOCUMENTATION]

   * Add note about MySQL strict mode settings and on_connect_do parameters
     to DatabaseSupport manual (Peter Mottram).

CHANGES  view on Meta::CPAN

   [TESTS]

   * Update PriceModifier tests (Peter Mottram).
   * Replace on_connect_call with on_connect_to in MySQL test role
     (Peter Mottram).
   * Add test for attribute_iterator method from Product class
     with hashref argument (Peter Mottram).
   * Clean up relationship tests (Peter Mottram).
   * Allow fixtures to avoid some foreign key constraints on clear_orders
     (Peter Mottram).
   * Add tests for Address delete cascades (Peter Mottram).
   * Add fixtures for ShipmentCarrier and ShipmentRate classes (Peter Mottram).
   * Remove pod tests from schema_sanity.t (Peter Mottram).

0.060 Thu Nov 27 16:30:51 2014 CET

   [BUG FIXES]

   * Fix many-to-many zones relationship in State class
     (GH #132, Grega Pompe, Peter Mottram).

lib/Interchange6/Schema/Result/Address.pm  view on Meta::CPAN


Type: has_many

Related object: L<Interchange6::Schema::Result::OrderlinesShipping>

=cut

has_many
  orderlines_shipping => "Interchange6::Schema::Result::OrderlinesShipping",
  { "foreign.addresses_id" => "self.addresses_id" },
  { cascade_copy           => 0, cascade_delete => 0 };

=head2 orders

Type: has_many

Related object: L<Interchange6::Schema::Result::Order>

=cut

has_many
  orders => "Interchange6::Schema::Result::Order",
  { "foreign.billing_addresses_id" => "self.addresses_id" },
  { cascade_copy                   => 0, cascade_delete => 0 };

=head2 user

Type: belongs_to

Related object: L<Interchange6::Schema::Result::User>

=cut

belongs_to

lib/Interchange6/Schema/Result/Attribute.pm  view on Meta::CPAN


Type: has_many

Related object: L<Interchange6::Schema::Result::AttributeValue>

=cut

has_many
  attribute_values => "Interchange6::Schema::Result::AttributeValue",
  { "foreign.attributes_id" => "self.attributes_id" },
  { cascade_copy            => 0, cascade_delete => 0 };

=head2 product_attributes

Type: has_many

Related object: L<Interchange6::Schema::Result::ProductAttribute>

=cut

has_many
  product_attributes => "Interchange6::Schema::Result::ProductAttribute",
  { "foreign.attributes_id" => "self.attributes_id" },
  { cascade_copy            => 0, cascade_delete => 0 };

=head2 navigation_attributes

Type: has_many

Related object: L<Interchange6::Schema::Result::NavigationAttribute>

=cut

has_many
  navigation_attributes => "Interchange6::Schema::Result::NavigationAttribute",
  { "foreign.attributes_id" => "self.attributes_id" },
  { cascade_copy            => 0, cascade_delete => 0 };

=head1 METHODS

=head2 new

Set default value of L</title> to L</name>.

=cut

sub new {

lib/Interchange6/Schema/Result/AttributeValue.pm  view on Meta::CPAN

Type: has_many

Related object: L<Interchange6::Schema::Result::ProductAttributeValue>

=cut

has_many
  product_attribute_values =>
  "Interchange6::Schema::Result::ProductAttributeValue",
  { "foreign.attribute_values_id" => "self.attribute_values_id" },
  { cascade_copy                  => 0, cascade_delete => 0 };

=head2 user_attribute_values

Type: has_many

Related object: L<Interchange6::Schema::Result::UserAttributeValue>

=cut

has_many
  user_attribute_values => "Interchange6::Schema::Result::UserAttributeValue",
  { "foreign.attribute_values_id" => "self.attribute_values_id" },
  { cascade_copy                  => 0, cascade_delete => 0 };

=head2 navigation_attribute_values

Type: has_many

Related object: L<Interchange6::Schema::Result::NavigationAttributeValue>

=cut

has_many
  navigation_attribute_values =>
  "Interchange6::Schema::Result::NavigationAttributeValue",
  { "foreign.attribute_values_id" => "self.attribute_values_id" },
  { cascade_copy                  => 0, cascade_delete => 0 };

=head1 METHODS

=head2 new

Set default value of L</title> to L</name>.

=cut

sub new {

lib/Interchange6/Schema/Result/Media.pm  view on Meta::CPAN


Type: has_many

Related object: L<Interchange6::Schema::Result::MediaProduct>

=cut

has_many
  media_products => "Interchange6::Schema::Result::MediaProduct",
  "media_id",
  { cascade_copy => 0, cascade_delete => 0 };

=head2 media_navigations

Type: has_many

Related object: L<Interchange6::Schema::Result::MediaNavigation>

=cut

has_many
  media_navigations => "Interchange6::Schema::Result::MediaNavigation",
  "media_id",
  { cascade_copy => 0, cascade_delete => 0 };

=head2 media_messages

Type: has_many

Related object: L<Interchange6::Schema::Result::MediaMessage>

=cut

has_many
  media_messages => "Interchange6::Schema::Result::MediaMessage",
  "media_id",
  { cascade_copy => 0, cascade_delete => 0 };

=head2 products

Type: many_to_many with product.

=cut

many_to_many products => "media_products", "product";

=head2 displays

lib/Interchange6/Schema/Result/MediaType.pm  view on Meta::CPAN


Type: has_many

Related object: L<Interchange6::Schema::Result::MediaDisplay>

=cut

has_many
  media_displays => "Interchange6::Schema::Result::MediaDisplay",
  "media_types_id",
  { cascade_copy => 0, cascade_delete => 0 };

=head2 media

Type: has_many

Related object: L<Interchange6::Schema::Result::Media>

=cut

has_many
  media => "Interchange6::Schema::Result::Media",
  "media_types_id",
  { cascade_copy => 0, cascade_delete => 0 };

1;

lib/Interchange6/Schema/Result/MerchandisingProduct.pm  view on Meta::CPAN

Type: has_many

Related object: L<Interchange6::Schema::Result::MerchandisingAttribute>

=cut

has_many
  merchandising_attributes =>
  "Interchange6::Schema::Result::MerchandisingAttribute",
  "merchandising_products_id",
  { cascade_copy => 0, cascade_delete => 0 };

=head2 product

Type: belongs_to

Related object: L<Interchange6::Schema::Result::Product>

=cut

belongs_to

lib/Interchange6/Schema/Result/Message.pm  view on Meta::CPAN


Type: has_many

Related object: L<Interchange6::Schema::Result::MediaMessage>

=cut

has_many
  media_messages => "Interchange6::Schema::Result::MediaMessage",
  "messages_id",
  { cascade_copy => 0, cascade_delete => 0 };

=head2 media

Type: many_to_many with media

=cut

many_to_many media => "media_messages", "media";

=head1 INHERITED METHODS

lib/Interchange6/Schema/Result/Navigation.pm  view on Meta::CPAN


Type: has_many

Related object: L<Interchange6::Schema::Result::MediaNavigation>

=cut

has_many
  media_navigations => "Interchange6::Schema::Result::MediaNavigation",
  "navigation_id",
  { cascade_copy => 0, cascade_delete => 0 };


=head2 navigation_products

Type: has_many

Related object: L<Interchange6::Schema::Result::NavigationProduct>

=cut

has_many
  navigation_products => "Interchange6::Schema::Result::NavigationProduct",
  "navigation_id",
  { cascade_copy => 0, cascade_delete => 0 };

=head2 products

Type: many_to_many

Accessor to related product results ordered by priority and name.

=cut

many_to_many

lib/Interchange6/Schema/Result/Navigation.pm  view on Meta::CPAN


Type: has_many

Related object: L<Interchange6::Schema::Result::NavigationAttribute>

=cut

has_many
  navigation_attributes => "Interchange6::Schema::Result::NavigationAttribute",
  "navigation_id",
  { cascade_copy => 0, cascade_delete => 0 };

=head2 attributes

Type: many_to_many

Accessor to related attribute results.

=cut

many_to_many

lib/Interchange6/Schema/Result/Navigation.pm  view on Meta::CPAN

=head2 navigation_messages

Type: has_many

Related object: L<Interchange6::Schema::Result::NavigationMessage>

=cut

has_many
  navigation_messages => "Interchange6::Schema::Result::NavigationMessage",
  "navigation_id", { cascade_copy => 0 };

=head2 messages

Type: many_to_many

Accessor to related Message results.

=cut

many_to_many messages => "navigation_messages", "message";

lib/Interchange6/Schema/Result/NavigationAttribute.pm  view on Meta::CPAN

Type: has_many

Related object: L<Interchange6::Schema::Result::NavigationAttributeValue>

=cut

has_many
  navigation_attribute_values =>
  "Interchange6::Schema::Result::NavigationAttributeValue",
  "navigation_attributes_id",
  { cascade_copy => 0, cascade_delete => 0 };

1;

lib/Interchange6/Schema/Result/NavigationMessage.pm  view on Meta::CPAN


Type: belongs_to

Related object: L<Interchange6::Schema::Result::Message>

=cut

belongs_to
  message => "Interchange6::Schema::Result::Message",
  "messages_id",
  { cascade_delete => 1 };

=head2 navigation

Type: belongs_to

Related object: L<Interchange6::Schema::Result::Navigation>

=cut

belongs_to

lib/Interchange6/Schema/Result/Order.pm  view on Meta::CPAN


Type: has_many

Related object: L<Interchange6::Schema::Result::Orderline>

=cut

has_many
  orderlines => "Interchange6::Schema::Result::Orderline",
  "orders_id",
  { cascade_copy => 0, cascade_delete => 0 };

=head2 payment_orders

Type: has_many

Related object: L<Interchange6::Schema::Result::PaymentOrder>

=cut

has_many
  payment_orders => "Interchange6::Schema::Result::PaymentOrder",
  "orders_id",
  { cascade_copy => 0, cascade_delete => 0 };

=head2 user

Type: belongs_to

Related object: L<Interchange6::Schema::Result::User>

=cut

belongs_to

lib/Interchange6/Schema/Result/Order.pm  view on Meta::CPAN

    $self->order_comments->delete_all;
    $self->add_to_comments( $_ ) for (@to_set);
}

=head2 delete

Overload delete to force removal of any order comments.

=cut

# FIXME: (SysPete) There ought to be a way to force this with cascade delete.

sub delete {
    my ( $self, @args ) = @_;
    my $guard = $self->result_source->schema->txn_scope_guard;
    $self->order_comments->delete_all;
    $self->next::method(@args);
    $guard->commit;
}

=head2 insert

lib/Interchange6/Schema/Result/OrderComment.pm  view on Meta::CPAN


Type: belongs_to

Related object: L<Interchange6::Schema::Result::Message>

=cut

belongs_to
  message => "Interchange6::Schema::Result::Message",
  "messages_id",
  { cascade_delete => 1 };

=head2 order

Type: belongs_to

Related object: L<Interchange6::Schema::Result::Order>

=cut

belongs_to

lib/Interchange6/Schema/Result/Orderline.pm  view on Meta::CPAN


Type: has_many

Related object: L<Interchange6::Schema::Result::OrderlinesShipping>

=cut

has_many
  orderlines_shipping => "Interchange6::Schema::Result::OrderlinesShipping",
  "orderlines_id",
  { cascade_copy => 0, cascade_delete => 0 };

=head2 product

Type: belongs_to

Related object: L<Interchange6::Schema::Result::Product>

=cut

belongs_to

lib/Interchange6/Schema/Result/Product.pm  view on Meta::CPAN


Type: has_many

Related object: L<Interchange6::Schema::Result::Product>

=cut

has_many
  variants => "Interchange6::Schema::Result::Product",
  { "foreign.canonical_sku" => "self.sku" },
  { cascade_copy            => 0, cascade_delete => 0 };

=head2 cart_products

Type: has_many

Related object: L<Interchange6::Schema::Result::CartProduct>

=cut

has_many
  cart_products => "Interchange6::Schema::Result::CartProduct",
  "sku",
  { cascade_copy => 0, cascade_delete => 0 };

=head2 price_modifiers

Type: has_many

Related object: L<Interchange6::Schema::Result::PriceModifier>

=cut

has_many

lib/Interchange6/Schema/Result/Product.pm  view on Meta::CPAN


Type: might_have

Related object: L<Interchange6::Schema::Result::Inventory>

=cut

might_have
  inventory => "Interchange6::Schema::Result::Inventory",
  "sku",
  { cascade_copy => 0, cascade_delete => 0 };

=head2 media_products

Type: has_many

Related object: L<Interchange6::Schema::Result::MediaProduct>

=cut

has_many
  media_products => "Interchange6::Schema::Result::MediaProduct",
  "sku",
  { cascade_copy => 0, cascade_delete => 0 };

=head2 merchandising_products

Type: has_many

Related object: L<Interchange6::Schema::Result::MerchandisingProduct>

=cut

has_many
  merchandising_products =>
  "Interchange6::Schema::Result::MerchandisingProduct",
  "sku",
  { cascade_copy => 0, cascade_delete => 0 };

=head2 merchandising_product_related

Type: has_many

Related object: L<Interchange6::Schema::Result::MerchandisingProduct>

=cut

has_many
  merchandising_product_related =>
  "Interchange6::Schema::Result::MerchandisingProduct",
  { "foreign.sku_related" => "self.sku" },
  { cascade_copy          => 0, cascade_delete => 0 };

=head2 navigation_products

Type: has_many

Related object: L<Interchange6::Schema::Result::NavigationProduct>

=cut

has_many
  navigation_products => "Interchange6::Schema::Result::NavigationProduct",
  "sku",
  { cascade_copy => 0, cascade_delete => 0 };

=head2 navigation

Type: many_to_many with navigation

=cut

many_to_many navigations => "navigation_products", "navigation";

=head2 orderlines

Type: has_many

Related object: L<Interchange6::Schema::Result::Orderline>

=cut

has_many
  orderlines => "Interchange6::Schema::Result::Orderline",
  "sku",
  { cascade_copy => 0, cascade_delete => 0 };

=head2 product_attributes

Type: has_many

Related object: L<Interchange6::Schema::Result::ProductAttribute>

=cut

has_many
  product_attributes => "Interchange6::Schema::Result::ProductAttribute",
  "sku",
  { cascade_copy => 0, cascade_delete => 0 };

=head2 media

Type: many_to_many with media

=cut

many_to_many media => "media_products", "media";

=head2 product_messages

Type: has_many

Related object: L<Interchange6::Schema::Result::ProductMessage>

=cut

has_many
  product_messages => "Interchange6::Schema::Result::ProductMessage",
  "sku", { cascade_copy => 0 };

=head2 messages

Type: many_to_many

Accessor to related Message results.

=cut

many_to_many messages => "product_messages", "message";

lib/Interchange6/Schema/Result/Product.pm  view on Meta::CPAN

    }
    return $quantity;
}

=head2 delete

Overload delete to force removal of any product reviews. Only parent products should have reviews so in the case of child products no attempt is made to delete reviews.

=cut

# FIXME: (SysPete) There ought to be a way to force this with cascade delete.

sub delete {
    my ( $self, @args ) = @_;
    my $guard = $self->result_source->schema->txn_scope_guard;
    $self->product_reviews->delete_all unless defined $self->canonical_sku;
    $self->next::method(@args);
    $guard->commit;
}

1;

lib/Interchange6/Schema/Result/ProductAttribute.pm  view on Meta::CPAN

Type: has_many

Related object: L<Interchange6::Schema::Result::ProductAttributeValue>

=cut

has_many
  product_attribute_values =>
  "Interchange6::Schema::Result::ProductAttributeValue",
  "product_attributes_id",
  { cascade_copy => 0, cascade_delete => 0 };

1;

lib/Interchange6/Schema/Result/ProductMessage.pm  view on Meta::CPAN


Type: belongs_to

Related object: L<Interchange6::Schema::Result::Message>

=cut

belongs_to
  message => "Interchange6::Schema::Result::Message",
  "messages_id",
  { cascade_delete => 1 };

=head2 product

Type: belongs_to

Related object: L<Interchange6::Schema::Result::Product>

=cut

belongs_to product => "Interchange6::Schema::Result::Product", "sku";

lib/Interchange6/Schema/Result/Role.pm  view on Meta::CPAN


Type: has_many

Related object: L<Interchange6::Schema::Result::PriceModifier>

=cut

has_many
  price_modifiers => "Interchange6::Schema::Result::PriceModifier",
  "roles_id",
  { cascade_copy => 0, cascade_delete => 0 };

=head2 permissions

Type: has_many

Related object: L<Interchange6::Schema::Result::Permission>

=cut

has_many
  permissions => "Interchange6::Schema::Result::Permission",
  "roles_id",
  { cascade_copy => 0, cascade_delete => 0 };

=head2 user_roles

Type: has_many

Related object: L<Interchange6::Schema::Result::UserRole>

=cut

has_many
  user_roles => "Interchange6::Schema::Result::UserRole",
  "roles_id",
  { cascade_copy => 0, cascade_delete => 0 };

=head2 users

Type: many_to_many

Composing rels: L</user_roles> -> user

=cut

many_to_many users => "user_roles", "user";

lib/Interchange6/Schema/Result/Session.pm  view on Meta::CPAN


Type: has_many

Related object: L<Interchange6::Schema::Result::Cart>

=cut

has_many
  carts => "Interchange6::Schema::Result::Cart",
  "sessions_id",
  { cascade_copy => 0, cascade_delete => 0 };

=head2 payment_orders

Type: has_many

Related object: L<Interchange6::Schema::Result::PaymentOrder>

=cut

has_many
  payment_orders => "Interchange6::Schema::Result::PaymentOrder",
  "sessions_id",
  { cascade_copy => 0, cascade_delete => 0 };

1;

lib/Interchange6/Schema/Result/ShipmentCarrier.pm  view on Meta::CPAN


Type: has_many

Related object: L<Interchange6::Schema::Result::ShipmentMethod>

=cut

has_many
  shipment_methods => "Interchange6::Schema::Result::ShipmentMethod",
  "shipment_carriers_id",
  { cascade_copy => 0, cascade_delete => 0 };

1;

lib/Interchange6/Schema/Result/ShipmentMethod.pm  view on Meta::CPAN


Type: has_many

Related object: L<Interchange6::Schema::Result::ShipmentRate>

=cut

has_many
  shipment_rates => "Interchange6::Schema::Result::ShipmentRate",
  "shipment_methods_id",
  { cascade_copy => 0, cascade_delete => 0 };

1;

lib/Interchange6/Schema/Result/State.pm  view on Meta::CPAN


Type: has_many

Related object L<Interchange6::Schema::Result::ZoneState>

=cut

has_many
  zone_states => "Interchange6::Schema::Result::ZoneState",
  "states_id",
  { cascade_copy => 0, cascade_delete => 0 };

=head2 zones

Type: many_to_many

Composing rels: L</zone_states> -> zone

=cut

many_to_many zones => "zone_states", "zone";

lib/Interchange6/Schema/Result/User.pm  view on Meta::CPAN


Type: has_many

Related object: L<Interchange6::Schema::Result::Address>

=cut

has_many
  addresses => "Interchange6::Schema::Result::Address",
  "users_id",
  { cascade_copy => 0, cascade_delete => 0 };

=head2 carts

Type: has_many

Related object: L<Interchange6::Schema::Result::Cart>

=cut

has_many
  carts => "Interchange6::Schema::Result::Cart",
  "users_id",
  { cascade_copy => 0, cascade_delete => 0 };

=head2 orders

Type: has_many

Related object: L<Interchange6::Schema::Result::Order>

=cut

has_many
  orders => "Interchange6::Schema::Result::Order",
  "users_id",
  { cascade_copy => 0, cascade_delete => 0 };

=head2 user_attributes

Type: has_many

Related object: L<Interchange6::Schema::Result::UserAttribute>

=cut

has_many
  user_attributes => "Interchange6::Schema::Result::UserAttribute",
  "users_id",
  { cascade_copy => 0, cascade_delete => 0 };

=head2 user_roles

Type: has_many

Related object: L<Interchange6::Schema::Result::UserRole>

=cut

has_many

lib/Interchange6/Schema/Result/UserAttribute.pm  view on Meta::CPAN


Type: has_many

Related object: L<Interchange6::Schema::Result::UserAttributeValue>

=cut

has_many
  user_attribute_values => "Interchange6::Schema::Result::UserAttributeValue",
  "user_attributes_id",
  { cascade_copy => 0, cascade_delete => 0 };

1;

lib/Interchange6/Schema/Result/Zone.pm  view on Meta::CPAN


Type: has_many

Related object: L<Interchange6::Schema::Result::ZoneCountry>

=cut

has_many
  zone_countries => "Interchange6::Schema::Result::ZoneCountry",
  "zones_id",
  { cascade_copy => 0, cascade_delete => 0 };

=head2 countries

Type: many_to_many

Accessor to related country results ordered by name.

=cut

many_to_many

lib/Interchange6/Schema/Result/Zone.pm  view on Meta::CPAN


Type: has_many

Related object: L<Interchange6::Schema::Result::ZoneState>

=cut

has_many
  zone_states => "Interchange6::Schema::Result::ZoneState",
  "zones_id",
  { cascade_copy => 0, cascade_delete => 0 };

=head2 states

Type: many_to_many

Accessor to related state results ordered by name.

=cut

many_to_many

t/lib/Test/Fixtures.pm  view on Meta::CPAN


    my $country_count = $self->countries->count;
    my $state_count   = $self->states->count;

    lives_ok( sub { $self->clear_taxes }, "clear_taxes" );

    ok( !$self->has_taxes, "has_taxes is false" );

    cmp_ok( $schema->resultset('Tax')->count, '==', 0, "0 Taxes in DB" );

    # check no cascade delete to country/state
    cmp_ok( $country_count, '==', $self->countries->count, "country count" );
    cmp_ok( $state_count,   '==', $self->states->count,    "state count" );

};

test 'price modifiers' => sub {
    my $self   = shift;
    my $schema = $self->ic6s_schema;

    cmp_ok( $self->price_modifiers->count,

t/lib/Test/Zone.pm  view on Meta::CPAN

        "Fail to remove country US from zone Canada"
    );

    lives_ok( sub { $result->remove_countries( $countries{CA} ) },
        "Remove country CA from zone Canada" );

    cmp_ok( $result->country_count, '==', 0, "0 country in zone" );

    $rset = $self->ic6s_schema->resultset('ZoneCountry')
      ->search( { zones_id => $result->zones_id } );
    cmp_ok( $rset->count, '==', 0, "check cascade delete in ZoneCountry" );

    $rset = $self->countries->search( { country_iso_code => 'CA' } );
    cmp_ok( $rset->count, '==', 1, "check cascade delete in Country" );

    lives_ok(
        sub { $result->add_countries( $countries{CA} ) },
        "Create relationship to Country for Canada in zone Canada"
    );

    throws_ok(
        sub { $result->remove_countries('FooBar') },
        qr/Bad country: FooBar/,
        "Fail remove country FooBar from zone Canada"



( run in 0.920 second using v1.01-cache-2.11-cpan-49f99fa48dc )