| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package DBIx::QuickORM::Dialect; |
|
2
|
24
|
|
|
24
|
|
53587
|
use strict; |
|
|
24
|
|
|
|
|
79
|
|
|
|
24
|
|
|
|
|
1057
|
|
|
3
|
24
|
|
|
24
|
|
138
|
use warnings; |
|
|
24
|
|
|
|
|
73
|
|
|
|
24
|
|
|
|
|
1522
|
|
|
4
|
|
|
|
|
|
|
|
|
5
|
24
|
|
|
24
|
|
141
|
use Carp qw/croak confess/; |
|
|
24
|
|
|
|
|
52
|
|
|
|
24
|
|
|
|
|
7799
|
|
|
6
|
24
|
|
|
24
|
|
190
|
use Scalar::Util qw/blessed/; |
|
|
24
|
|
|
|
|
58
|
|
|
|
24
|
|
|
|
|
7593
|
|
|
7
|
24
|
|
|
24
|
|
1858
|
use DBI(); |
|
|
24
|
|
|
|
|
26779
|
|
|
|
24
|
|
|
|
|
1393
|
|
|
8
|
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
our $VERSION = '0.000019'; |
|
10
|
|
|
|
|
|
|
|
|
11
|
24
|
|
|
24
|
|
209
|
use DBIx::QuickORM::Util qw/load_class find_modules/; |
|
|
24
|
|
|
|
|
51
|
|
|
|
24
|
|
|
|
|
391
|
|
|
12
|
|
|
|
|
|
|
|
|
13
|
24
|
|
|
|
|
921
|
use DBIx::QuickORM::Util::HashBase qw{ |
|
14
|
|
|
|
|
|
|
<dbh |
|
15
|
|
|
|
|
|
|
<db_name |
|
16
|
24
|
|
|
24
|
|
1245
|
}; |
|
|
24
|
|
|
|
|
66
|
|
|
17
|
|
|
|
|
|
|
|
|
18
|
0
|
|
|
0
|
0
|
0
|
sub dsn_socket_field { 'host' } |
|
19
|
|
|
|
|
|
|
|
|
20
|
0
|
|
|
0
|
0
|
0
|
sub dbi_driver { confess "Not Implemented" } |
|
21
|
0
|
|
|
0
|
0
|
0
|
sub db_version { confess "Not Implemented" } |
|
22
|
|
|
|
|
|
|
|
|
23
|
0
|
|
|
0
|
0
|
0
|
sub start_txn { croak "$_[0]->start_txn() is not implemented" } |
|
24
|
0
|
|
|
0
|
0
|
0
|
sub commit_txn { croak "$_[0]->commit_txn() is not implemented" } |
|
25
|
0
|
|
|
0
|
0
|
0
|
sub rollback_txn { croak "$_[0]->rollback_txn() is not implemented" } |
|
26
|
0
|
|
|
0
|
0
|
0
|
sub create_savepoint { croak "$_[0]->create_savepoint() is not implemented" } |
|
27
|
0
|
|
|
0
|
0
|
0
|
sub commit_savepoint { croak "$_[0]->commit_savepoint() is not implemented" } |
|
28
|
0
|
|
|
0
|
0
|
0
|
sub rollback_savepoint { croak "$_[0]->rollback_savepoint() is not implemented" } |
|
29
|
|
|
|
|
|
|
|
|
30
|
156
|
|
|
156
|
0
|
4167
|
sub quote_binary_data { DBI::SQL_BINARY() } |
|
31
|
0
|
|
|
0
|
0
|
0
|
sub supports_returning_update { 0 } |
|
32
|
0
|
|
|
0
|
0
|
0
|
sub supports_returning_insert { 0 } |
|
33
|
0
|
|
|
0
|
0
|
0
|
sub supports_returning_delete { 0 } |
|
34
|
|
|
|
1
|
0
|
|
sub supports_type { } |
|
35
|
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
sub in_txn { |
|
37
|
32
|
|
|
32
|
0
|
48
|
my $self = shift; |
|
38
|
32
|
|
|
|
|
74
|
my %params = @_; |
|
39
|
32
|
|
33
|
|
|
176
|
my $dbh = $params{dbh} // $self->dbh; |
|
40
|
|
|
|
|
|
|
|
|
41
|
32
|
100
|
|
|
|
4677
|
return 1 if $dbh->{BegunWork}; |
|
42
|
30
|
50
|
|
|
|
338
|
return 0 if $dbh->{AutoCommit}; |
|
43
|
0
|
|
|
|
|
0
|
return 1; |
|
44
|
|
|
|
|
|
|
} |
|
45
|
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
sub dialect_name { |
|
47
|
0
|
|
|
0
|
0
|
0
|
my $self_or_class = shift; |
|
48
|
0
|
|
0
|
|
|
0
|
my $class = blessed($self_or_class) || $self_or_class; |
|
49
|
0
|
|
|
|
|
0
|
$class =~ s/^DBIx::QuickORM::Dialect:://; |
|
50
|
0
|
|
|
|
|
0
|
$class =~ s/::.*$//g; |
|
51
|
0
|
|
|
|
|
0
|
return $class; |
|
52
|
|
|
|
|
|
|
} |
|
53
|
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
sub init { |
|
55
|
23
|
|
|
23
|
0
|
215
|
my $self = shift; |
|
56
|
|
|
|
|
|
|
|
|
57
|
23
|
50
|
|
|
|
230
|
croak "A 'dbh' is required" unless $self->{+DBH}; |
|
58
|
23
|
50
|
|
|
|
1181
|
croak "A 'db_name' is arequired" unless $self->{+DB_NAME}; |
|
59
|
|
|
|
|
|
|
} |
|
60
|
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
sub dsn { |
|
62
|
0
|
|
|
0
|
0
|
0
|
my $self_or_class = shift; |
|
63
|
0
|
|
|
|
|
0
|
my ($db) = @_; |
|
64
|
|
|
|
|
|
|
|
|
65
|
0
|
|
0
|
|
|
0
|
my $driver = $db->dbi_driver // $self_or_class->dbi_driver; |
|
66
|
0
|
0
|
|
|
|
0
|
load_class($driver) or croak "Could not load '$driver': $@"; |
|
67
|
0
|
|
|
|
|
0
|
my $dsn_driver = $driver; |
|
68
|
0
|
|
|
|
|
0
|
$dsn_driver =~ s/^DBD:://; |
|
69
|
|
|
|
|
|
|
|
|
70
|
0
|
|
|
|
|
0
|
my $db_name = $db->db_name; |
|
71
|
0
|
|
|
|
|
0
|
my $dsn = "dbi:${dsn_driver}:dbname=${db_name};"; |
|
72
|
|
|
|
|
|
|
|
|
73
|
0
|
0
|
|
|
|
0
|
if (my $socket = $db->socket) { |
|
|
|
0
|
|
|
|
|
|
|
74
|
0
|
|
|
|
|
0
|
$dsn .= $self_or_class->dsn_socket_field($driver) . "=$socket"; |
|
75
|
|
|
|
|
|
|
} |
|
76
|
|
|
|
|
|
|
elsif (my $host = $db->host) { |
|
77
|
0
|
|
|
|
|
0
|
$dsn .= "host=$host;"; |
|
78
|
0
|
0
|
|
|
|
0
|
if (my $port = $db->port) { |
|
79
|
0
|
|
|
|
|
0
|
$dsn .= "port=$port;"; |
|
80
|
|
|
|
|
|
|
} |
|
81
|
|
|
|
|
|
|
} |
|
82
|
|
|
|
|
|
|
else { |
|
83
|
0
|
|
|
|
|
0
|
croak "Cannot construct dsn without a host or socket"; |
|
84
|
|
|
|
|
|
|
} |
|
85
|
|
|
|
|
|
|
|
|
86
|
0
|
|
|
|
|
0
|
return $dsn; |
|
87
|
|
|
|
|
|
|
} |
|
88
|
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
sub upsert_statement { |
|
90
|
2
|
|
|
2
|
0
|
6
|
my $self = shift; |
|
91
|
2
|
|
|
|
|
6
|
my ($pk) = @_; |
|
92
|
2
|
|
|
|
|
12
|
return "ON CONFLICT(" . join(", " => @$pk). ") DO UPDATE SET"; |
|
93
|
|
|
|
|
|
|
} |
|
94
|
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
############################################################################### |
|
96
|
|
|
|
|
|
|
# {{{ Schema Builder Code |
|
97
|
|
|
|
|
|
|
############################################################################### |
|
98
|
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
sub build_schema_from_db { |
|
100
|
22
|
|
|
22
|
0
|
551
|
my $self = shift; |
|
101
|
22
|
|
|
|
|
129
|
my %params = @_; |
|
102
|
|
|
|
|
|
|
|
|
103
|
22
|
50
|
|
|
|
109
|
croak "No autofill object provided" unless $params{autofill}; |
|
104
|
|
|
|
|
|
|
|
|
105
|
22
|
|
|
|
|
259
|
my $dbh = $self->dbh; |
|
106
|
|
|
|
|
|
|
|
|
107
|
22
|
|
|
|
|
188
|
my $tables = $self->build_tables_from_db(%params); |
|
108
|
|
|
|
|
|
|
|
|
109
|
22
|
|
|
|
|
247
|
$params{autofill}->hook(tables => $tables); |
|
110
|
|
|
|
|
|
|
|
|
111
|
|
|
|
|
|
|
return DBIx::QuickORM::Schema->new( |
|
112
|
|
|
|
|
|
|
tables => $tables, |
|
113
|
|
|
|
|
|
|
row_class => $params{row_class}, |
|
114
|
22
|
|
|
|
|
298
|
); |
|
115
|
|
|
|
|
|
|
} |
|
116
|
|
|
|
|
|
|
|
|
117
|
0
|
|
|
0
|
0
|
|
sub build_tables_from_db { confess "Not Implemented" } |
|
118
|
0
|
|
|
0
|
0
|
|
sub build_table_keys_from_db { confess "Not Implemented" } |
|
119
|
0
|
|
|
0
|
0
|
|
sub build_columns_from_db { confess "Not Implemented" } |
|
120
|
0
|
|
|
0
|
0
|
|
sub build_indexes_from_db { confess "Not Implemented" } |
|
121
|
|
|
|
|
|
|
|
|
122
|
|
|
|
|
|
|
############################################################################### |
|
123
|
|
|
|
|
|
|
# }}} Schema Builder Code |
|
124
|
|
|
|
|
|
|
############################################################################### |
|
125
|
|
|
|
|
|
|
|
|
126
|
|
|
|
|
|
|
############################################################################### |
|
127
|
|
|
|
|
|
|
# {{{ SQL Builder Code |
|
128
|
|
|
|
|
|
|
############################################################################### |
|
129
|
|
|
|
|
|
|
|
|
130
|
|
|
|
|
|
|
sub build_sql_from_schema { |
|
131
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
|
132
|
0
|
|
|
|
|
|
my ($schema, %params) = @_; |
|
133
|
|
|
|
|
|
|
|
|
134
|
0
|
|
|
|
|
|
my @sections; |
|
135
|
|
|
|
|
|
|
|
|
136
|
0
|
|
0
|
|
|
|
push @sections => @{$params{prefix} // []}; |
|
|
0
|
|
|
|
|
|
|
|
137
|
0
|
|
|
|
|
|
push @sections => $self->build_table_sql_from_schema(@_); |
|
138
|
0
|
|
0
|
|
|
|
push @sections => @{$params{postfix} // []}; |
|
|
0
|
|
|
|
|
|
|
|
139
|
|
|
|
|
|
|
|
|
140
|
0
|
|
|
|
|
|
return join "\n" => @sections; |
|
141
|
|
|
|
|
|
|
} |
|
142
|
|
|
|
|
|
|
|
|
143
|
0
|
|
|
0
|
0
|
|
sub build_table_sql_from_schema { confess "Not Implemented" } |
|
144
|
|
|
|
|
|
|
|
|
145
|
|
|
|
|
|
|
############################################################################### |
|
146
|
|
|
|
|
|
|
# }}} SQL Builder Code |
|
147
|
|
|
|
|
|
|
############################################################################### |
|
148
|
|
|
|
|
|
|
|
|
149
|
|
|
|
|
|
|
1; |