-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add native JSON type support for MySQL >=5.7.8 #2266
Changes from 2 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
<?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 <[email protected]> | ||
* @link www.doctrine-project.org | ||
* @since 2.5 | ||
*/ | ||
class MySQL578Platform extends MySQL57Platform | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If we introduce a new platform, we also need to introduce a new reserved keywords class. See New reserved keywords
Removed reserved keywords
The new keywords class can simply extend Please also update the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
{ | ||
/** | ||
* {@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'; | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
<?php | ||
|
||
namespace Doctrine\Tests\DBAL\Platforms; | ||
|
||
use Doctrine\DBAL\Platforms\MySQL578Platform; | ||
|
||
class MySQL578PlatformTest extends MySQL57PlatformTest | ||
{ | ||
/** | ||
* {@inheritdoc} | ||
*/ | ||
public function createPlatform() | ||
{ | ||
return new MySQL578Platform(); | ||
} | ||
|
||
/** | ||
* @group DBAL-553 | ||
*/ | ||
public function testHasNativeJsonType() | ||
{ | ||
$this->assertTrue($this->_platform->hasNativeJsonType()); | ||
} | ||
|
||
/** | ||
* @group DBAL-553 | ||
*/ | ||
public function testReturnsJsonTypeDeclarationSQL() | ||
{ | ||
$this->assertSame('JSON', $this->_platform->getJsonTypeDeclarationSQL(array())); | ||
} | ||
|
||
/** | ||
* @group DBAL-553 | ||
*/ | ||
public function testInitializesJsonTypeMapping() | ||
{ | ||
$this->assertTrue($this->_platform->hasDoctrineTypeMappingFor('json')); | ||
$this->assertEquals('json_array', $this->_platform->getDoctrineTypeMapping('json')); | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@since 2.6
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
https://github.com/ismailbaskin/dbal/commit/aa594405c4aa79f4237ebbb03a16901fcc12e114