implement pretty_read
authorivan <ivan>
Wed, 27 Sep 2000 12:40:35 +0000 (12:40 +0000)
committerivan <ivan>
Wed, 27 Sep 2000 12:40:35 +0000 (12:40 +0000)
DBSchema.pm
DBSchema/Table.pm
README

index ae82a9b..da182cd 100644 (file)
@@ -7,6 +7,9 @@ use vars qw(@ISA $VERSION);
 use DBI;
 use FreezeThaw qw(freeze thaw cmpStr);
 use DBIx::DBSchema::Table;
+use DBIx::DBSchema::Column;
+use DBIx::DBSchema::ColGroup::Unique;
+use DBIx::DBSchema::ColGroup::Index;
 
 #@ISA = qw(Exporter);
 @ISA = ();
@@ -47,6 +50,16 @@ DBIx::DBSchema - Database-independent schema objects
 DBIx::DBSchema objects are collections of DBIx::DBSchema::Table objects and
 represent a database schema.
 
+This module implements an OO-interface to database schemas.  Using this module,
+you can create a database schema with an OO Perl interface.  You can read the
+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.
+
 =head1 METHODS
 
 =over 4
@@ -246,8 +259,21 @@ B<pretty_print> method.
 =cut
 
 sub pretty_read {
-  die "unimplemented (pull from fs-setup)";
-  my($proto) = @_;
+  my($proto, $href) = @_;
+  my $schema = proto->new( map {  
+    my(@columns);
+    while (@{$tables{$_}{'columns'}}) {
+      my($name,$type,$null,$length)=splice @{$tables{$_}{'columns'}}, 0, 4;
+      push @columns, new DBIx::DBSchema::Column ( $name,$type,$null,$length );
+    }
+    DBIx::DBSchema::Table->new(
+      $_,
+      $tables{$_}{'primary_key'},
+      DBIx::DBSchema::ColGroup::Unique->new($tables{$_}{'unique'}),
+      DBIx::DBSchema::ColGroup::Index->new($tables{$_}{'index'}),
+      @columns,
+    );
+  } (keys %tables) );
 }
 
 # private subroutines
index a05becf..47e0b12 100644 (file)
@@ -284,7 +284,7 @@ supported in the future.
 
 sub sql_create_table { 
   my($self,$datasrc)=@_;
-
+  warn $datasrc;
   my(@columns)=map { $self->column($_)->line($datasrc) } $self->columns;
   push @columns, "PRIMARY KEY (". $self->primary_key. ")"
     if $self->primary_key;
diff --git a/README b/README
index 2d1c2e2..5fb0d66 100644 (file)
--- a/README
+++ b/README
@@ -10,7 +10,7 @@ This module implements an OO-interface to database schemas.  Using this module,
 you can create a database schema with an OO Perl interface.  You can read the
 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
-statements to create the given schema.
+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
@@ -38,4 +38,4 @@ A mailing list is available.  Send a blank message to
 
 Homepage: <http://www.420.am/dbix-dbschema>
 
-$Id: README,v 1.2 2000-09-27 11:51:36 ivan Exp $
+$Id: README,v 1.3 2000-09-27 12:40:35 ivan Exp $