Skip to content

Commit

Permalink
v1.0 (PR#8)
Browse files Browse the repository at this point in the history
  • Loading branch information
kristuff authored Jun 13, 2021
2 parents d23fa0c + a140437 commit e3719c0
Show file tree
Hide file tree
Showing 6 changed files with 18 additions and 6 deletions.
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ All notable changes to this project will be documented in this file.

### Changed
- **Possible break change** PHP Strict types.
- New `DatabaseDriver::isForeignKeyEnabled()` method (`bool`) added for compatibility (implemented on sqlite, return false by other drivers).
- New `DatabaseDriver::isForeignKeyEnabled()` method (`bool`) added for compatibility (implemented on sqlite, returns true by other drivers as there is now way to disable FK).

## [v0.5] - 2020-10-08

Expand Down
6 changes: 3 additions & 3 deletions lib/Driver/Mysql/MysqlDriver.php
Original file line number Diff line number Diff line change
Expand Up @@ -137,14 +137,14 @@ public function disableForeignKeys(): void

/**
* Get whether foreign keys are enabled or not
* For compatibility with Sqlite, not implemented in that driver, return false
* For compatibility with Sqlite, not implemented in that driver (allways enabled), return true
*
* @access public
* @return bool true if foreign keys are enabled, otherwise false
*/
public function isForeignKeyEnabled(): bool
{
return false;
return true;
}

/**
Expand Down
4 changes: 2 additions & 2 deletions lib/Driver/Postgres/PostgresDriver.php
Original file line number Diff line number Diff line change
Expand Up @@ -157,14 +157,14 @@ public function disableForeignKeys(): void

/**
* Get whether foreign keys are enabled or not
* For compatibility with Sqlite, not implemented in that driver, return false
* For compatibility with Sqlite, not implemented in that driver (allways enabled), return true
* @access public
* @return bool true if foreign keys are enabled, otherwise false
*/
public function isForeignKeyEnabled(): bool
{
return false;
return true;
}

/**
Expand Down
6 changes: 6 additions & 0 deletions tests/mysql/MysqlDriverTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,12 @@ public function testMissingRequiredParameter()
new Kristuff\Patabase\Driver\Mysql\MysqlDriver(array());
}


public function testIsFkEnabled()
{
$this->assertTrue(self::$srv->getDriver()->isForeignKeyEnabled());
}

public function testEscape()
{
$this->assertEquals('`a`', self::$srv->getDriver()->escape('a'));
Expand Down
5 changes: 5 additions & 0 deletions tests/pgsql/PgsqlDriverTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,11 @@ public function testMissingRequiredParameter()
new Kristuff\Patabase\Driver\Mysql\MysqlDriver(array());
}

public function testIsFkEnabled()
{
$this->assertTrue(self::$srv->getDriver()->isForeignKeyEnabled());
}

public function testEscape()
{
$this->assertEquals('"a"', self::$srv->getDriver()->escape('a'));
Expand Down
1 change: 1 addition & 0 deletions tests/sqlite/SqliteDriverTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ public function testMissingRequiredParameter()
new Kristuff\Patabase\Driver\Sqlite\SqliteDriver(array());
}


public function testEscape()
{
$this->assertEquals('"a"', self::$db->getDriver()->escape('a'));
Expand Down

0 comments on commit e3719c0

Please sign in to comment.