multi db_schema support
[dbsrgits/DBIx-Class-Schema-Loader.git] / lib / DBIx / Class / Schema / Loader / DBObject / Informix.pm
CommitLineData
c4a69b87 1package DBIx::Class::Schema::Loader::DBObject::Informix;
2
3use strict;
4use warnings;
5use base 'DBIx::Class::Schema::Loader::DBObject';
6use namespace::clean;
7
8=head1 NAME
9
10DBIx::Class::Schema::Loader::DBObject::Informix - Class for Database Objects for
11Informix Such as Tables and Views in L<DBIx::Class::Schema::Loader>
12
13=head1 DESCRIPTION
14
15This is a subclass of L<DBIx::Class::Schema::Loader::DBObject> that adds
16support for fully qualified objects in Informix including both L</database>
17and L<schema|DBIx::Class::Schema::Loader::DBObject/schema> of the form:
18
19 database:owner.object_name
20
21=head1 METHODS
22
23=head2 database
24
25The database name this object belongs to.
26
27Returns undef if
28L<ignore_schema|DBIx::Class::Schema::Loader::DBObject/ignore_schema> is set.
29
30=cut
31
32__PACKAGE__->mk_group_accessors(simple => qw/
33 _database
34/);
35
36sub new {
37 my $class = shift;
38
39 my $self = $class->next::method(@_);
40
41 $self->{_database} = delete $self->{database};
42
43 return $self;
44}
45
46sub database {
47 my $self = shift;
48
49 return $self->_database(@_) unless $self->ignore_schema;
50
51 return undef;
52}
53
54=head1 sql_name
55
56Returns the properly quoted full identifier with L</database>,
57L<schema|DBIx::Class::Schema::Loader::DBObject/schema> and
58L<name|DBIx::Class::Schema::Loader::DBObject/name>.
59
60=cut
61
62sub sql_name {
63 my $self = shift;
64
65 my $name_sep = $self->loader->name_sep;
66
67 if ($self->database) {
68 return $self->_quote($self->database)
69 . ':'
70 . $self->_quote($self->schema)
71 . $name_sep
72 . $self->_quote($self->name);
73 }
74
75 return $self->next::method(@_);
76}
77
78sub dbic_name {
79 my $self = shift;
80
81 my $name_sep = $self->loader->name_sep;
82
83 if ($self->loader->qualify_objects && $self->_database) {
84 if ($self->_database =~ /\W/
85 || $self->_schema =~ /\W/ || $self->name =~ /\W/) {
86
87 return \ $self->sql_name;
88 }
89
90 return $self->_database . ':' . $self->_schema . $name_sep . $self->name;
91 }
92
93 return $self->next::method(@_);
94}
95
96=head1 SEE ALSO
97
98L<DBIx::Class::Schema::Loader::Table::Informix>,
99L<DBIx::Class::Schema::Loader::DBObject>,
100L<DBIx::Class::Schema::Loader::Table>, L<DBIx::Class::Schema::Loader>,
101L<DBIx::Class::Schema::Loader::Base>
102
103=head1 AUTHOR
104
105See L<DBIx::Class::Schema::Loader/AUTHOR> and L<DBIx::Class::Schema::Loader/CONTRIBUTORS>.
106
107=head1 LICENSE
108
109This library is free software; you can redistribute it and/or modify it under
110the same terms as Perl itself.
111
112=cut
113
1141;
115# vim:et sts=4 sw=4 tw=0: