Skip to content
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

JSON column type not supported #175

Closed
kg-bot opened this issue Sep 12, 2017 · 6 comments
Closed

JSON column type not supported #175

kg-bot opened this issue Sep 12, 2017 · 6 comments

Comments

@kg-bot
Copy link

kg-bot commented Sep 12, 2017

When we create table and add new columns, only timestamp and soft delete and try to save table it gives as error

Doctrine\DBAL\DBALException: Unknown database type json requested, Doctrine\DBAL\Platforms\MySQL57Platform may not support it. in /var/www/html/test-october-composer/vendor/doctrine/dbal/lib/Doctrine/DBAL/Platforms/AbstractPlatform.php:423

Followed this trace and discovered that this happens because of those lines

$this->_platform->doctrineTypeMapping = array[31]
			$this->_platform->doctrineTypeMapping['tinyint'] = (string) boolean
			$this->_platform->doctrineTypeMapping['smallint'] = (string) smallint
			$this->_platform->doctrineTypeMapping['mediumint'] = (string) integer
			$this->_platform->doctrineTypeMapping['int'] = (string) integer
			$this->_platform->doctrineTypeMapping['integer'] = (string) integer
			$this->_platform->doctrineTypeMapping['bigint'] = (string) bigint
			$this->_platform->doctrineTypeMapping['tinytext'] = (string) text
			$this->_platform->doctrineTypeMapping['mediumtext'] = (string) text
			$this->_platform->doctrineTypeMapping['longtext'] = (string) text
			$this->_platform->doctrineTypeMapping['text'] = (string) text
			$this->_platform->doctrineTypeMapping['varchar'] = (string) string
			$this->_platform->doctrineTypeMapping['string'] = (string) string
			$this->_platform->doctrineTypeMapping['char'] = (string) string
			$this->_platform->doctrineTypeMapping['date'] = (string) date
			$this->_platform->doctrineTypeMapping['datetime'] = (string) datetime
			$this->_platform->doctrineTypeMapping['timestamp'] = (string) datetime
			$this->_platform->doctrineTypeMapping['time'] = (string) time
			$this->_platform->doctrineTypeMapping['float'] = (string) float
			$this->_platform->doctrineTypeMapping['double'] = (string) float
			$this->_platform->doctrineTypeMapping['real'] = (string) float
			$this->_platform->doctrineTypeMapping['decimal'] = (string) decimal
			$this->_platform->doctrineTypeMapping['numeric'] = (string) decimal
			$this->_platform->doctrineTypeMapping['year'] = (string) date
			$this->_platform->doctrineTypeMapping['longblob'] = (string) blob
			$this->_platform->doctrineTypeMapping['blob'] = (string) blob
			$this->_platform->doctrineTypeMapping['mediumblob'] = (string) blob
			$this->_platform->doctrineTypeMapping['tinyblob'] = (string) blob
			$this->_platform->doctrineTypeMapping['binary'] = (string) binary
			$this->_platform->doctrineTypeMapping['varbinary'] = (string) binary
			$this->_platform->doctrineTypeMapping['set'] = (string) simple_array
			$this->_platform->doctrineTypeMapping['enum'] = (string) enumdbtype

This can be fixed if you do same as you did for enum inside this method

protected static function getSchemaManager()
    {
        if (!self::$schemaManager) {
            self::$schemaManager = Schema::getConnection()->getDoctrineSchemaManager();

            Type::addType('enumdbtype', 'RainLab\Builder\Classes\EnumDbType');

            // Fixes the problem with enum column type not supported
            // by Doctrine (https://github.com/laravel/framework/issues/1346)
            $platform = self::$schemaManager->getDatabasePlatform();
            $platform->registerDoctrineTypeMapping('enum', 'enumdbtype');
        }

        return self::$schemaManager;
    }

If you add $platform->registerDoctrineTypeMapping('json', 'text'); it works as expected.

@LukeTowers
Copy link
Contributor

This should have been fixed in Doctrine in doctrine/dbal#2653.

@LukeTowers
Copy link
Contributor

After further research it was fixed in doctrine/dbal#2653, however that fix was merged into 2.6 while October loads 2.5.

@kg-bot
Copy link
Author

kg-bot commented Sep 12, 2017

Should update October dependencies with Doctrine 2.6 which is not going to be easy I tried but a lot of other dependencies depend on doctrine 2.5.

@LukeTowers
Copy link
Contributor

This has been fixed in octobercms/library#278

@daftspunk daftspunk reopened this Oct 13, 2017
@daftspunk
Copy link
Member

Rollback doctrine to 2.5 and go with the OP suggestion

 $platform->registerDoctrineTypeMapping('json', 'text');

@LukeTowers
Copy link
Contributor

Fixed by 0320a13

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants