annotate _test/Test/SQL/Diff.pm @ 260:2879cdb6b8cd

sync
author sergey
date Tue, 25 Dec 2012 02:18:59 +0400
parents 4d0e1962161c
children 56364d0c4b4f
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 {
194
4d0e1962161c Replaced tabs with spaces
cin
parents: 181
diff changeset
15 my $schemaSrc = new IMPL::SQL::Schema(name => 'simple', version => 1 );
4d0e1962161c Replaced tabs with spaces
cin
parents: 181
diff changeset
16
4d0e1962161c Replaced tabs with spaces
cin
parents: 181
diff changeset
17 my $tbl = $schemaSrc->AddTable({
4d0e1962161c Replaced tabs with spaces
cin
parents: 181
diff changeset
18 name => 'User',
4d0e1962161c Replaced tabs with spaces
cin
parents: 181
diff changeset
19 columns => [
4d0e1962161c Replaced tabs with spaces
cin
parents: 181
diff changeset
20 { name => 'name', type => Varchar(255) },
4d0e1962161c Replaced tabs with spaces
cin
parents: 181
diff changeset
21 { name => 'description', type => Varchar(255) }
4d0e1962161c Replaced tabs with spaces
cin
parents: 181
diff changeset
22 ]
4d0e1962161c Replaced tabs with spaces
cin
parents: 181
diff changeset
23 });
4d0e1962161c Replaced tabs with spaces
cin
parents: 181
diff changeset
24
4d0e1962161c Replaced tabs with spaces
cin
parents: 181
diff changeset
25 $tbl->AddConstraint( unique => { name => 'unique_name', columns => ['name'] });
4d0e1962161c Replaced tabs with spaces
cin
parents: 181
diff changeset
26
4d0e1962161c Replaced tabs with spaces
cin
parents: 181
diff changeset
27 my $schemaDst = new IMPL::SQL::Schema(name => 'simple', version => 2 );
4d0e1962161c Replaced tabs with spaces
cin
parents: 181
diff changeset
28
4d0e1962161c Replaced tabs with spaces
cin
parents: 181
diff changeset
29 my $users = $schemaDst->AddTable({
4d0e1962161c Replaced tabs with spaces
cin
parents: 181
diff changeset
30 name => 'User',
4d0e1962161c Replaced tabs with spaces
cin
parents: 181
diff changeset
31 columns => [
4d0e1962161c Replaced tabs with spaces
cin
parents: 181
diff changeset
32 { name => 'id', type => Integer },
4d0e1962161c Replaced tabs with spaces
cin
parents: 181
diff changeset
33 { name => 'login', type => Varchar(255) },
4d0e1962161c Replaced tabs with spaces
cin
parents: 181
diff changeset
34 { name => 'description', type => Text, isNullable => 1 }
4d0e1962161c Replaced tabs with spaces
cin
parents: 181
diff changeset
35 ]
4d0e1962161c Replaced tabs with spaces
cin
parents: 181
diff changeset
36 });
4d0e1962161c Replaced tabs with spaces
cin
parents: 181
diff changeset
37
4d0e1962161c Replaced tabs with spaces
cin
parents: 181
diff changeset
38 $users->SetPrimaryKey('id');
4d0e1962161c Replaced tabs with spaces
cin
parents: 181
diff changeset
39 $users->AddConstraint( unique => { name => 'unique_login', columns => ['login'] } );
4d0e1962161c Replaced tabs with spaces
cin
parents: 181
diff changeset
40
4d0e1962161c Replaced tabs with spaces
cin
parents: 181
diff changeset
41 #warn Dumper(IMPL::SQL::Schema::Traits::Diff->Diff($schemaSrc,$schemaDst));
4d0e1962161c Replaced tabs with spaces
cin
parents: 181
diff changeset
42
4d0e1962161c Replaced tabs with spaces
cin
parents: 181
diff changeset
43 $schemaSrc->Dispose;
4d0e1962161c Replaced tabs with spaces
cin
parents: 181
diff changeset
44 $schemaDst->Dispose;
4d0e1962161c Replaced tabs with spaces
cin
parents: 181
diff changeset
45
168
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;