Skip to content

Commit

Permalink
Merge pull request #793 from bcit-ci/feature/sqlite
Browse files Browse the repository at this point in the history
Feature/sqlite
  • Loading branch information
lonnieezell authored Sep 15, 2018
2 parents 3dd106a + 307bcd1 commit 5562caa
Show file tree
Hide file tree
Showing 19 changed files with 1,647 additions and 133 deletions.
1 change: 1 addition & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ dist: precise
env:
- DB=mysqli
- DB=postgres
- DB=sqlite

services:
- memcached
Expand Down
1 change: 1 addition & 0 deletions php_errors.log
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
[30-Jan-2018 23:57:36 America/Chicago] PHP Fatal error: Class 'z' not found in /Users/kilishan/WebSites/CodeIgniter4/tests/system/Validation/RulesTest.php on line 5
5 changes: 4 additions & 1 deletion phpunit.xml.dist
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,10 @@
</testsuite>
<testsuite name="system">
<directory>./tests/system</directory>
<!-- <exclude>./tests/system/Database/Live</exclude> -->
<exclude>./tests/system/Database</exclude>
</testsuite>
<testsuite name="database">
<directory>./tests/system/Database</directory>
</testsuite>
</testsuites>

Expand Down
25 changes: 25 additions & 0 deletions system/Database/BaseBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,21 @@ class BaseBuilder
*/
protected $binds = [];

/**
* Some databases, like SQLite, do not by default
* allow limiting of delete clauses.
*
* @var bool
*/
protected $canLimitDeletes = true;

/**
* Some databases do not by default
* allow limit update queries with WHERE.
* @var bool
*/
protected $canLimitWhereUpdates = true;

//--------------------------------------------------------------------

/**
Expand Down Expand Up @@ -1908,6 +1923,11 @@ public function update($set = null, $where = null, int $limit = null, $test = fa

if ( ! empty($limit))
{
if (! $this->canLimitWhereUpdates)
{
throw new DatabaseException('This driver does not allow LIMITs on UPDATE queries using WHERE.');
}

$this->limit($limit);
}

Expand Down Expand Up @@ -2292,6 +2312,11 @@ public function delete($where = '', $limit = null, $reset_data = true, $returnSQ

if ( ! empty($this->QBLimit))
{
if (! $this->canLimitDeletes)
{
throw new DatabaseException('SQLite3 does not allow LIMITs on DELETE queries.');
}

$sql = $this->_limit($sql);
}

Expand Down
Loading

0 comments on commit 5562caa

Please sign in to comment.