initial hackage, will be cleaned up
Rafael Kitover [Mon, 25 May 2009 02:00:15 +0000 (02:00 +0000)]
lib/DBIx/Class/Schema/Loader/DBI/ODBC.pm [new file with mode: 0644]
lib/DBIx/Class/Schema/Loader/DBI/ODBC/Microsoft_SQL_Server.pm [new file with mode: 0644]

diff --git a/lib/DBIx/Class/Schema/Loader/DBI/ODBC.pm b/lib/DBIx/Class/Schema/Loader/DBI/ODBC.pm
new file mode 100644 (file)
index 0000000..b4cdec3
--- /dev/null
@@ -0,0 +1,26 @@
+package DBIx::Class::Schema::Loader::DBI::ODBC;
+
+use strict;
+use warnings;
+use base 'DBIx::Class::Schema::Loader::DBI';
+use Carp::Clan qw/^DBIx::Class/;
+use Class::C3;
+
+our $VERSION = '0.04999_06';
+
+sub _rebless {
+  my $self = shift;
+  my $dbh  = $self->schema->storage->dbh;
+
+# stolen from DBIC ODBC driver for MSSQL
+  my $dbtype = eval { $dbh->get_info(17) };
+  unless ( $@ ) {
+    # Translate the backend name into a perl identifier
+    $dbtype =~ s/\W/_/gi;
+    my $class = "DBIx::Class::Schema::Loader::DBI::ODBC::${dbtype}";
+    eval "require $class";
+    bless $self, $class unless $@;
+  }
+}
+
+1;
diff --git a/lib/DBIx/Class/Schema/Loader/DBI/ODBC/Microsoft_SQL_Server.pm b/lib/DBIx/Class/Schema/Loader/DBI/ODBC/Microsoft_SQL_Server.pm
new file mode 100644 (file)
index 0000000..5b956ab
--- /dev/null
@@ -0,0 +1,16 @@
+package DBIx::Class::Schema::Loader::DBI::ODBC::Microsoft_SQL_Server;
+
+use base 'DBIx::Class::Schema::Loader::DBI::MSSQL';
+
+sub _tables_list { 
+    my $self = shift;
+
+    my $dbh = $self->schema->storage->dbh;
+    my @tables = $dbh->tables(undef, $self->db_schema);
+    s/\Q$self->{_quoter}\E//g for @tables;
+    s/^.*\Q$self->{_namesep}\E// for @tables;
+
+    return @tables;
+}
+
+1;