1package DBIx::Class::Schema::Loader::DBI::Sybase::Common; 2 3use strict; 4use warnings; 5use base 'DBIx::Class::Schema::Loader::DBI'; 6use Carp::Clan qw/^DBIx::Class/; 7use Class::C3; 8 9our $VERSION = '0.05003'; 10 11=head1 NAME 12 13DBIx::Class::Schema::Loader::DBI::Sybase::Common - Common functions for Sybase 14and MSSQL 15 16=head1 DESCRIPTION 17 18See L<DBIx::Class::Schema::Loader::Base>. 19 20=cut 21 22# DBD::Sybase doesn't implement get_info properly 23sub _build_quoter { '"' } 24sub _build_namesep { '.' } 25 26sub _set_quote_char_and_name_sep { 27 my $self = shift; 28 29 $self->schema->storage->sql_maker->quote_char([qw/[ ]/]) 30 unless $self->schema->storage->sql_maker->quote_char; 31 32 $self->schema->storage->sql_maker->name_sep('.') 33 unless $self->schema->storage->sql_maker->name_sep; 34} 35 36sub _build_db_schema { 37 my $self = shift; 38 my $dbh = $self->schema->storage->dbh; 39 40 local $dbh->{FetchHashKeyName} = 'NAME_lc'; 41 42 my $test_table = "_loader_test_$$"; 43 44 my $db_schema = 'dbo'; # default 45 46 eval { 47 $dbh->do("create table $test_table (id integer)"); 48 my $sth = $dbh->prepare('sp_tables'); 49 $sth->execute; 50 while (my $row = $sth->fetchrow_hashref) { 51 next unless $row->{table_name} eq $test_table; 52 53 $db_schema = $row->{table_owner}; 54 last; 55 } 56 $sth->finish; 57 $dbh->do("drop table $test_table"); 58 }; 59 my $exception = $@; 60 eval { $dbh->do("drop table $test_table") }; 61 carp "Could not determine db_schema, defaulting to $db_schema : $exception" 62 if $exception; 63 64 return $db_schema; 65} 66 67# remove 'IDENTITY' from column data_type 68sub _columns_info_for { 69 my $self = shift; 70 my $result = $self->next::method(@_); 71 72 foreach my $col (keys %$result) { 73 $result->{$col}->{data_type} =~ s/\s* identity \s*//ix; 74 } 75 76 return $result; 77} 78 79=head1 SEE ALSO 80 81L<DBIx::Class::Schema::Loader::DBI::Sybase>, 82L<DBIx::Class::Schema::Loader::DBI::MSSQL>, 83L<DBIx::Class::Schema::Loader::DBI> 84L<DBIx::Class::Schema::Loader>, L<DBIx::Class::Schema::Loader::Base>, 85 86=head1 AUTHOR 87 88See L<DBIx::Class::Schema::Loader/AUTHOR> and L<DBIx::Class::Schema::Loader/CONTRIBUTORS>. 89 90=head1 LICENSE 91 92This library is free software; you can redistribute it and/or modify it under 93the same terms as Perl itself. 94 95=cut 96 971; 98