From: Rafael Kitover Date: Mon, 25 May 2009 23:45:11 +0000 (+0000) Subject: make quoter/name_sep builders overridable methods X-Git-Tag: 0.04999_08~14^2 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=77d3753e5992dca4720b0eb28a6d85bb71a7159a;p=dbsrgits%2FDBIx-Class-Schema-Loader.git make quoter/name_sep builders overridable methods --- diff --git a/lib/DBIx/Class/Schema/Loader/DBI.pm b/lib/DBIx/Class/Schema/Loader/DBI.pm index b8699c5..4890b10 100644 --- a/lib/DBIx/Class/Schema/Loader/DBI.pm +++ b/lib/DBIx/Class/Schema/Loader/DBI.pm @@ -46,14 +46,8 @@ sub new { } # Set up the default quoting character and name seperators - $self->{_quoter} = $dbh->get_info(29) - || $self->schema->storage->sql_maker->quote_char - || q{"}; - - $self->{_namesep} = $dbh->get_info(41) - || $self->schema->storage->sql_maker->name_sep - || q{.}; - + $self->{_quoter} = $self->_build_quoter; + $self->{_namesep} = $self->_build_namesep; # For our usage as regex matches, concatenating multiple quoter # values works fine (e.g. s/\Q<>\E// if quoter was [ '<', '>' ]) if( ref $self->{_quoter} eq 'ARRAY') { @@ -65,6 +59,22 @@ sub new { $self; } +sub _build_quoter { + my $self = shift; + my $dbh = $self->schema->storage->dbh; + return $dbh->get_info(29) + || $self->schema->storage->sql_maker->quote_char + || q{"}; +} + +sub _build_namesep { + my $self = shift; + my $dbh = $self->schema->storage->dbh; + return $dbh->get_info(41) + || $self->schema->storage->sql_maker->name_sep + || q{.}; +} + # Override this in vendor modules to do things at the end of ->new() sub _setup { } @@ -79,7 +89,8 @@ sub _tables_list { my $dbh = $self->schema->storage->dbh; my @tables = $dbh->tables(undef, $self->db_schema, $table, $type); - s/\Q$self->{_quoter}\E//g for @tables; + + s/\Q$self->{_quoter}\E//g for @tables; s/^.*\Q$self->{_namesep}\E// for @tables; return @tables; diff --git a/lib/DBIx/Class/Schema/Loader/DBI/MSSQL.pm b/lib/DBIx/Class/Schema/Loader/DBI/MSSQL.pm index 9e6c4ac..74ba030 100644 --- a/lib/DBIx/Class/Schema/Loader/DBI/MSSQL.pm +++ b/lib/DBIx/Class/Schema/Loader/DBI/MSSQL.pm @@ -34,6 +34,11 @@ sub _setup { $self->{db_schema} ||= 'dbo'; } +# DBD::Sybase doesn't implement get_info properly +#sub _build_quoter { [qw/[ ]/] } +sub _build_quoter { '"' } +sub _build_namesep { '.' } + sub _table_pk_info { my ($self, $table) = @_; my $dbh = $self->schema->storage->dbh;