|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
declare(strict_types=1); |
|
4
|
|
|
|
|
5
|
|
|
namespace Yiisoft\Db\Tests\Provider; |
|
6
|
|
|
|
|
7
|
|
|
final class QuoterProvider |
|
8
|
|
|
{ |
|
9
|
|
|
/** |
|
10
|
|
|
* @return string[][] |
|
11
|
|
|
*/ |
|
12
|
|
|
public function columnName(): array |
|
13
|
|
|
{ |
|
14
|
|
|
return [ |
|
15
|
|
|
['*', '*'], |
|
16
|
|
|
['`*`', '`*`'], |
|
17
|
|
|
['[[*]]', '[[*]]'], |
|
18
|
|
|
['{{*}}', '{{*}}'], |
|
19
|
|
|
['table.column', '`table`.`column`'], |
|
20
|
|
|
['`table`.`column`', '`table`.`column`'], |
|
21
|
|
|
['[[table]].[[column]]', '[[table]].[[column]]'], |
|
22
|
|
|
['{{table}}.{{column}}', '{{column}}'], |
|
23
|
|
|
]; |
|
24
|
|
|
} |
|
25
|
|
|
|
|
26
|
|
|
/** |
|
27
|
|
|
* @return string[][] |
|
28
|
|
|
*/ |
|
29
|
|
|
public function ensureColumnName(): array |
|
30
|
|
|
{ |
|
31
|
|
|
return [ |
|
32
|
|
|
['*', '*'], |
|
33
|
|
|
['`*`', '`*`'], |
|
34
|
|
|
['[[*]]', '[[*]]'], |
|
35
|
|
|
['{{*}}', '{{*}}'], |
|
36
|
|
|
['table.column', 'column'], |
|
37
|
|
|
['`table`.`column`', '`column`'], |
|
38
|
|
|
['[[table]].[[column]]', 'column'], |
|
39
|
|
|
['{{table}}.{{column}}', '{{column}}'], |
|
40
|
|
|
]; |
|
41
|
|
|
} |
|
42
|
|
|
|
|
43
|
|
|
/** |
|
44
|
|
|
* @return string[][] |
|
45
|
|
|
*/ |
|
46
|
|
|
public function ensureNameQuoted(): array |
|
47
|
|
|
{ |
|
48
|
|
|
return [ |
|
49
|
|
|
['name', '{{name}}'], |
|
50
|
|
|
['`name`', '{{name}}'], |
|
51
|
|
|
['[[name]]', '{{name}}'], |
|
52
|
|
|
['{{name}}', '{{name}}'], |
|
53
|
|
|
['table.name', '{{table.name}}'], |
|
54
|
|
|
['`table`.`name`', '{{table.name}}'], |
|
55
|
|
|
['[[table]].[[name]]', '{{table.name}}'], |
|
56
|
|
|
['{{table}}.{{name}}', '{{table}}.{{name}}'], |
|
57
|
|
|
]; |
|
58
|
|
|
} |
|
59
|
|
|
|
|
60
|
|
|
/** |
|
61
|
|
|
* @return string[][] |
|
62
|
|
|
*/ |
|
63
|
|
|
public function simpleColumnName(): array |
|
64
|
|
|
{ |
|
65
|
|
|
return [ |
|
66
|
|
|
['*', '*'], |
|
67
|
|
|
['`*`', '`*`'], |
|
68
|
|
|
['[[*]]', '`[[*]]`'], |
|
69
|
|
|
['{{*}}', '`{{*}}`'], |
|
70
|
|
|
['table.column', '`table.column`'], |
|
71
|
|
|
['`table`.`column`', '`table`.`column`'], |
|
72
|
|
|
['[[table]].[[column]]', '`[[table]].[[column]]`'], |
|
73
|
|
|
['{{table}}.{{column}}', '`{{table}}.{{column}}`'], |
|
74
|
|
|
]; |
|
75
|
|
|
} |
|
76
|
|
|
|
|
77
|
|
|
/** |
|
78
|
|
|
* @return string[][] |
|
79
|
|
|
*/ |
|
80
|
|
|
public function simpleTableName(): array |
|
81
|
|
|
{ |
|
82
|
|
|
return [ |
|
83
|
|
|
['test', '`test`'], |
|
84
|
|
|
['`test`', '`test`'], |
|
85
|
|
|
['[[test]]', '`[[test]]`'], |
|
86
|
|
|
['{{test}}', '`{{test}}`'], |
|
87
|
|
|
['table.test', '`table.test`'], |
|
88
|
|
|
['`table`.`test`', '`table`.`test`'], |
|
89
|
|
|
['[[table]].[[test]]', '`[[table]].[[test]]`'], |
|
90
|
|
|
['{{table}}.{{test}}', '`{{table}}.{{test}}`'], |
|
91
|
|
|
]; |
|
92
|
|
|
} |
|
93
|
|
|
|
|
94
|
|
|
/** |
|
95
|
|
|
* @return string[][] |
|
96
|
|
|
*/ |
|
97
|
|
|
public function tableName(): array |
|
98
|
|
|
{ |
|
99
|
|
|
return [ |
|
100
|
|
|
['table', '`table`'], |
|
101
|
|
|
['`table`', '`table`'], |
|
102
|
|
|
['(table)', '(table)'], |
|
103
|
|
|
['[[test]]', '`[[test]]`'], |
|
104
|
|
|
['{{test}}', '{{test}}'], |
|
105
|
|
|
['table.column', '`table`.`column`'], |
|
106
|
|
|
['`table`.`column`', '`table`.`column`'], |
|
107
|
|
|
['[[table]].[[column]]', '`[[table]]`.`[[column]]`'], |
|
108
|
|
|
['{{table}}.{{column}}', '{{table}}.{{column}}'], |
|
109
|
|
|
]; |
|
110
|
|
|
} |
|
111
|
|
|
|
|
112
|
|
|
/** |
|
113
|
|
|
* @return string[][] |
|
114
|
|
|
*/ |
|
115
|
|
|
public function tableNameParts(): array |
|
116
|
|
|
{ |
|
117
|
|
|
return [ |
|
118
|
|
|
['schema.table', ['schema', 'table']], |
|
119
|
|
|
['`schema`.`table`', ['schema', 'table']], |
|
120
|
|
|
['`table`', ['table']], |
|
121
|
|
|
['table', ['table']], |
|
122
|
|
|
]; |
|
123
|
|
|
} |
|
124
|
|
|
|
|
125
|
|
|
/** |
|
126
|
|
|
* @return string[][] |
|
127
|
|
|
*/ |
|
128
|
|
|
public function unquoteSimpleColumnName(): array |
|
129
|
|
|
{ |
|
130
|
|
|
return [ |
|
131
|
|
|
['*', '*'], |
|
132
|
|
|
['`*`', '*'], |
|
133
|
|
|
['[[*]]', '[[*]]'], |
|
134
|
|
|
['{{*}}', '{{*}}'], |
|
135
|
|
|
['table.column', 'table.column'], |
|
136
|
|
|
['[[table]].[[column]]', '[[table]].[[column]]'], |
|
137
|
|
|
['{{table}}.{{column}}', '{{table}}.{{column}}'], |
|
138
|
|
|
]; |
|
139
|
|
|
} |
|
140
|
|
|
|
|
141
|
|
|
/** |
|
142
|
|
|
* @return string[][] |
|
143
|
|
|
*/ |
|
144
|
|
|
public function unquoteSimpleTableName(): array |
|
145
|
|
|
{ |
|
146
|
|
|
return [ |
|
147
|
|
|
['test', 'test'], |
|
148
|
|
|
['`test`', 'test'], |
|
149
|
|
|
['[[test]]', '[[test]]'], |
|
150
|
|
|
['{{test}}', '{{test}}'], |
|
151
|
|
|
['table.column', 'table.column'], |
|
152
|
|
|
['[[table.column]]', '[[table.column]]'], |
|
153
|
|
|
['{{table.column}}', '{{table.column}}'], |
|
154
|
|
|
]; |
|
155
|
|
|
} |
|
156
|
|
|
} |
|
157
|
|
|
|