Commit | Line | Data |
4f4fd192 |
1 | use MooseX::Declare; |
2 | role SQL::Translator::Parser::DDL { |
9b50af5c |
3 | use MooseX::Types::Moose qw(HashRef Maybe Str); |
4 | use SQL::Translator::Types qw(Schema); |
5 | use SQL::Translator::Constants qw(:sqlt_types); |
6 | use MooseX::MultiMethods; |
7 | use Parse::RecDescent; |
8 | |
9 | has 'data_type_mapping' => ( |
10 | isa => HashRef, |
11 | is => 'ro', |
12 | lazy_build => 1 |
13 | ); |
14 | |
15 | has 'schema_name' => ( |
16 | is => 'rw', |
17 | isa => Maybe[Str], |
18 | lazy => 1, |
19 | default => undef |
20 | ); |
21 | |
22 | has 'grammar' => ( |
23 | is => 'ro', |
24 | isa => Str, |
25 | lazy_build => 1 |
26 | ); |
27 | |
28 | method _subclass { |
29 | return unless $self->type; |
30 | |
31 | my $grammar = 'SQL::Translator::Grammar::' . $self->type; |
32 | Class::MOP::load_class($grammar); |
33 | $grammar->meta->apply($self); |
34 | |
35 | my $role = __PACKAGE__ . '::' . $self->type; |
36 | Class::MOP::load_class($role); |
37 | $role->meta->apply($self); |
38 | } |
39 | |
40 | method _build_data_type_mapping { |
41 | return { |
42 | 'text' => SQL_LONGVARCHAR(), |
43 | 'timestamp' => SQL_TIMESTAMP(), |
44 | 'timestamp without time zone' => SQL_TYPE_TIMESTAMP(), |
45 | 'timestamp' => SQL_TYPE_TIMESTAMP_WITH_TIMEZONE(), |
46 | 'int' => SQL_INTEGER(), |
47 | 'integer' => SQL_INTEGER(), |
48 | 'character' => SQL_CHAR(), |
49 | 'varchar' => SQL_VARCHAR(), |
50 | 'char' => SQL_CHAR(), |
51 | 'bigint' => SQL_BIGINT() |
52 | } |
53 | } |
4f4fd192 |
54 | } |