[Rt-commit] r4336 - in Jifty-DBI/trunk: . lib/Jifty/DBI t

jesse at bestpractical.com jesse at bestpractical.com
Tue Dec 20 16:32:42 EST 2005


Author: jesse
Date: Tue Dec 20 16:32:41 2005
New Revision: 4336

Modified:
   Jifty-DBI/trunk/   (props changed)
   Jifty-DBI/trunk/Changes
   Jifty-DBI/trunk/META.yml
   Jifty-DBI/trunk/lib/Jifty/DBI/Record.pm
   Jifty-DBI/trunk/lib/Jifty/DBI/SchemaGenerator.pm
   Jifty-DBI/trunk/t/10schema.t
Log:
 r20871 at truegrounds:  jesse | 2005-12-20 16:10:14 -0500
 * Test updates for mysql and pg


Modified: Jifty-DBI/trunk/Changes
==============================================================================
--- Jifty-DBI/trunk/Changes	(original)
+++ Jifty-DBI/trunk/Changes	Tue Dec 20 16:32:41 2005
@@ -1,5 +1,7 @@
 Revision history for Perl extension Jifty::DBI.
 
+* Added more tests for mysql and Pg now that DBSchema supports them. Tests want more love
+
 0.05_03
 
 Forward-ported features from DBIx::SearchBuilder:

Modified: Jifty-DBI/trunk/META.yml
==============================================================================
--- Jifty-DBI/trunk/META.yml	(original)
+++ Jifty-DBI/trunk/META.yml	Tue Dec 20 16:32:41 2005
@@ -21,4 +21,4 @@
 no_index:
   directory:
     - inc
-generated_by: Module::Install version 0.37
+generated_by: Module::Install version 0.41

Modified: Jifty-DBI/trunk/lib/Jifty/DBI/Record.pm
==============================================================================
--- Jifty-DBI/trunk/lib/Jifty/DBI/Record.pm	(original)
+++ Jifty-DBI/trunk/lib/Jifty/DBI/Record.pm	Tue Dec 20 16:32:41 2005
@@ -342,7 +342,9 @@
 
 sub columns {
     my $self = shift;
-    return ( values %{ $self->COLUMNS } );
+    return ( sort { 
+         ((($b->type||'') eq 'serial') <=> (($a->type||'') eq 'serial')) or 
+            ( $a->name cmp $b->name) } values %{ $self->COLUMNS } );
 }
 
 # sub {{{ readable_attributes

Modified: Jifty-DBI/trunk/lib/Jifty/DBI/SchemaGenerator.pm
==============================================================================
--- Jifty-DBI/trunk/lib/Jifty/DBI/SchemaGenerator.pm	(original)
+++ Jifty-DBI/trunk/lib/Jifty/DBI/SchemaGenerator.pm	Tue Dec 20 16:32:41 2005
@@ -190,8 +190,7 @@
 
     my @cols;
 
-    # The sort here is to make it predictable, so that we can write tests.
-    for my $column ( sort { $a->name cmp $b->name } @columns ) {
+    for my $column (  @columns ) {
 
         # Skip "Virtual" columns - (foreign keys to collections)
         next if $column->virtual;

Modified: Jifty-DBI/trunk/t/10schema.t
==============================================================================
--- Jifty-DBI/trunk/t/10schema.t	(original)
+++ Jifty-DBI/trunk/t/10schema.t	Tue Dec 20 16:32:41 2005
@@ -26,7 +26,7 @@
 
 foreach my $d ( @available_drivers ) {
   SKIP: {
-    unless ($d eq 'Pg') {
+    unless ($d eq 'Pg' or $d eq 'SQLite' or $d eq 'mysql') {
       skip "first goal is to work on Pg", TESTS_PER_DRIVER;
     }
     
@@ -60,8 +60,8 @@
 
     ok($ret != 0, "added model from real class");
 
-    is_ignoring_space($SG->create_table_sql_text, <<END_SCHEMA, "got the right schema");
-    CREATE table addresses ( 
+    if ($d eq 'Pg' ) { is_ignoring_space($SG->create_table_sql_text, <<END_SCHEMA, "got the right schema");
+    CREATE TABLE addresses ( 
       id serial NOT NULL , 
       employee_id integer ,
       name varchar DEFAULT 'Frank' ,
@@ -70,6 +70,13 @@
     ) ;
 END_SCHEMA
 
+    } else {
+     TODO: {
+            local $TODO = "Need schema for $d";
+            ok(0, "need db schema for $d");
+        };
+    }
+
     my $employee = Sample::Employee->new;
     
     isa_ok($employee, 'Sample::Employee');
@@ -78,25 +85,41 @@
 
     ok($ret != 0, "added model from an instantiated object");
 
+    if ($d eq 'Pg') {
     is_ignoring_space($SG->create_table_sql_text, <<END_SCHEMA, "got the right schema");
-    CREATE table addresses ( 
+    CREATE TABLE addresses ( 
       id serial NOT NULL , 
       employee_id integer  ,
       name varchar DEFAULT 'Frank' ,
       phone varchar ,
       PRIMARY KEY (id)
     ) ;
-    CREATE table employees (
+    CREATE TABLE employees (
       id serial NOT NULL ,
       dexterity integer ,
       name varchar ,
       PRIMARY KEY (id)
     ) ;
 END_SCHEMA
+    } else {
+        TODO: {
+            local $TODO = "Need schema for $d";
+        ok(0, "need db schema for $d");
+        };
+    }
     
     my $manually_make_text = join ' ', map { "$_;" } $SG->create_table_sql_statements;
-    is_ignoring_space($SG->create_table_sql_text, $manually_make_text, 'create_table_sql_text is the statements in create_table_sql_statements')
-}}
+    if ($d eq 'Pg') { 
+         is_ignoring_space($SG->create_table_sql_text, $manually_make_text, 'create_table_sql_text is the statements in create_table_sql_statements')
+    } else {
+        TODO: {
+            local $TODO = "Need schema for $d";
+        ok(0, "need db schema for $d");
+        };
+    }
+
+}
+}
 
 sub is_ignoring_space {
   my $a = shift;


More information about the Rt-commit mailing list