package MyDatabase::Main;
use base qw/DBIx::Class::Schema/;
-__PACKAGE__->load_namespaces;
+__PACKAGE__->load_classes(qw/Artist Cd Track/);
1;
-package MyDatabase::Main::Result::Artist;
+package MyDatabase::Main::Artist;
use base qw/DBIx::Class/;
__PACKAGE__->load_components(qw/PK::Auto Core/);
__PACKAGE__->table('artist');
__PACKAGE__->add_columns(qw/ artistid name /);
__PACKAGE__->set_primary_key('artistid');
-__PACKAGE__->has_many('cds' => 'MyDatabase::Main::Result::Cd');
+__PACKAGE__->has_many('cds' => 'MyDatabase::Main::Cd');
1;
-package MyDatabase::Main::Result::Cd;
+package MyDatabase::Main::Cd;
use base qw/DBIx::Class/;
__PACKAGE__->load_components(qw/PK::Auto Core/);
__PACKAGE__->table('cd');
__PACKAGE__->add_columns(qw/ cdid artist title/);
__PACKAGE__->set_primary_key('cdid');
-__PACKAGE__->belongs_to('artist' => 'MyDatabase::Main::Result::Artist');
-__PACKAGE__->has_many('tracks' => 'MyDatabase::Main::Result::Track');
+__PACKAGE__->belongs_to('artist' => 'MyDatabase::Main::Artist');
+__PACKAGE__->has_many('tracks' => 'MyDatabase::Main::Track');
1;
-package MyDatabase::Main::Result::Track;
+package MyDatabase::Main::Track;
use base qw/DBIx::Class/;
__PACKAGE__->load_components(qw/PK::Auto Core/);
__PACKAGE__->table('track');
__PACKAGE__->add_columns(qw/ trackid cd title/);
__PACKAGE__->set_primary_key('trackid');
-__PACKAGE__->belongs_to('cd' => 'MyDatabase::Main::Result::Cd');
+__PACKAGE__->belongs_to('cd' => 'MyDatabase::Main::Cd');
1;
},
{
join => [qw/ cd /],
+ prefetch => [qw/ cd /]
}
);
while (my $track = $rs->next) {
},
{
join => [qw/ artist /],
+ prefetch => [qw/ artist /]
}
);
while (my $cd = $rs->next) {
sub _dbh_execute {
my ($self, $dbh, $op, $extra_bind, $ident, $bind_attributes, @args) = @_;
-
+
my ($sql, $bind) = $self->_prep_for_execute($op, $extra_bind, $ident, \@args);
$self->_query_start( $sql, @$bind );
sub _prep_for_execute {
my $self = shift;
+
+ my ($op, $extra_bind, $ident) = @_;
+
my ($sql, $bind) = $self->next::method(@_);
# stringify args, quote via $dbh, and manually insert
my $new_sql;
foreach my $bound (@$bind) {
- shift @$bound;
+ my $col = shift @$bound;
+ my $do_quote = $self->should_quote_data_type($col);
foreach my $data (@$bound) {
if(ref $data) {
$data = ''.$data;
}
- $new_sql .= shift(@sql_part) . $self->_dbh->quote($data);
+ $data = $self->_dbh->quote($data) if $do_quote;
+ $new_sql .= shift(@sql_part) . $data;
}
}
$new_sql .= join '', @sql_part;
return ($new_sql);
}
+sub should_quote_data_type { 1 }
+
=head1 AUTHORS
Brandon Black <blblack@gmail.com>
use base qw/DBIx::Class::Storage::DBI::NoBindVars/;
+my %noquote = map ($_ => 1), qw(int integer);
+
+sub should_quote_data_type {
+ my $self = shift;
+ my ($type) = @_;
+ return 0 if $noquote{$type};
+ return $self->next::method(@_);
+}
+
1;
=head1 NAME