|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
/** |
|
4
|
|
|
* Licensed to CRATE Technology GmbH("Crate") under one or more contributor |
|
5
|
|
|
* license agreements. See the NOTICE file distributed with this work for |
|
6
|
|
|
* additional information regarding copyright ownership. Crate licenses |
|
7
|
|
|
* this file to you under the Apache License, Version 2.0 (the "License"); |
|
8
|
|
|
* you may not use this file except in compliance with the License. You may |
|
9
|
|
|
* obtain a copy of the License at |
|
10
|
|
|
* |
|
11
|
|
|
* http://www.apache.org/licenses/LICENSE-2.0 |
|
12
|
|
|
* |
|
13
|
|
|
* Unless required by applicable law or agreed to in writing, software |
|
14
|
|
|
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT |
|
15
|
|
|
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the |
|
16
|
|
|
* License for the specific language governing permissions and limitations |
|
17
|
|
|
* under the License. |
|
18
|
|
|
* |
|
19
|
|
|
* However, if you have executed another commercial license agreement |
|
20
|
|
|
* with Crate these terms will supersede the license and you may use the |
|
21
|
|
|
* software solely pursuant to the terms of the relevant commercial agreement. |
|
22
|
|
|
*/ |
|
23
|
|
|
|
|
24
|
|
|
namespace Crate\DBAL\Driver\PDOCrate; |
|
25
|
|
|
|
|
26
|
|
|
use Crate\DBAL\Platforms\CratePlatform; |
|
27
|
|
|
use Crate\DBAL\Platforms\CratePlatform1; |
|
28
|
|
|
use Crate\DBAL\Platforms\CratePlatform4; |
|
29
|
|
|
use Crate\DBAL\Schema\CrateSchemaManager; |
|
30
|
|
|
use Doctrine\DBAL\Connection; |
|
31
|
|
|
use Doctrine\DBAL\Platforms\AbstractPlatform; |
|
32
|
|
|
use Doctrine\DBAL\Schema\AbstractSchemaManager; |
|
33
|
|
|
use SensitiveParameter; |
|
|
|
|
|
|
34
|
|
|
|
|
35
|
|
|
class Driver implements \Doctrine\DBAL\Driver |
|
36
|
|
|
{ |
|
37
|
|
|
public const VERSION = '4.0.3'; |
|
38
|
|
|
public const NAME = 'crate'; |
|
39
|
|
|
|
|
40
|
|
|
private const VERSION_057 = '0.57.0'; |
|
41
|
|
|
private const VERSION_4 = '4.0.0'; |
|
42
|
|
|
|
|
43
|
|
|
/** |
|
44
|
|
|
* {@inheritDoc} |
|
45
|
|
|
* @return PDOConnection The database connection. |
|
46
|
|
|
*/ |
|
47
|
12 |
|
public function connect( |
|
48
|
|
|
#[SensitiveParameter] |
|
49
|
|
|
array $params |
|
50
|
|
|
): PDOConnection { |
|
51
|
12 |
|
$username = $params['user'] ?? null; |
|
52
|
12 |
|
$password = $params['password'] ?? null; |
|
53
|
12 |
|
$driverOptions = $params['driver_options'] ?? []; |
|
54
|
12 |
|
return new PDOConnection($this->constructPdoDsn($params), $username, $password, $driverOptions); |
|
55
|
|
|
} |
|
56
|
|
|
|
|
57
|
|
|
/** |
|
58
|
|
|
* Constructs the Crate PDO DSN. |
|
59
|
|
|
* |
|
60
|
|
|
* @return string The DSN. |
|
61
|
|
|
*/ |
|
62
|
12 |
|
private function constructPdoDsn(array $params): string |
|
63
|
|
|
{ |
|
64
|
12 |
|
$dsn = self::NAME . ':'; |
|
65
|
12 |
|
if (isset($params['host']) && $params['host'] != '') { |
|
66
|
12 |
|
$dsn .= $params['host']; |
|
67
|
|
|
} else { |
|
68
|
|
|
$dsn .= 'localhost'; |
|
69
|
|
|
} |
|
70
|
12 |
|
$dsn .= ':' . (isset($params['port']) ? $params['port'] : '4200'); |
|
71
|
|
|
|
|
72
|
12 |
|
return $dsn; |
|
73
|
|
|
} |
|
74
|
|
|
|
|
75
|
|
|
/** |
|
76
|
|
|
* {@inheritDoc} |
|
77
|
|
|
*/ |
|
78
|
6 |
|
public function getDatabasePlatform(): AbstractPlatform |
|
79
|
|
|
{ |
|
80
|
6 |
|
return new CratePlatform4(); |
|
81
|
|
|
} |
|
82
|
|
|
|
|
83
|
|
|
/** |
|
84
|
|
|
* {@inheritDoc} |
|
85
|
|
|
*/ |
|
86
|
96 |
|
public function getSchemaManager(Connection $conn, AbstractPlatform $platform): AbstractSchemaManager |
|
87
|
|
|
{ |
|
88
|
|
|
// Added by Doctrine 3. |
|
89
|
96 |
|
return new CrateSchemaManager($conn, $platform); |
|
90
|
|
|
} |
|
91
|
|
|
|
|
92
|
|
|
/** |
|
93
|
|
|
* {@inheritDoc} |
|
94
|
|
|
*/ |
|
95
|
|
|
public function getName(): string |
|
96
|
|
|
{ |
|
97
|
|
|
return self::NAME; |
|
98
|
|
|
} |
|
99
|
|
|
|
|
100
|
|
|
/** |
|
101
|
|
|
* {@inheritDoc} |
|
102
|
|
|
*/ |
|
103
|
|
|
public function getDatabase(Connection $conn): string|null |
|
|
|
|
|
|
104
|
|
|
{ |
|
105
|
|
|
return null; |
|
106
|
|
|
} |
|
107
|
|
|
|
|
108
|
|
|
/** |
|
109
|
|
|
* {@inheritDoc} |
|
110
|
|
|
*/ |
|
111
|
238 |
|
public function createDatabasePlatformForVersion($version): AbstractPlatform |
|
112
|
|
|
{ |
|
113
|
238 |
|
if (version_compare($version, self::VERSION_057, "<")) { |
|
114
|
2 |
|
return new CratePlatform(); |
|
115
|
236 |
|
} elseif (version_compare($version, self::VERSION_4, "<")) { |
|
116
|
2 |
|
return new CratePlatform1(); |
|
117
|
|
|
} else { |
|
118
|
234 |
|
return new CratePlatform4(); |
|
119
|
|
|
} |
|
120
|
|
|
} |
|
121
|
|
|
|
|
122
|
|
|
/** |
|
123
|
|
|
* {@inheritDoc} |
|
124
|
|
|
*/ |
|
125
|
2 |
|
public function getExceptionConverter(): ExceptionConverter |
|
126
|
|
|
{ |
|
127
|
|
|
// Added by Doctrine 3. |
|
128
|
2 |
|
return new ExceptionConverter(); |
|
129
|
|
|
} |
|
130
|
|
|
} |
|
131
|
|
|
|
The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g.
excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths