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 should support more data types. #923

Closed
cvictory opened this issue Jun 7, 2021 · 0 comments · Fixed by #926
Closed

Mysql should support more data types. #923

cvictory opened this issue Jun 7, 2021 · 0 comments · Fixed by #926
Assignees
Labels
kind/bug Something isn't working
Milestone

Comments

@cvictory
Copy link
Contributor

cvictory commented Jun 7, 2021

Expected Behavior

In mysql, there are types as following:

// From : github.com/go-sql-driver/mysql@v1.5.0/fields.go
case fieldTypeBit:
		return "BIT"
	case fieldTypeBLOB:
		if mf.charSet != collations[binaryCollation] {
			return "TEXT"
		}
		return "BLOB"
	case fieldTypeDate:
		return "DATE"
	case fieldTypeDateTime:
		return "DATETIME"
	case fieldTypeDecimal:
		return "DECIMAL"
	case fieldTypeDouble:
		return "DOUBLE"
	case fieldTypeEnum:
		return "ENUM"
	case fieldTypeFloat:
		return "FLOAT"
	case fieldTypeGeometry:
		return "GEOMETRY"
	case fieldTypeInt24:
		return "MEDIUMINT"
	case fieldTypeJSON:
		return "JSON"
	case fieldTypeLong:
		return "INT"
	case fieldTypeLongBLOB:
		if mf.charSet != collations[binaryCollation] {
			return "LONGTEXT"
		}
		return "LONGBLOB"
	case fieldTypeLongLong:
		return "BIGINT"
	case fieldTypeMediumBLOB:
		if mf.charSet != collations[binaryCollation] {
			return "MEDIUMTEXT"
		}
		return "MEDIUMBLOB"
	case fieldTypeNewDate:
		return "DATE"
	case fieldTypeNewDecimal:
		return "DECIMAL"
	case fieldTypeNULL:
		return "NULL"
	case fieldTypeSet:
		return "SET"
	case fieldTypeShort:
		return "SMALLINT"
	case fieldTypeString:
		if mf.charSet == collations[binaryCollation] {
			return "BINARY"
		}
		return "CHAR"
	case fieldTypeTime:
		return "TIME"
	case fieldTypeTimestamp:
		return "TIMESTAMP"
	case fieldTypeTiny:
		return "TINYINT"
	case fieldTypeTinyBLOB:
		if mf.charSet != collations[binaryCollation] {
			return "TINYTEXT"
		}
		return "TINYBLOB"
	case fieldTypeVarChar:
		if mf.charSet == collations[binaryCollation] {
			return "VARBINARY"
		}
		return "VARCHAR"
	case fieldTypeVarString:
		if mf.charSet == collations[binaryCollation] {
			return "VARBINARY"
		}
		return "VARCHAR"
	case fieldTypeYear:
		return "YEAR"

Maybe we should support these data types.

Actual Behavior

But now we only support these data types.

// component-contrib mysql.go
func prepareScanArgs(columnTypes []*sql.ColumnType) []interface{} {
	scanArgs := make([]interface{}, len(columnTypes))
	for i, v := range columnTypes {
		switch v.DatabaseTypeName() {
		case "BOOL":
			scanArgs[i] = new(sql.NullBool)
		case "INT", "MEDIUMINT", "SMALLINT", "CHAR", "TINYINT":
			scanArgs[i] = new(sql.NullInt32)
		case "BIGINT":
			scanArgs[i] = new(sql.NullInt64)
		case "DOUBLE", "FLOAT", "DECIMAL":
			scanArgs[i] = new(sql.NullFloat64)
		case "DATE", "TIME", "YEAR":
			scanArgs[i] = new(sql.NullTime)
		default:
			scanArgs[i] = new(sql.NullString)
		}
	}

	return scanArgs
}

Steps to Reproduce the Problem

Release Note

RELEASE NOTE:

@cvictory cvictory added the kind/bug Something isn't working label Jun 7, 2021
beiwei30 added a commit to beiwei30/components-contrib that referenced this issue Jun 7, 2021
yaron2 added a commit that referenced this issue Jul 8, 2021
* fix: Mysql should support more data types. #923

* go fmt

* fix lint issue

* revise according to the review comment

Co-authored-by: Phil Kedy <phil.kedy@gmail.com>
Co-authored-by: Yaron Schneider <yaronsc@microsoft.com>
@yaron2 yaron2 added this to the v1.3 milestone Jul 8, 2021
Taction added a commit to Taction/components-contrib that referenced this issue Jul 15, 2021
* master: (23 commits)
  Adds support for TTL in Redis State Store (dapr#990)
  Adds support for TTL in Memcached State Store (PR Fixup) (dapr#1011)
  Adds support for TTL in Cassandra State Store (dapr#996)
  Return blob metadata and add list operation (dapr#999)
  Added new output binding for Cosmos Graph DB - Gremlin (dapr#885)
  Adds support for TTL in CosmosDB State Store (dapr#991)
  Delete unused code and update test (dapr#924)
  Return SystemProperties on events from EventHubs bindings and pubsub (dapr#1009)
  Implement E2E tests for zeebe (dapr#973)
  rebase (dapr#982)
  Update CODEOWNERS (dapr#987)
  ci: add test skip case (dapr#922)
  fix: Mysql should support more data types. dapr#923 (dapr#926)
  fix: Dapr runtime panic when handle Pub/Sub (dapr#3281) (dapr#967)
  switch to golang-jwt (dapr#993)
  unmarshal getBlobRetryCount as int (dapr#919)
  secretstores: support more format of azure key vault (dapr#944)
  Optimize vault secret component error output (dapr#909)
  Convert AZURE_KEYVAULT in conformance.yml a GitHub secret (dapr#1002)
  Use AzureKeyVaultName param for Azure Keyvault conformance test (dapr#975)
  ...

# Conflicts:
#	secretstores/hashicorp/vault/vault.go
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants