|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
declare(strict_types=1); |
|
4
|
|
|
|
|
5
|
|
|
namespace Yiisoft\Db\Sqlite; |
|
6
|
|
|
|
|
7
|
|
|
use Yiisoft\Db\QueryBuilder\AbstractQueryBuilder; |
|
8
|
|
|
use Yiisoft\Db\Schema\QuoterInterface; |
|
9
|
|
|
use Yiisoft\Db\Schema\SchemaInterface; |
|
10
|
|
|
|
|
11
|
|
|
/** |
|
12
|
|
|
* Implements the SQLite Server specific query builder. |
|
13
|
|
|
*/ |
|
14
|
|
|
final class QueryBuilder extends AbstractQueryBuilder |
|
15
|
|
|
{ |
|
16
|
|
|
/** |
|
17
|
|
|
* @var string[] Mapping from abstract column types (keys) to physical column types (values). |
|
18
|
|
|
*/ |
|
19
|
|
|
protected array $typeMap = [ |
|
20
|
|
|
SchemaInterface::TYPE_PK => 'integer PRIMARY KEY AUTOINCREMENT NOT NULL', |
|
21
|
|
|
SchemaInterface::TYPE_UPK => 'integer PRIMARY KEY AUTOINCREMENT NOT NULL', |
|
22
|
|
|
SchemaInterface::TYPE_BIGPK => 'integer PRIMARY KEY AUTOINCREMENT NOT NULL', |
|
23
|
|
|
SchemaInterface::TYPE_UBIGPK => 'integer PRIMARY KEY AUTOINCREMENT NOT NULL', |
|
24
|
|
|
SchemaInterface::TYPE_CHAR => 'char(1)', |
|
25
|
|
|
SchemaInterface::TYPE_STRING => 'varchar(255)', |
|
26
|
|
|
SchemaInterface::TYPE_TEXT => 'text', |
|
27
|
|
|
SchemaInterface::TYPE_TINYINT => 'tinyint', |
|
28
|
|
|
SchemaInterface::TYPE_SMALLINT => 'smallint', |
|
29
|
|
|
SchemaInterface::TYPE_INTEGER => 'integer', |
|
30
|
|
|
SchemaInterface::TYPE_BIGINT => 'bigint', |
|
31
|
|
|
SchemaInterface::TYPE_FLOAT => 'float', |
|
32
|
|
|
SchemaInterface::TYPE_DOUBLE => 'double', |
|
33
|
|
|
SchemaInterface::TYPE_DECIMAL => 'decimal(10,0)', |
|
34
|
|
|
SchemaInterface::TYPE_DATETIME => 'datetime', |
|
35
|
|
|
SchemaInterface::TYPE_TIMESTAMP => 'timestamp', |
|
36
|
|
|
SchemaInterface::TYPE_TIME => 'time', |
|
37
|
|
|
SchemaInterface::TYPE_DATE => 'date', |
|
38
|
|
|
SchemaInterface::TYPE_BINARY => 'blob', |
|
39
|
|
|
SchemaInterface::TYPE_BOOLEAN => 'boolean', |
|
40
|
|
|
SchemaInterface::TYPE_MONEY => 'decimal(19,4)', |
|
41
|
|
|
SchemaInterface::TYPE_UUID => 'blob(16)', |
|
42
|
|
|
SchemaInterface::TYPE_UUID_PK => 'blob(16) PRIMARY KEY', |
|
43
|
|
|
SchemaInterface::TYPE_JSON => 'json', |
|
44
|
|
|
]; |
|
45
|
|
|
|
|
46
|
547 |
|
public function __construct(QuoterInterface $quoter, SchemaInterface $schema) |
|
47
|
|
|
{ |
|
48
|
547 |
|
$ddlBuilder = new DDLQueryBuilder($this, $quoter, $schema); |
|
49
|
547 |
|
$dmlBuilder = new DMLQueryBuilder($this, $quoter, $schema); |
|
50
|
547 |
|
$dqlBuilder = new DQLQueryBuilder($this, $quoter); |
|
51
|
547 |
|
parent::__construct($quoter, $schema, $ddlBuilder, $dmlBuilder, $dqlBuilder); |
|
52
|
|
|
} |
|
53
|
|
|
} |
|
54
|
|
|
|