blib/lib/DBIx/Class/Schema/Loader/DBObject/Sybase.pm untested

filter: Statementstmt 0.0% 0 / 35 Branchbran 0.0% 0 / 8 Conditioncond 0.0% 0 / 9 MC/DCmcdc 0.0% 0 / 5 Subroutinesub 0.0% 0 / 9 Podpod 0.0% 0 / 4 totaltotal 0.0% 0 / 70 CC 5 SCAR 17.1
CC
5
Cov
0%
dbic_name
12.0
database
6.0
sql_name
6.0
CRAP 5.5
1 package DBIx::Class::Schema::Loader::DBObject::Sybase;
2  
3 use strict;
4 use warnings;
5 use base 'DBIx::Class::Schema::Loader::DBObject';
6 use mro 'c3';
7 use namespace::clean;
8  
9 =head1 NAME
10  
11 DBIx::Class::Schema::Loader::DBObject::Sybase - Class for Database Objects for
12 Sybase ASE and MSSQL Such as Tables and Views in L<DBIx::Class::Schema::Loader>
13  
14 =head1 DESCRIPTION
15  
16 This is a subclass of L<DBIx::Class::Schema::Loader::DBObject> that adds
17 support for fully qualified objects in Sybase ASE and MSSQL including both
18 L</database> and L<schema|DBIx::Class::Schema::Loader::DBObject/schema> of the
19 form:
20  
21 database.owner.object_name
22  
23 =head1 METHODS
24  
25 =head2 database
26  
27 The database name this object belongs to.
28  
29 Returns undef if
30 L<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  
38 sub 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  
48 sub 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  
58 Returns the properly quoted full identifier with L</database>,
59 L<schema|DBIx::Class::Schema::Loader::DBObject/schema> and
60 L<name|DBIx::Class::Schema::Loader::DBObject/name>.
61  
62 =cut
63  
64 sub 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  
80 sub 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  
100 L<DBIx::Class::Schema::Loader::Table::Sybase>,
101 L<DBIx::Class::Schema::Loader::DBObject>,
102 L<DBIx::Class::Schema::Loader::Table>, L<DBIx::Class::Schema::Loader>,
103 L<DBIx::Class::Schema::Loader::Base>
104  
105 =head1 AUTHORS
106  
107 See L<DBIx::Class::Schema::Loader/AUTHORS>.
108  
109 =head1 LICENSE
110  
111 This library is free software; you can redistribute it and/or modify it under
112 the same terms as Perl itself.
113  
114 =cut
115  
116 1;
117 # vim:et sts=4 sw=4 tw=0: