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