Skip to content

Commit

Permalink
Merge pull request doctrine#233 from lcobucci/improve-sqlite3
Browse files Browse the repository at this point in the history
Improve SQLite3 adapter
  • Loading branch information
Ocramius authored Aug 25, 2017
2 parents 2121298 + b39fab7 commit 5a5e00b
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 10 deletions.
23 changes: 14 additions & 9 deletions lib/Doctrine/Common/Cache/SQLite3Cache.php
Original file line number Diff line number Diff line change
Expand Up @@ -70,15 +70,20 @@ public function __construct(SQLite3 $sqlite, $table)
$this->sqlite = $sqlite;
$this->table = (string) $table;

list($id, $data, $exp) = $this->getFields();

return $this->sqlite->exec(sprintf(
'CREATE TABLE IF NOT EXISTS %s(%s TEXT PRIMARY KEY NOT NULL, %s BLOB, %s INTEGER)',
$table,
$id,
$data,
$exp
));
$this->ensureTableExists();
}

private function ensureTableExists() : void
{
$this->sqlite->exec(
sprintf(
'CREATE TABLE IF NOT EXISTS %s(%s TEXT PRIMARY KEY NOT NULL, %s BLOB, %s INTEGER)',
$this->table,
static::ID_FIELD,
static::DATA_FIELD,
static::EXPIRATION_FIELD
)
);
}

/**
Expand Down
2 changes: 1 addition & 1 deletion tests/Doctrine/Tests/Common/Cache/SQLite3CacheTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
use SQLite3;

/**
* @requires extension sqlite3
* @requires extension sqlite3 >= 3
*/
class SQLite3CacheTest extends CacheTest
{
Expand Down

0 comments on commit 5a5e00b

Please sign in to comment.