line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package DBIx::Result::Convert::JSONSchema::Type::MySQL; |
2
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
=head1 NAME |
4
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
DBIx::Result::Convert::JSONSchema::Type::MySQL - Mapping of MySQL field type to JSON property type |
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
=head1 VERSION |
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
0.01 |
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
=head1 SYNOPSIS |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
use DBIx::Result::Convert::JSONSchema::Type::MySQL; |
14
|
|
|
|
|
|
|
my $type_map = DBIx::Result::Convert::JSONSchema::Type::MySQL->get_type_map; |
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
=head1 DESCRIPTION |
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
This module defines mapping between DBIx MySQL field types to JSON schema property types. |
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
=cut |
21
|
|
|
|
|
|
|
|
22
|
4
|
|
|
4
|
|
2315
|
use strict; |
|
4
|
|
|
|
|
21
|
|
|
4
|
|
|
|
|
103
|
|
23
|
4
|
|
|
4
|
|
27
|
use warnings; |
|
4
|
|
|
|
|
15
|
|
|
4
|
|
|
|
|
140
|
|
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
our $VERSION = '0.01'; |
26
|
|
|
|
|
|
|
|
27
|
4
|
|
|
4
|
|
430
|
use Readonly; |
|
4
|
|
|
|
|
3248
|
|
|
4
|
|
|
|
|
660
|
|
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
Readonly my %TYPE_MAP => ( |
31
|
|
|
|
|
|
|
string => [ |
32
|
|
|
|
|
|
|
qw/ char varchar binary varbinary blob text mediumtext tinytext /, |
33
|
|
|
|
|
|
|
qw/ date datetime timestamp time year / |
34
|
|
|
|
|
|
|
], |
35
|
|
|
|
|
|
|
enum => [ qw/ enum set / ], |
36
|
|
|
|
|
|
|
integer => [ qw/ integer smallint tinyint mediumint bigint bit / ], |
37
|
|
|
|
|
|
|
number => [ qw/ decimal float double /, 'double precision' ], |
38
|
|
|
|
|
|
|
object => [ qw/ json / ], |
39
|
|
|
|
|
|
|
); |
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
=head2 C |
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
Return mapping of DBIx::Class:Result field name => JSON Schema field name. |
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
# { decimal => 'number', time => 'string', ... } |
46
|
|
|
|
|
|
|
my $map = DBIx::Result::Convert::Type::MySQL->get_type_map; |
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
=cut |
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
sub get_type_map { |
51
|
5
|
|
|
5
|
1
|
213863
|
my ( $class ) = @_; |
52
|
|
|
|
|
|
|
|
53
|
5
|
|
|
|
|
75
|
my $mapped_fields; |
54
|
5
|
|
|
|
|
27
|
foreach my $json_type ( keys %TYPE_MAP ) { |
55
|
25
|
|
|
|
|
270
|
foreach my $dbix_type ( @{ $TYPE_MAP{ $json_type } } ) { |
|
25
|
|
|
|
|
73
|
|
56
|
130
|
|
|
|
|
1054
|
$mapped_fields->{ $dbix_type } = $json_type; |
57
|
|
|
|
|
|
|
} |
58
|
|
|
|
|
|
|
} |
59
|
|
|
|
|
|
|
|
60
|
5
|
|
|
|
|
115
|
return $mapped_fields; |
61
|
|
|
|
|
|
|
} |
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
=head1 AUTHOR |
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
malishew - C |
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
=head1 LICENSE |
68
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
This library is free software; you can redistribute it and/or modify it under |
70
|
|
|
|
|
|
|
the same terms as Perl itself. If you would like to contribute documentation |
71
|
|
|
|
|
|
|
or file a bug report then please raise an issue / pull request: |
72
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
https://github.com/Humanstate/p5-dbix-result-convert-jsonschema |
74
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
=cut |
76
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
1; |