• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

letsdrink / ouzo / 6037036166

31 Aug 2023 11:53AM UTC coverage: 84.202% (-1.8%) from 86.01%
6037036166

push

github

web-flow
Add string space const (#318)

4877 of 5792 relevant lines covered (84.2%)

33.84 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

3.85
/src/Ouzo/Core/Db/Dialect/Sqlite3Dialect.php
1
<?php
2
/*
3
 * Copyright (c) Ouzo contributors, https://github.com/letsdrink/ouzo
4
 * This file is made available under the MIT License (view the LICENSE file for more information).
5
 */
6

7
namespace Ouzo\Db\Dialect;
8

9
use BadMethodCallException;
10
use InvalidArgumentException;
11
use Ouzo\Db\JoinClause;
12
use Ouzo\Db\OnConflict;
13
use Ouzo\Utilities\Arrays;
14
use Ouzo\Utilities\Strings;
15

16
class Sqlite3Dialect extends Dialect
17
{
18
    public function getConnectionErrorCodes(): array
19
    {
20
        return [10, 11, 14];
4✔
21
    }
22

23
    public function getErrorCode(array $errorInfo): mixed
24
    {
25
        return Arrays::getValue($errorInfo, 1);
4✔
26
    }
27

28
    public function update(): string
29
    {
30
        if ($this->query->aliasTable) {
14✔
31
            throw new InvalidArgumentException("Alias in update query is not supported in sqlite3");
1✔
32
        }
33
        return parent::update();
13✔
34
    }
35

36
    public function join(): string
37
    {
38
        $any = Arrays::any($this->query->joinClauses, function (JoinClause $joinClause) {
137✔
39
            return Strings::equalsIgnoreCase($joinClause->type, 'RIGHT');
28✔
40
        });
137✔
41
        if ($any) {
137✔
42
            throw new BadMethodCallException('RIGHT JOIN is not supported in sqlite3');
1✔
43
        }
44
        return parent::join();
136✔
45
    }
46

47
    public function lockForUpdate(): string
48
    {
49
        if ($this->query->lockForUpdate) {
133✔
50
            throw new BadMethodCallException('SELECT ... FOR UPDATE is not supported in sqlite3');
×
51
        }
52
        return '';
133✔
53
    }
54

55
    public function using(): string
56
    {
57
        if ($this->query->usingClauses) {
2✔
58
            throw new BadMethodCallException('USING clause is not supported in sqlite3');
×
59
        }
60
        return '';
2✔
61
    }
62

63
    public function batchInsert(string $table, string $primaryKey, $columns, $batchSize, ?OnConflict $onConflict): string
64
    {
65
        throw new InvalidArgumentException("Batch insert not supported in sqlite3");
×
66
    }
67

68
    protected function insertEmptyRow(): string
69
    {
70
        return "INSERT INTO {$this->query->table} DEFAULT VALUES";
2✔
71
    }
72

73
    public function regexpMatcher(): string
74
    {
75
        //needs package sqlite3-pcre to work correctly
76
        return 'REGEXP';
3✔
77
    }
78

79
    protected function quote(string $word): string
80
    {
81
        return "\"{$word}\"";
×
82
    }
83

84
    public function getIteratorOptions(): array
85
    {
86
        return [];
2✔
87
    }
88

89
    public function onConflictUpdate(): string
90
    {
91
        throw new BadMethodCallException('UPSERT is not supported in sqlite3');
×
92
    }
93

94
    public function onConflictDoNothing(): string
95
    {
96
        throw new BadMethodCallException('On conflict do nothing is not supported in sqlite3');
×
97
    }
98

99
    protected function getDistinctOnQuery(): string
100
    {
101
        throw new InvalidArgumentException("DISTINCT ON is not supported in sqlite3");
×
102
    }
103

104
    protected function wrapQueryWithDistinctCount(string $sql): string
105
    {
106
        throw new InvalidArgumentException("DISTINCT for COUNT is not supported in sqlite3");
×
107
    }
108
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc