From bb2c813d256d5c0356e06489046887ba6c1f6ccf Mon Sep 17 00:00:00 2001 From: lianxmfor <1034552569@qq.com> Date: Mon, 14 Feb 2022 09:34:47 +0800 Subject: [PATCH] fix(dbutil): function DBValueType support TIDB --- internal/database/dbutil/db_opt.go | 10 ++++------ internal/database/dbutil/type_mapping.go | 2 +- 2 files changed, 5 insertions(+), 7 deletions(-) diff --git a/internal/database/dbutil/db_opt.go b/internal/database/dbutil/db_opt.go index 5fee0cb14..e0cc14485 100644 --- a/internal/database/dbutil/db_opt.go +++ b/internal/database/dbutil/db_opt.go @@ -5,13 +5,12 @@ import ( "fmt" "strings" + "cloud.google.com/go/bigquery" "github.com/gocql/gocql" - - "github.com/oom-ai/oomstore/pkg/errdefs" + "github.com/jmoiron/sqlx" "github.com/spf13/cast" - "cloud.google.com/go/bigquery" - "github.com/jmoiron/sqlx" + "github.com/oom-ai/oomstore/pkg/errdefs" "github.com/oom-ai/oomstore/pkg/oomstore/types" ) @@ -38,8 +37,7 @@ func (d *DBOpt) ExecContext(ctx context.Context, query string, args []interface{ _, err := d.BigQueryDB.Query(query).Read(ctx) return errdefs.WithStack(err) case types.BackendCassandra: - err := d.CassandraDB.Query(query).Exec() - return errdefs.WithStack(err) + return errdefs.WithStack(d.CassandraDB.Query(query).Exec()) default: _, err := d.SqlxDB.ExecContext(ctx, d.SqlxDB.Rebind(query), args...) return errdefs.WithStack(err) diff --git a/internal/database/dbutil/type_mapping.go b/internal/database/dbutil/type_mapping.go index d22cf4890..a8058331e 100644 --- a/internal/database/dbutil/type_mapping.go +++ b/internal/database/dbutil/type_mapping.go @@ -14,7 +14,7 @@ func DBValueType(backend types.BackendType, valueType types.ValueType) (string, mp = valueTypeToPostgresType case types.BackendSQLite: mp = valueTypeToSQLiteType - case types.BackendMySQL: + case types.BackendMySQL, types.BackendTiDB: mp = valueTypeToMySQLType case types.BackendCassandra: mp = valueTypeToCassandraType