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

Add binary, set and other missing data types to typeMap list in Mysql Schema #19705

Closed
SOHELAHMED7 opened this issue Dec 6, 2022 · 10 comments
Closed
Milestone

Comments

@SOHELAHMED7
Copy link
Contributor

SOHELAHMED7 commented Dec 6, 2022

As binary is the real data type in Mysql, it would be more perfect to add it to $typeMap list of \yii\db\mysql\Schema::class

My proposal:

        'enum' => self::TYPE_STRING,
        'varbinary' => self::TYPE_BINARY,
+       'binary' => self::TYPE_BINARY,
        'json' => self::TYPE_JSON,

List of missing data types

  • set
  • binary
  • bool
  • boolean
  • dec
  • fixed
  • double precision
  • GEOMETRY
  • point
  • LINESTRING
  • POLYGON
  • MULTIPOINT
  • MULTILINESTRING
  • MULTIPOLYGON
  • GEOMETRYCOLLECTION

For set

#19705 (comment)


Loosely related to #18409

@samdark
Copy link
Member

samdark commented Dec 6, 2022

Sounds alright. Would you please do a pull requests so we have a test runs to verify it doesn't break anything covered?

@SOHELAHMED7
Copy link
Contributor Author

This issue also stands for set data type in Mysql. Though its corresponding PHP side should be array I think. So possibly implementation for 'set' in Yii should be more work than just adding it to $typeMap list

@SOHELAHMED7 SOHELAHMED7 changed the title Add binary data type to typeMap list in Mysql Schema Add binary and set data type to typeMap list in Mysql Schema Dec 6, 2022
@SOHELAHMED7
Copy link
Contributor Author

There are also other data type missing. I will put that in main issue description.

@SOHELAHMED7 SOHELAHMED7 changed the title Add binary and set data type to typeMap list in Mysql Schema Add binary, set and other missing data types to typeMap list in Mysql Schema Dec 7, 2022
@SOHELAHMED7
Copy link
Contributor Author

What should be corresponding abstract data type for spatial data type such as geometry, point etc?

@bizley
Copy link
Member

bizley commented Dec 7, 2022

I think we should not add spatial types.

@samdark
Copy link
Member

samdark commented Dec 7, 2022

We should not add too specific types since the whole idea of DB/AR was to have a commong ground between MySQL, PostgreSQL etc.

@SOHELAHMED7
Copy link
Contributor Author

string is not real DB type in MySQL but it is still present ('string' => self::TYPE_STRING,) in yii\db\mysql\Schema::$typeMap. I am curious to know reason behind it.

@rob006
Copy link
Contributor

rob006 commented Dec 28, 2022

List of missing data types

Most of these non-spatial types are only aliases that can be used while creating/altering column, they're not real MySQL types.

@SOHELAHMED7
Copy link
Contributor Author

The purpose of adding these data type is that I am building a library on the top of Yii 2. In that lib I allow lib user to put a real DB type. And to validate it I use \yii\db\mysql\Schema::$typeMap

SOHELAHMED7 added a commit to SOHELAHMED7/yii2 that referenced this issue Feb 9, 2023
@samdark samdark closed this as completed Feb 9, 2023
@samdark samdark added this to the 2.0.48 milestone Feb 9, 2023
@ilyaplot
Copy link

ilyaplot commented May 3, 2023

@SOHELAHMED7 you may use uppercase. For example: $this->addColumn('table', 'column', 'BINARY(16)');
Yii2 uses case sensitive mapping.

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

No branches or pull requests

5 participants