comparison 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
comparison
equal deleted inserted replaced
164:eb3e9861a761 165:76515373dac0
1 use strict; 1 use strict;
2 package IMPL::SQL::Schema::Type; 2 package IMPL::SQL::Schema::Type;
3 use base qw(IMPL::Object IMPL::Object::Autofill); 3 use parent qw(IMPL::Object IMPL::Object::Autofill);
4 use IMPL::Class::Property; 4 use IMPL::Class::Property;
5 use IMPL::Class::Property::Direct; 5 use IMPL::Class::Property::Direct;
6 6
7 BEGIN { 7 BEGIN {
8 public _direct property Name => prop_get; 8 public _direct property name => prop_get;
9 public _direct property MaxLength => prop_get; 9 public _direct property maxLength => prop_get;
10 public _direct property Scale => prop_get; 10 public _direct property scale => prop_get;
11 public _direct property Unsigned => prop_get; 11 public _direct property unsigned => prop_get;
12 public _direct property Zerofill => prop_get; 12 public _direct property zerofill => prop_get;
13 public _direct property Tag => prop_get; 13 public _direct property tag => prop_get;
14 } 14 }
15 15
16 __PACKAGE__->PassThroughArgs; 16 __PACKAGE__->PassThroughArgs;
17 17
18 sub CTOR { 18 sub CTOR {
19 my $this = shift; 19 my $this = shift;
20 20
21 $this->{$Scale} = 0 if not $this->{$Scale}; 21 $this->{$scale} = 0 if not $this->{$scale};
22 } 22 }
23 23
24 sub isEquals { 24 sub isEquals {
25 my ($a,$b) = @_; 25 my ($a,$b) = @_;
26 26
36 } 36 }
37 37
38 sub isSame { 38 sub isSame {
39 my ($this,$other) = @_; 39 my ($this,$other) = @_;
40 40
41 return ($this->{$Name} eq $other->{$Name} and isEquals($this->{$MaxLength},$other->{$MaxLength}) and isEquals($this->{$Scale},$other->{$Scale})); 41 return ($this->{$name} eq $other->{$name} and isEquals($this->{$maxLength},$other->{$maxLength}) and isEquals($this->{$scale},$other->{$scale}));
42 } 42 }
43 43
44 1; 44 1;
45
46 __END__
47
48 =pod
49
50 =head1 NAME
51
52 C<IMPL::SQL::Schema::Type> Описывает SQL типы данных
53
54 =head1 SYNOPSIS
55
56 =begin code
57
58 use IMPL::SQL::Schema::Type;
59
60 my $varchar_t = new IMPL::SQL::Schema::Type( name => 'varchar', maxLength => 255 );
61
62 my $real_t = new IMPL::SQL::Schema::Type( name => 'float', maxLength=> 10, scale => 4); # mysql: float(10,4)
63
64 =end
65
66 Данный класс используется для стандатрного описания SQL типов данных. В зависимости
67 от движка БД эти объекты могут быть представлены различными строковыми представлениями.
68
69 =head1 MEMBERS
70
71 =over
72
73 =item C<CTOR(%props)>
74
75 Конструктор, заполняет объект значениями которые были переданы в конструкторе.
76
77 =item C<[get]name>
78
79 Имя типа. Обязательно.
80
81 =item C<[get]maxLength>
82
83 Максимальная длина, используется только для типов, имеющих длину (либо переменную,
84 либо постоянную).
85
86 =item C<[get]scale>
87
88 Точность, количество знаков после запятой. Используется вместе с C<maxLength>.
89
90 =item C<[get]unsigned>
91
92 Используется с числовыми данными, обозначает беззнаковые типы.
93
94 =item C<[get]zerofill>
95
96 Нестандартный атрибут дополняющий числа лидирующими нулями до C<maxLength>.
97
98 =item C<[get]tag>
99
100 Хеш с дополнительными опциями.
101
102 =back
103
104 =cut