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