forked from doctrine/dbal
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request doctrine#2266 from ismailbaskin/master
[MySQL] Add platform for version >=5.7.8 with native JSON type support
- Loading branch information
Showing
8 changed files
with
186 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
<?php | ||
/* | ||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS | ||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT | ||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR | ||
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT | ||
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, | ||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT | ||
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | ||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | ||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | ||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | ||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
* | ||
* This software consists of voluntary contributions made by many individuals | ||
* and is licensed under the MIT license. For more information, see | ||
* <http://www.doctrine-project.org>. | ||
*/ | ||
|
||
namespace Doctrine\DBAL\Platforms\Keywords; | ||
|
||
/** | ||
* MySQL 5.7.8 reserved keywords list. | ||
* | ||
* @author Steve Müller <st.mueller@dzh-online.de> | ||
* @link www.doctrine-project.org | ||
* @since 2.6 | ||
*/ | ||
class MySQL578Keywords extends MySQL57Keywords | ||
{ | ||
/** | ||
* {@inheritdoc} | ||
*/ | ||
public function getName() | ||
{ | ||
return 'MySQL578'; | ||
} | ||
|
||
/** | ||
* {@inheritdoc} | ||
*/ | ||
protected function getKeywords() | ||
{ | ||
return array_merge( | ||
array_diff( | ||
parent::getKeywords(), | ||
array('NONBLOCKING') | ||
), | ||
array( | ||
'GENERATED', | ||
'OPTIMIZER_COSTS', | ||
'STORED', | ||
'VIRTUAL' | ||
) | ||
); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
<?php | ||
/* | ||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS | ||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT | ||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR | ||
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT | ||
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, | ||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT | ||
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | ||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | ||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | ||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | ||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
* | ||
* This software consists of voluntary contributions made by many individuals | ||
* and is licensed under the MIT license. For more information, see | ||
* <http://www.doctrine-project.org>. | ||
*/ | ||
|
||
namespace Doctrine\DBAL\Platforms; | ||
|
||
/** | ||
* Provides the behavior, features and SQL dialect of the MySQL >=5.7.8 database platform. | ||
* Extends for json support >=5.7.8 version | ||
* | ||
* @author İsmail BASKIN <ismailbaskin1@gmail.com> | ||
* @link www.doctrine-project.org | ||
* @since 2.6 | ||
*/ | ||
class MySQL578Platform extends MySQL57Platform | ||
{ | ||
/** | ||
* {@inheritdoc} | ||
*/ | ||
protected function getReservedKeywordsClass() | ||
{ | ||
return 'Doctrine\DBAL\Platforms\Keywords\MySQL578Keywords'; | ||
} | ||
|
||
/** | ||
* {@inheritdoc} | ||
*/ | ||
protected function initializeDoctrineTypeMappings() | ||
{ | ||
parent::initializeDoctrineTypeMappings(); | ||
|
||
$this->doctrineTypeMapping['json'] = 'json_array'; | ||
} | ||
|
||
/** | ||
* {@inheritdoc} | ||
*/ | ||
public function hasNativeJsonType() | ||
{ | ||
return true; | ||
} | ||
|
||
/** | ||
* {@inheritdoc} | ||
*/ | ||
public function getJsonTypeDeclarationSQL(array $field) | ||
{ | ||
return 'JSON'; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
52 changes: 52 additions & 0 deletions
52
tests/Doctrine/Tests/DBAL/Platforms/MySQL578PlatformTest.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
<?php | ||
|
||
namespace Doctrine\Tests\DBAL\Platforms; | ||
|
||
use Doctrine\DBAL\Platforms\MySQL578Platform; | ||
|
||
class MySQL578PlatformTest extends MySQL57PlatformTest | ||
{ | ||
/** | ||
* {@inheritdoc} | ||
*/ | ||
public function createPlatform() | ||
{ | ||
return new MySQL578Platform(); | ||
} | ||
|
||
/** | ||
* @group DBAL-2266 | ||
*/ | ||
public function testHasNativeJsonType() | ||
{ | ||
$this->assertTrue($this->_platform->hasNativeJsonType()); | ||
} | ||
|
||
/** | ||
* @group DBAL-2266 | ||
*/ | ||
public function testReturnsJsonTypeDeclarationSQL() | ||
{ | ||
$this->assertSame('JSON', $this->_platform->getJsonTypeDeclarationSQL(array())); | ||
} | ||
|
||
/** | ||
* @group DBAL-2266 | ||
*/ | ||
public function testInitializesJsonTypeMapping() | ||
{ | ||
$this->assertTrue($this->_platform->hasDoctrineTypeMappingFor('json')); | ||
$this->assertEquals('json_array', $this->_platform->getDoctrineTypeMapping('json')); | ||
} | ||
|
||
/** | ||
* @group DBAL-2266 | ||
*/ | ||
public function testReturnsReservedKeywordsClass() | ||
{ | ||
$this->assertInstanceOf( | ||
'Doctrine\DBAL\Platforms\Keywords\MySQL578Keywords', | ||
$this->_platform->getReservedKeywordsList() | ||
); | ||
} | ||
} |