sub name_unique_constraint {
my ($self, $cols) = @_;
- return join '_', $self->name, @$cols;
+ my $name = $self->name;
+ $name = $$name if ref $name;
+
+ return join '_', $name, @$cols;
}
=head2 unique_constraints
L<DBIx::Class::Relationship>.
The returned hashref is keyed by the name of the opposing
- relationship, and contains it's data in the same manner as
+ relationship, and contains its data in the same manner as
L</relationship_info>.
=cut
use base qw/DBIx::Class::ResultSourceProxy/;
use DBIx::Class::ResultSource::Table;
+use Scalar::Util ();
__PACKAGE__->mk_classdata(table_class => 'DBIx::Class::ResultSource::Table');
=head2 table
__PACKAGE__->table('tbl_name');
-
+
Gets or sets the table name.
=cut
sub table {
my ($class, $table) = @_;
return $class->result_source_instance->name unless $table;
- unless (ref $table) {
+
+ unless (Scalar::Util::blessed($table) && $table->isa($class->table_class)) {
$table = $class->table_class->new({
$class->can('result_source_instance') ?
%{$class->result_source_instance||{}} : (),
my ($self,$source,$col) = @_;
my @pri = $source->primary_columns;
- my ($schema,$table) = $source->name =~ /^(.+)\.(.+)$/ ? ($1,$2)
- : (undef,$source->name);
+
+ my $schema;
+ my $table = $source->name;
+
+ if (ref $table eq 'SCALAR') {
+ $table = $$table;
+ }
+ elsif ($table =~ /^(.+)\.(.+)$/) {
+ ($schema, $table) = ($1, $2);
+ }
$self->dbh_do('_dbh_get_autoinc_seq', $schema, $table, @pri);
}
bytea => { pg_type => DBD::Pg::PG_BYTEA },
blob => { pg_type => DBD::Pg::PG_BYTEA },
};
-
+
if( defined $bind_attributes->{$data_type} ) {
return $bind_attributes->{$data_type};
}
{
my $source = $dbicschema->source($moniker);
my $table_name = $source->name;
-
- # Skip custom query sources
- next if ref $table_name;
+ $table_name = $$table_name if ref $table_name eq 'SCALAR'; #sqlt currently does not do quoting right anyway
# Its possible to have multiple DBIC sources using the same table
next if $tables{$table_name};
my $othertable = $source->related_source($rel);
my $rel_table = $othertable->name;
+ $rel_table = $$rel_table if ref $rel_table eq 'SCALAR'; #sqlt currently does not do quoting right anyway
my $reverse_rels = $source->reverse_relationship_info($rel);
my ($otherrelname, $otherrelationship) = each %{$reverse_rels};
{
my $source = $dbicschema->source($moniker);
my $view_name = $source->name;
+ $view_name = $$view_name if ref $view_name eq 'SCALAR'; #sqlt currently does not do quoting right anyway
# Skip custom query sources
next if ref $view_name;
## Standalone
use MyApp::Schema;
use SQL::Translator;
-
+
my $schema = MyApp::Schema->connect;
my $trans = SQL::Translator->new (
parser => 'SQL::Translator::Parser::DBIx::Class',
C<SQL::Translator::Parser::DBIx::Class> reads a DBIx::Class schema,
interrogates the columns, and stuffs it all in an $sqlt_schema object.
- It's primary use is in deploying database layouts described as a set
+ Its primary use is in deploying database layouts described as a set
of L<DBIx::Class> classes, to a database. To do this, see
L<DBIx::Class::Schema/deploy>.