documentation for %typemap, preliminary Sybase driver
authorivan <ivan>
Wed, 5 Sep 2001 16:20:03 +0000 (16:20 +0000)
committerivan <ivan>
Wed, 5 Sep 2001 16:20:03 +0000 (16:20 +0000)
DBSchema.pm
DBSchema/DBD.pm
DBSchema/DBD/Sybase.pm [new file with mode: 0755]
README

index 418fadf..420d44f 100644 (file)
@@ -14,7 +14,7 @@ use DBIx::DBSchema::ColGroup::Index;
 #@ISA = qw(Exporter);
 @ISA = ();
 
-$VERSION = "0.18";
+$VERSION = "0.19";
 
 =head1 NAME
 
@@ -58,9 +58,10 @@ schema from an existing database.  You can save the schema to disk and restore
 it a different process.  Most importantly, DBIx::DBSchema can write SQL
 CREATE statements statements for different databases from a single source.
 
-Currently supported databases are MySQL and PostgreSQL.  DBIx::DBSchema will
-attempt to use generic SQL syntax for other databases.  Assistance adding
-support for other databases is welcomed.
+Currently supported databases are MySQL and PostgreSQL.  Sybase support is
+partially implemented.  DBIx::DBSchema will attempt to use generic SQL syntax
+for other databases.  Assistance adding support for other databases is
+welcomed.  See L<DBIx::DBSchema::DBD>, "Driver Writer's Guide and Base Class".
 
 =head1 METHODS
 
@@ -329,6 +330,9 @@ sub _tables_from_dbh {
 
 Ivan Kohler <ivan-dbix-dbschema@420.am>
 
+Charles Shapiro <charles.shapiro@numethods.com> and Mitchell Friedman
+<mitchell.friedman@numethods.com> contributed the start of a Sybase driver.
+
 =head1 COPYRIGHT
 
 Copyright (c) 2000 Ivan Kohler
@@ -351,8 +355,9 @@ qw(:sql_types) here instead of externally.
 
 L<DBIx::DBSchema::Table>, L<DBIx::DBSchema::ColGroup>,
 L<DBIx::DBSchema::ColGroup::Unique>, L<DBIx::DBSchema::ColGroup::Index>,
-L<DBIx::DBSchema::Column>, L<DBIx::DBSchema::DBD>, L<DBIx::DBSchema::mysql>,
-L<DBIx::DBSchema::Pg>, L<FS::Record>, L<DBI>
+L<DBIx::DBSchema::Column>, L<DBIx::DBSchema::DBD>,
+L<DBIx::DBSchema::DBD::mysql>, L<DBIx::DBSchema::DBD::Pg>, L<FS::Record>,
+L<DBI>
 
 =cut
 
index c0a8652..2f386b2 100644 (file)
@@ -69,6 +69,24 @@ L<DBIx::DBSchema::ColGroup>.
 
 =back
 
+=head1 TYPE MAPPING
+
+You can define a %typemap array for your driver to map "standard" data    
+types to database-specific types.  For example, the MySQL TIMESTAMP field
+has non-standard auto-updating semantics; the MySQL DATETIME type is 
+what other databases and the ODBC standard call TIMESTAMP, so on of the   
+entries in the MySQL %typemap is:
+
+  'TIMESTAMP' => 'DATETIME',
+
+Another example is the Pg %typemap which maps the standard types BLOB and
+LONG VARBINARY to the Pg-specific BYTEA:
+
+  'BLOB' => 'BYTEA',
+  'LONG VARBINARY' => 'BYTEA',
+
+Make sure you use all uppercase-keys.
+
 =head1 AUTHOR
 
 Ivan Kohler <ivan-dbix-dbschema@420.am>
diff --git a/DBSchema/DBD/Sybase.pm b/DBSchema/DBD/Sybase.pm
new file mode 100755 (executable)
index 0000000..95e2d1a
--- /dev/null
@@ -0,0 +1,115 @@
+package DBIx::DBSchema::DBD::Sybase;
+
+use strict;
+use vars qw($VERSION @ISA %typemap);
+use DBIx::DBSchema::DBD;
+
+$VERSION = '0.02';
+@ISA = qw(DBIx::DBSchema::DBD);
+
+%typemap = (
+#  'empty' => 'empty'
+);
+
+#
+# Return this from uncompleted driver calls.
+#
+
+=head1 NAME
+
+DBIx::DBSchema::DBD::Sybase - Sybase database driver for DBIx::DBSchema
+
+=head1 SYNOPSIS
+
+use DBI;
+use DBIx::DBSchema;
+
+$dbh = DBI->connect('dbi:Sybase:dbname=database', 'user', 'pass');
+$schema = new_native DBIx::DBSchema $dbh;
+
+=head1 DESCRIPTION
+
+This module implements a Sybase driver for DBIx::DBSchema. 
+
+=cut
+
+sub columns {
+
+  my($proto, $dbh, $table) = @_;
+
+  my $sth = $dbh->prepare("sp_columns \@table_name=$table") 
+  or die $dbh->errstr;
+
+  $sth->execute or die $sth->errstr;
+  map {
+    [
+      $_->{'COLUMN_NAME'},
+      $_->{'TYPE_NAME'},
+      ($_->{'NULLABLE'} ? 1 : ''),
+      $_->{'LENGTH'},
+      '', #default
+      ''  #local
+    ]
+  } @{ $sth->fetchall_arrayref({}) };
+
+}
+
+sub primary_key {
+    return("StubbedPrimaryKey");
+}
+
+
+sub unique {
+
+    my %stubList = (
+         'stubfirstUniqueIndex' => ['stubfirstUniqueIndex'],
+         'stubtwostUniqueIndex' => ['stubtwostUniqueIndex']
+                       );
+
+   return ( { %stubList } );
+
+}
+
+sub index {
+
+    my %stubList = (
+         'stubfirstIndex' => ['stubfirstUniqueIndex'],
+         'stubtwostIndex' => ['stubtwostUniqueIndex']
+                       );
+
+    return ( { %stubList } );
+
+}
+
+=head1 AUTHOR
+
+Charles Shapiro <charles.shapiro@numethods.com>
+(courtesy of Ivan Kohler <ivan-dbix-dbschema@420.am>)
+
+Mitchell Friedman <mitchell.friedman@numethods.com>
+
+=head1 COPYRIGHT
+
+Copyright (c) 2001 Charles Shapiro, Mitchell J. Friedman
+Copyright (c) 2001 nuMethods LLC.
+All rights reserved.
+This program is free software; you can redistribute it and/or modify it under
+the same terms as Perl itself.
+
+=head1 BUGS
+
+Yes.
+
+Most of this is not implemented.
+
+the "columns" method works; primary key, unique and index do not yet.  Please
+send any patches to all three addresses listed above.
+
+=head1 SEE ALSO
+
+L<DBIx::DBSchema>, L<DBIx::DBSchema::DBD>, L<DBI>, L<DBI::DBD>
+
+=cut 
+
+1;
+
diff --git a/README b/README
index ee9a798..67d434a 100644 (file)
--- a/README
+++ b/README
@@ -12,9 +12,11 @@ schema from an existing database.  You can save the schema to disk and restore
 it from different process.  Most importantly, DBIx::DBSchema can write SQL
 CREATE statements for different databases from a single source.
 
-Currently supported databases are MySQL and PostgreSQL.  DBIx::DBSchema will
-attempt to use generic SQL syntax for other databases.  Assistance adding
-support for other databases is welcomed.
+Currently supported databases are MySQL and PostgreSQL.  Sybase support is
+partially implemented.  DBIx::DBSchema will attempt to use generic SQL syntax
+for other databases.  Assistance adding support for other databases is
+welcomed.  See the DBIx::DBSchema::DBD> manpage, "Driver Writer's Guide and
+Base Class".
 
 To install:
        perl Makefile.PL
@@ -38,4 +40,4 @@ A mailing list is available.  Send a blank message to
 
 Homepage: <http://www.420.am/dbix-dbschema>
 
-$Id: README,v 1.5 2001-07-08 00:57:17 ivan Exp $
+$Id: README,v 1.6 2001-09-05 16:20:03 ivan Exp $