Show
Ignore:
Timestamp:
02/04/08 22:09:56 (2 years ago)
Author:
eevee
Message:

Bit of a shoutbox test. Not particularly amazing. For the life of me I can't figure out how to log in and stay that way. (#152)
Tossing in my schema cleanup script, too. Ugh dirty mixed commits~

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • veekun/trunk/lib/Vee/Schema.pm

    r31 r404  
    11package Vee::Schema; 
    2  
    3 # Created by DBIx::Class::Schema::Loader v0.03003 @ 2006-07-09 12:56:13 
    42 
    53use strict; 
    64use warnings; 
    7  
    85use base 'DBIx::Class::Schema'; 
    96 
    107__PACKAGE__->load_classes; 
    118 
     9=head1 METHODS 
     10 
     11=head2 add_simple_column_types 
     12 
     13Iterates over every column in every table in the schema.  Primary key columns 
     14named C<id> are given a C<data_type> of C<integer>; all other columns are set 
     15C<is_nullable>. 
     16 
     17This method is really a hack for deploying the schema to SQLite and testing with 
     18dummy data; autoincrement will only work on single-column integral primary keys, 
     19and defaults for every column would be a pain to mark just for tests. 
     20 
     21=cut 
     22 
     23sub add_simple_column_types { 
     24    my ($self) = @_; 
     25 
     26    for my $table_name ($self->sources) { 
     27        my $table = $self->source($table_name); 
     28 
     29        for my $column_name ($table->columns) { 
     30            my $column_info = $table->column_info($column_name); 
     31 
     32            # sessions table uses a string, as dictated by Session plugin 
     33            if ($table_name ne 'Sessions' and 
     34                $column_name eq 'id' and 
     35                join("\0", $table->primary_columns) eq 'id') 
     36            { 
     37                $column_info->{data_type} = 'integer'; 
     38            } else { 
     39                $column_info->{is_nullable} = 1; 
     40            } 
     41        } 
     42    } 
     43} 
     44 
    12451;