annotate _test/Test/SQL/Diff.pm @ 181:47dac58691ee

New templating system, small fixes
author sourcer
date Thu, 26 Jan 2012 01:15:57 +0400
parents d1676be8afcc
children 4d0e1962161c
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
168
6148f89bb7bf IMPL::SQL::Schema::Traits::Diff alfa version
sourcer
parents:
diff changeset
1 package Test::SQL::Diff;
6148f89bb7bf IMPL::SQL::Schema::Traits::Diff alfa version
sourcer
parents:
diff changeset
2 use strict;
6148f89bb7bf IMPL::SQL::Schema::Traits::Diff alfa version
sourcer
parents:
diff changeset
3 use warnings;
6148f89bb7bf IMPL::SQL::Schema::Traits::Diff alfa version
sourcer
parents:
diff changeset
4 use parent qw(IMPL::Test::Unit);
6148f89bb7bf IMPL::SQL::Schema::Traits::Diff alfa version
sourcer
parents:
diff changeset
5
6148f89bb7bf IMPL::SQL::Schema::Traits::Diff alfa version
sourcer
parents:
diff changeset
6 use IMPL::Test qw(test failed assert);
6148f89bb7bf IMPL::SQL::Schema::Traits::Diff alfa version
sourcer
parents:
diff changeset
7 use IMPL::SQL::Schema();
6148f89bb7bf IMPL::SQL::Schema::Traits::Diff alfa version
sourcer
parents:
diff changeset
8 use IMPL::SQL::Types qw(Integer Varchar Text);
6148f89bb7bf IMPL::SQL::Schema::Traits::Diff alfa version
sourcer
parents:
diff changeset
9 use IMPL::SQL::Schema::Traits::Diff();
6148f89bb7bf IMPL::SQL::Schema::Traits::Diff alfa version
sourcer
parents:
diff changeset
10 use Data::Dumper;
6148f89bb7bf IMPL::SQL::Schema::Traits::Diff alfa version
sourcer
parents:
diff changeset
11
6148f89bb7bf IMPL::SQL::Schema::Traits::Diff alfa version
sourcer
parents:
diff changeset
12 __PACKAGE__->PassThroughArgs;
6148f89bb7bf IMPL::SQL::Schema::Traits::Diff alfa version
sourcer
parents:
diff changeset
13
6148f89bb7bf IMPL::SQL::Schema::Traits::Diff alfa version
sourcer
parents:
diff changeset
14 test diff => sub {
6148f89bb7bf IMPL::SQL::Schema::Traits::Diff alfa version
sourcer
parents:
diff changeset
15 my $schemaSrc = new IMPL::SQL::Schema(name => 'simple', version => 1 );
6148f89bb7bf IMPL::SQL::Schema::Traits::Diff alfa version
sourcer
parents:
diff changeset
16
169
fd92830036c3 corrected IMPL::SQL::Schema::Diff
sourcer
parents: 168
diff changeset
17 my $tbl = $schemaSrc->AddTable({
168
6148f89bb7bf IMPL::SQL::Schema::Traits::Diff alfa version
sourcer
parents:
diff changeset
18 name => 'User',
6148f89bb7bf IMPL::SQL::Schema::Traits::Diff alfa version
sourcer
parents:
diff changeset
19 columns => [
169
fd92830036c3 corrected IMPL::SQL::Schema::Diff
sourcer
parents: 168
diff changeset
20 { name => 'name', type => Varchar(255) },
fd92830036c3 corrected IMPL::SQL::Schema::Diff
sourcer
parents: 168
diff changeset
21 { name => 'description', type => Varchar(255) }
168
6148f89bb7bf IMPL::SQL::Schema::Traits::Diff alfa version
sourcer
parents:
diff changeset
22 ]
6148f89bb7bf IMPL::SQL::Schema::Traits::Diff alfa version
sourcer
parents:
diff changeset
23 });
6148f89bb7bf IMPL::SQL::Schema::Traits::Diff alfa version
sourcer
parents:
diff changeset
24
169
fd92830036c3 corrected IMPL::SQL::Schema::Diff
sourcer
parents: 168
diff changeset
25 $tbl->AddConstraint( unique => { name => 'unique_name', columns => ['name'] });
fd92830036c3 corrected IMPL::SQL::Schema::Diff
sourcer
parents: 168
diff changeset
26
168
6148f89bb7bf IMPL::SQL::Schema::Traits::Diff alfa version
sourcer
parents:
diff changeset
27 my $schemaDst = new IMPL::SQL::Schema(name => 'simple', version => 2 );
6148f89bb7bf IMPL::SQL::Schema::Traits::Diff alfa version
sourcer
parents:
diff changeset
28
6148f89bb7bf IMPL::SQL::Schema::Traits::Diff alfa version
sourcer
parents:
diff changeset
29 my $users = $schemaDst->AddTable({
6148f89bb7bf IMPL::SQL::Schema::Traits::Diff alfa version
sourcer
parents:
diff changeset
30 name => 'User',
6148f89bb7bf IMPL::SQL::Schema::Traits::Diff alfa version
sourcer
parents:
diff changeset
31 columns => [
6148f89bb7bf IMPL::SQL::Schema::Traits::Diff alfa version
sourcer
parents:
diff changeset
32 { name => 'id', type => Integer },
6148f89bb7bf IMPL::SQL::Schema::Traits::Diff alfa version
sourcer
parents:
diff changeset
33 { name => 'login', type => Varchar(255) },
6148f89bb7bf IMPL::SQL::Schema::Traits::Diff alfa version
sourcer
parents:
diff changeset
34 { name => 'description', type => Text, isNullable => 1 }
6148f89bb7bf IMPL::SQL::Schema::Traits::Diff alfa version
sourcer
parents:
diff changeset
35 ]
6148f89bb7bf IMPL::SQL::Schema::Traits::Diff alfa version
sourcer
parents:
diff changeset
36 });
6148f89bb7bf IMPL::SQL::Schema::Traits::Diff alfa version
sourcer
parents:
diff changeset
37
6148f89bb7bf IMPL::SQL::Schema::Traits::Diff alfa version
sourcer
parents:
diff changeset
38 $users->SetPrimaryKey('id');
169
fd92830036c3 corrected IMPL::SQL::Schema::Diff
sourcer
parents: 168
diff changeset
39 $users->AddConstraint( unique => { name => 'unique_login', columns => ['login'] } );
168
6148f89bb7bf IMPL::SQL::Schema::Traits::Diff alfa version
sourcer
parents:
diff changeset
40
181
47dac58691ee New templating system, small fixes
sourcer
parents: 180
diff changeset
41 #warn Dumper(IMPL::SQL::Schema::Traits::Diff->Diff($schemaSrc,$schemaDst));
168
6148f89bb7bf IMPL::SQL::Schema::Traits::Diff alfa version
sourcer
parents:
diff changeset
42
6148f89bb7bf IMPL::SQL::Schema::Traits::Diff alfa version
sourcer
parents:
diff changeset
43 $schemaSrc->Dispose;
6148f89bb7bf IMPL::SQL::Schema::Traits::Diff alfa version
sourcer
parents:
diff changeset
44 $schemaDst->Dispose;
6148f89bb7bf IMPL::SQL::Schema::Traits::Diff alfa version
sourcer
parents:
diff changeset
45
6148f89bb7bf IMPL::SQL::Schema::Traits::Diff alfa version
sourcer
parents:
diff changeset
46 };
6148f89bb7bf IMPL::SQL::Schema::Traits::Diff alfa version
sourcer
parents:
diff changeset
47
6148f89bb7bf IMPL::SQL::Schema::Traits::Diff alfa version
sourcer
parents:
diff changeset
48
180
d1676be8afcc Перекодировка в utf-8
sourcer
parents: 169
diff changeset
49 1;