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
|
|
|
['test', '[test]'], |
16
|
|
|
['[test]', '[test]'], |
17
|
|
|
['*', '*'], |
18
|
|
|
]; |
19
|
|
|
} |
20
|
|
|
|
21
|
|
|
/** |
22
|
|
|
* @return string[][] |
23
|
|
|
*/ |
24
|
|
|
public function simpleTableName(): array |
25
|
|
|
{ |
26
|
|
|
return [ |
27
|
|
|
['test', '[test]', ], |
28
|
|
|
['te`st', '[te`st]', ], |
29
|
|
|
['te\'st', '[te\'st]', ], |
30
|
|
|
['te"st', '[te"st]', ], |
31
|
|
|
['current-table-name', '[current-table-name]'], |
32
|
|
|
['[current-table-name]', '[current-table-name]'], |
33
|
|
|
]; |
34
|
|
|
} |
35
|
|
|
|
36
|
|
|
/** |
37
|
|
|
* @return string[][] |
38
|
|
|
*/ |
39
|
|
|
public function tableName(): array |
40
|
|
|
{ |
41
|
|
|
return [ |
42
|
|
|
['test', '[test]'], |
43
|
|
|
['test.test', '[test].[test]'], |
44
|
|
|
['[test]', '[test]'], |
45
|
|
|
['[test].[test]', '[test].[test]'], |
46
|
|
|
]; |
47
|
|
|
} |
48
|
|
|
|
49
|
|
|
/** |
50
|
|
|
* @return string[][] |
51
|
|
|
*/ |
52
|
|
|
public function tableNameParts(): array |
53
|
|
|
{ |
54
|
|
|
return [ |
55
|
|
|
['animal', 'animal',], |
56
|
|
|
['dbo.animal', 'animal', 'dbo'], |
57
|
|
|
['[dbo].[animal]', 'animal', 'dbo'], |
58
|
|
|
['[other].[animal2]', 'animal2', 'other'], |
59
|
|
|
['other.[animal2]', 'animal2', 'other'], |
60
|
|
|
['other.animal2', 'animal2', 'other'], |
61
|
|
|
]; |
62
|
|
|
} |
63
|
|
|
|
64
|
|
|
/** |
65
|
|
|
* @return string[][] |
66
|
|
|
*/ |
67
|
|
|
public function unquoteSimpleColumnName(): array |
68
|
|
|
{ |
69
|
|
|
return [ |
70
|
|
|
['test', 'test'], |
71
|
|
|
['[test]', 'test'], |
72
|
|
|
['*', '*'], |
73
|
|
|
]; |
74
|
|
|
} |
75
|
|
|
|
76
|
|
|
/** |
77
|
|
|
* @return string[][] |
78
|
|
|
*/ |
79
|
|
|
public function unquoteSimpleTableName(): array |
80
|
|
|
{ |
81
|
|
|
return [ |
82
|
|
|
['[test]', 'test'], |
83
|
|
|
['[te`st]', 'te`st'], |
84
|
|
|
['[te\'st]', 'te\'st'], |
85
|
|
|
['[te"st]', 'te"st'], |
86
|
|
|
['[current-table-name]', 'current-table-name'], |
87
|
|
|
['[current-table-name]', 'current-table-name'], |
88
|
|
|
]; |
89
|
|
|
} |
90
|
|
|
} |
91
|
|
|
|