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

MySql CreateTable and DateTimeOffset improvements #2044

Merged
merged 1 commit into from Jan 25, 2020
Merged

Conversation

MaceWindu
Copy link
Contributor

Fix #1206, fix #2020

This PR address issues with CreateTable API for MySQL by adding support for most of MySQL types.
Also fixes TIMESPAN values read into DateTimeOffset for MySqlConnector provider (MySql.Data provider is broken heavily here, will look into it on request)

Changes:

  • DataType.VarChar/DataType.NVarChar generate VARCHAR type. Was: Char
  • Guid generates CHAR(36) type. Was: Guid (invalid type name).
  • DataType.Binary/VarBinary default length set to 255. Was: Binary, VarBinary (invalid type name)
  • DataType.Blob/Text/NText generate corresponding subtypes based on length: TINY-/MEDIUM-/LONG- BLOB/TEXT.
  • DataType.DateTime/DateTime2/SmallDateTime generates fractional seconds if precision specified. Was: no fractional size (=0)
  • DataType.DateTimeOffset generates TIMESPAN type. Fractional seconds generated if precision specified. Was: DateTimeOffset (invalid type name)
  • DataType.Time properly generates fractional seconds if precision specified. Was: TIME(x, ) (invalid type name due to extra comma)
  • DataType.Byte generates TINYINT UNSIGNED type. Was: TINYINT
  • DataType.Uint16 generates SMALLINT UNSIGNED type. Was: INT
  • DataType.Uint32 generates INT UNSIGNED type. Was: BIGINT
  • DataType.Uint64 generates BIGINT UNSIGNED type. Was: DECIMAL
  • DataType.Decimal generates proper precision and scale values. WAS: generated incorrect type if only precision or scale specified
  • DataType.Single/Double generates proper Float/Double type names, including Float(precision). WAS: DECIMAL(29,10)
  • Data.Type.BitArray generates BIT/BIT(N) type. Was: incorrect type name BitArray/BitArray(N)
  • Fixed DateTimeOffset values read for MySqlConnector provider to read values with proper offset

@MaceWindu MaceWindu added this to the 2.9.6 milestone Jan 19, 2020
@MaceWindu
Copy link
Contributor Author

SQL from testcase:

CREATE TABLE `CreateTable`
(
	`VarChar255`       VARCHAR(255)          NULL,
	`VarChar1`         VARCHAR(1)            NULL,
	`VarChar112`       VARCHAR(112)          NULL,
	`Char`             CHAR              NOT NULL,
	`Char255`          CHAR(255)             NULL,
	`Char1`            CHAR                  NULL,
	`Char112`          CHAR(112)             NULL,
	`VarBinary1`       VARBINARY(1)          NULL,
	`VarBinary255`     VARBINARY(255)        NULL,
	`VarBinary3`       VARBINARY(3)          NULL,
	`Binary1`          BINARY                NULL,
	`Binary255`        BINARY(255)           NULL,
	`Binary3`          BINARY(3)             NULL,
	`TinyBlob`         TINYBLOB              NULL,
	`Blob`             BLOB                  NULL,
	`MediumBlob`       MEDIUMBLOB            NULL,
	`BlobDefault`      BLOB                  NULL,
	`LongBlob`         LONGBLOB              NULL,
	`TinyText`         TINYTEXT              NULL,
	`Text`             TEXT                  NULL,
	`MediumText`       MEDIUMTEXT            NULL,
	`LongText`         LONGTEXT              NULL,
	`TextDefault`      TEXT                  NULL,
	`Date`             DATE              NOT NULL,
	`DateTime`         DATETIME          NOT NULL,
	`DateTime3`        DATETIME(3)       NOT NULL,
	`TimeStamp`        TIMESTAMP         NOT NULL,
	`TimeStamp5`       TIMESTAMP(5)      NOT NULL,
	`Time`             TIME              NOT NULL,
	`Time2`            TIME(2)           NOT NULL,
	`TinyInt`          TINYINT           NOT NULL,
	`UnsignedTinyInt`  TINYINT UNSIGNED  NOT NULL,
	`SmallInt`         SMALLINT          NOT NULL,
	`UnsignedSmallInt` SMALLINT UNSIGNED NOT NULL,
	`Int`              INT               NOT NULL,
	`UnsignedInt`      INT UNSIGNED      NOT NULL,
	`BigInt`           BIGINT            NOT NULL,
	`UnsignedBigInt`   BIGINT UNSIGNED   NOT NULL,
	`Decimal`          DECIMAL           NOT NULL,
	`Decimal15_0`      DECIMAL(15)       NOT NULL,
	`Decimal10_5`      DECIMAL(10,5)     NOT NULL,
	`Decimal20_2`      DECIMAL(20,2)     NOT NULL,
	`Float`            FLOAT             NOT NULL,
	`Float10`          FLOAT(10)         NOT NULL,
	`Double`           DOUBLE            NOT NULL,
	`Float30`          FLOAT(30)         NOT NULL,
	`Bool`             BOOLEAN           NOT NULL,
	`Bit1`             BIT               NOT NULL,
	`Bit8`             BIT(8)            NOT NULL,
	`Bit16`            BIT(16)           NOT NULL,
	`Bit32`            BIT(32)           NOT NULL,
	`Bit10`            BIT(10)           NOT NULL,
	`Bit64`            BIT(64)           NOT NULL,
	`Json`             JSON                  NULL,
	`Guid`             CHAR(36)          NOT NULL
)

@MaceWindu
Copy link
Contributor Author

travis fails due to old mysql version, will disable mysql testing on ci before release from master. doesn't makes sense to fix as we ditching travis soon anyway and it it fixed in v3 already.

@MaceWindu MaceWindu merged commit 2737b3c into master Jan 25, 2020
@MaceWindu MaceWindu deleted the issue_2020 branch January 25, 2020 11:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

MySQL CreateTable DataType varchar to char issue MySQL and DateTimeOffset
2 participants