Skip to content

Error in migration createTable (and possible other) method when DB data type has more than one word #19759

Closed
@SOHELAHMED7

Description

@SOHELAHMED7

double precision is the SQL data type. It has two words.

Consider method \yii\db\migration::createTable()

What steps will reproduce the problem?

$this->createTable('{{%fruits}}', [
            'dp' => 'double precision NULL DEFAULT null',

What is the expected result?

This should create table in DB successfully.

What do you get instead?

I get SQL error: Part of SQL created was

dp double precision precision NULL DEFAULT null

'double precision precision' creates SQL syntax error.

Solution

2 Possibilities

  • implement solution to this error
  • change the docs for createTable() method and similar methods as mentioned below:
* where name stands for a column name which will be properly quoted by the method, and definition
-      * stands for the column type which can contain an abstract DB type.
+      * stands for the column type which must contain an abstract DB type. 

Additional info

Q A
Yii version 2.0.*
PHP version
Operating system

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions