annotate Lib/IMPL/SQL/Schema/Type.pm @ 165:76515373dac0

Added Class::Template, Rewritten SQL::Schema 'use parent' directive instead of 'use base'
author wizard
date Sat, 23 Apr 2011 23:06:48 +0400
parents 16ada169ca75
children 1f7a6d762394
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
49
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 32
diff changeset
1 use strict;
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 32
diff changeset
2 package IMPL::SQL::Schema::Type;
165
76515373dac0 Added Class::Template,
wizard
parents: 49
diff changeset
3 use parent qw(IMPL::Object IMPL::Object::Autofill);
49
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 32
diff changeset
4 use IMPL::Class::Property;
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 32
diff changeset
5 use IMPL::Class::Property::Direct;
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 32
diff changeset
6
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 32
diff changeset
7 BEGIN {
165
76515373dac0 Added Class::Template,
wizard
parents: 49
diff changeset
8 public _direct property name => prop_get;
76515373dac0 Added Class::Template,
wizard
parents: 49
diff changeset
9 public _direct property maxLength => prop_get;
76515373dac0 Added Class::Template,
wizard
parents: 49
diff changeset
10 public _direct property scale => prop_get;
76515373dac0 Added Class::Template,
wizard
parents: 49
diff changeset
11 public _direct property unsigned => prop_get;
76515373dac0 Added Class::Template,
wizard
parents: 49
diff changeset
12 public _direct property zerofill => prop_get;
76515373dac0 Added Class::Template,
wizard
parents: 49
diff changeset
13 public _direct property tag => prop_get;
49
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 32
diff changeset
14 }
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 32
diff changeset
15
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 32
diff changeset
16 __PACKAGE__->PassThroughArgs;
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 32
diff changeset
17
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 32
diff changeset
18 sub CTOR {
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 32
diff changeset
19 my $this = shift;
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 32
diff changeset
20
165
76515373dac0 Added Class::Template,
wizard
parents: 49
diff changeset
21 $this->{$scale} = 0 if not $this->{$scale};
49
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 32
diff changeset
22 }
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 32
diff changeset
23
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 32
diff changeset
24 sub isEquals {
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 32
diff changeset
25 my ($a,$b) = @_;
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 32
diff changeset
26
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 32
diff changeset
27 if (defined $a and defined $b) {
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 32
diff changeset
28 return $a == $b;
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 32
diff changeset
29 } else {
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 32
diff changeset
30 if (defined $a or defined $b) {
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 32
diff changeset
31 return 0;
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 32
diff changeset
32 } else {
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 32
diff changeset
33 return 1;
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 32
diff changeset
34 }
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 32
diff changeset
35 }
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 32
diff changeset
36 }
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 32
diff changeset
37
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 32
diff changeset
38 sub isSame {
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 32
diff changeset
39 my ($this,$other) = @_;
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 32
diff changeset
40
165
76515373dac0 Added Class::Template,
wizard
parents: 49
diff changeset
41 return ($this->{$name} eq $other->{$name} and isEquals($this->{$maxLength},$other->{$maxLength}) and isEquals($this->{$scale},$other->{$scale}));
49
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 32
diff changeset
42 }
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 32
diff changeset
43
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 32
diff changeset
44 1;
165
76515373dac0 Added Class::Template,
wizard
parents: 49
diff changeset
45
76515373dac0 Added Class::Template,
wizard
parents: 49
diff changeset
46 __END__
76515373dac0 Added Class::Template,
wizard
parents: 49
diff changeset
47
76515373dac0 Added Class::Template,
wizard
parents: 49
diff changeset
48 =pod
76515373dac0 Added Class::Template,
wizard
parents: 49
diff changeset
49
76515373dac0 Added Class::Template,
wizard
parents: 49
diff changeset
50 =head1 NAME
76515373dac0 Added Class::Template,
wizard
parents: 49
diff changeset
51
76515373dac0 Added Class::Template,
wizard
parents: 49
diff changeset
52 C<IMPL::SQL::Schema::Type> Описывает SQL типы данных
76515373dac0 Added Class::Template,
wizard
parents: 49
diff changeset
53
76515373dac0 Added Class::Template,
wizard
parents: 49
diff changeset
54 =head1 SYNOPSIS
76515373dac0 Added Class::Template,
wizard
parents: 49
diff changeset
55
76515373dac0 Added Class::Template,
wizard
parents: 49
diff changeset
56 =begin code
76515373dac0 Added Class::Template,
wizard
parents: 49
diff changeset
57
76515373dac0 Added Class::Template,
wizard
parents: 49
diff changeset
58 use IMPL::SQL::Schema::Type;
76515373dac0 Added Class::Template,
wizard
parents: 49
diff changeset
59
76515373dac0 Added Class::Template,
wizard
parents: 49
diff changeset
60 my $varchar_t = new IMPL::SQL::Schema::Type( name => 'varchar', maxLength => 255 );
76515373dac0 Added Class::Template,
wizard
parents: 49
diff changeset
61
76515373dac0 Added Class::Template,
wizard
parents: 49
diff changeset
62 my $real_t = new IMPL::SQL::Schema::Type( name => 'float', maxLength=> 10, scale => 4); # mysql: float(10,4)
76515373dac0 Added Class::Template,
wizard
parents: 49
diff changeset
63
76515373dac0 Added Class::Template,
wizard
parents: 49
diff changeset
64 =end
76515373dac0 Added Class::Template,
wizard
parents: 49
diff changeset
65
76515373dac0 Added Class::Template,
wizard
parents: 49
diff changeset
66 Данный класс используется для стандатрного описания SQL типов данных. В зависимости
76515373dac0 Added Class::Template,
wizard
parents: 49
diff changeset
67 от движка БД эти объекты могут быть представлены различными строковыми представлениями.
76515373dac0 Added Class::Template,
wizard
parents: 49
diff changeset
68
76515373dac0 Added Class::Template,
wizard
parents: 49
diff changeset
69 =head1 MEMBERS
76515373dac0 Added Class::Template,
wizard
parents: 49
diff changeset
70
76515373dac0 Added Class::Template,
wizard
parents: 49
diff changeset
71 =over
76515373dac0 Added Class::Template,
wizard
parents: 49
diff changeset
72
76515373dac0 Added Class::Template,
wizard
parents: 49
diff changeset
73 =item C<CTOR(%props)>
76515373dac0 Added Class::Template,
wizard
parents: 49
diff changeset
74
76515373dac0 Added Class::Template,
wizard
parents: 49
diff changeset
75 Конструктор, заполняет объект значениями которые были переданы в конструкторе.
76515373dac0 Added Class::Template,
wizard
parents: 49
diff changeset
76
76515373dac0 Added Class::Template,
wizard
parents: 49
diff changeset
77 =item C<[get]name>
76515373dac0 Added Class::Template,
wizard
parents: 49
diff changeset
78
76515373dac0 Added Class::Template,
wizard
parents: 49
diff changeset
79 Имя типа. Обязательно.
76515373dac0 Added Class::Template,
wizard
parents: 49
diff changeset
80
76515373dac0 Added Class::Template,
wizard
parents: 49
diff changeset
81 =item C<[get]maxLength>
76515373dac0 Added Class::Template,
wizard
parents: 49
diff changeset
82
76515373dac0 Added Class::Template,
wizard
parents: 49
diff changeset
83 Максимальная длина, используется только для типов, имеющих длину (либо переменную,
76515373dac0 Added Class::Template,
wizard
parents: 49
diff changeset
84 либо постоянную).
76515373dac0 Added Class::Template,
wizard
parents: 49
diff changeset
85
76515373dac0 Added Class::Template,
wizard
parents: 49
diff changeset
86 =item C<[get]scale>
76515373dac0 Added Class::Template,
wizard
parents: 49
diff changeset
87
76515373dac0 Added Class::Template,
wizard
parents: 49
diff changeset
88 Точность, количество знаков после запятой. Используется вместе с C<maxLength>.
76515373dac0 Added Class::Template,
wizard
parents: 49
diff changeset
89
76515373dac0 Added Class::Template,
wizard
parents: 49
diff changeset
90 =item C<[get]unsigned>
76515373dac0 Added Class::Template,
wizard
parents: 49
diff changeset
91
76515373dac0 Added Class::Template,
wizard
parents: 49
diff changeset
92 Используется с числовыми данными, обозначает беззнаковые типы.
76515373dac0 Added Class::Template,
wizard
parents: 49
diff changeset
93
76515373dac0 Added Class::Template,
wizard
parents: 49
diff changeset
94 =item C<[get]zerofill>
76515373dac0 Added Class::Template,
wizard
parents: 49
diff changeset
95
76515373dac0 Added Class::Template,
wizard
parents: 49
diff changeset
96 Нестандартный атрибут дополняющий числа лидирующими нулями до C<maxLength>.
76515373dac0 Added Class::Template,
wizard
parents: 49
diff changeset
97
76515373dac0 Added Class::Template,
wizard
parents: 49
diff changeset
98 =item C<[get]tag>
76515373dac0 Added Class::Template,
wizard
parents: 49
diff changeset
99
76515373dac0 Added Class::Template,
wizard
parents: 49
diff changeset
100 Хеш с дополнительными опциями.
76515373dac0 Added Class::Template,
wizard
parents: 49
diff changeset
101
76515373dac0 Added Class::Template,
wizard
parents: 49
diff changeset
102 =back
76515373dac0 Added Class::Template,
wizard
parents: 49
diff changeset
103
76515373dac0 Added Class::Template,
wizard
parents: 49
diff changeset
104 =cut