(refactor) add `TEST_YDB_CONNECTION_STRING`
(refactor) fix return in `toYQLDataType` (refactor) fix returns in `yqlToSQLType`
This commit is contained in:
parent
706471070e
commit
b2b647f9ca
|
@ -37,10 +37,8 @@ jobs:
|
||||||
with:
|
with:
|
||||||
go-version: 1.20
|
go-version: 1.20
|
||||||
- uses: actions/checkout@v3
|
- uses: actions/checkout@v3
|
||||||
#- name: test ydb (secure connection)
|
|
||||||
# run: TEST_YDB_SCHEME=grpcs TEST_YDB_HOST=ydb:2135 TEST_YDB_DBNAME=local make test-ydb
|
|
||||||
- name: test ydb (insecure connection)
|
- name: test ydb (insecure connection)
|
||||||
run: TEST_YDB_SCHEME=grpc TEST_YDB_HOST=ydb:2136 TEST_YDB_DBNAME=local make test-ydb
|
run: make test-ydb
|
||||||
|
|
||||||
services:
|
services:
|
||||||
ydb:
|
ydb:
|
||||||
|
@ -49,13 +47,10 @@ jobs:
|
||||||
- 2135:2135
|
- 2135:2135
|
||||||
- 2136:2136
|
- 2136:2136
|
||||||
- 8765:8765
|
- 8765:8765
|
||||||
#volumes:
|
|
||||||
# - /tmp/ydb_certs:/ydb_certs
|
|
||||||
env:
|
env:
|
||||||
YDB_LOCAL_SURVIVE_RESTART: true
|
YDB_LOCAL_SURVIVE_RESTART: true
|
||||||
YDB_USE_IN_MEMORY_PDISKS: true
|
YDB_USE_IN_MEMORY_PDISKS: true
|
||||||
|
|
||||||
env:
|
env:
|
||||||
#YDB_SSL_ROOT_CERTIFICATES_FILE: /tmp/ydb_certs/ca.pem
|
|
||||||
YDB_SESSIONS_SHUTDOWN_URLS: http://ydb:8765/actors/kqp_proxy?force_shutdown=all
|
YDB_SESSIONS_SHUTDOWN_URLS: http://ydb:8765/actors/kqp_proxy?force_shutdown=all
|
||||||
HIDE_APPLICATION_OUTPUT: 1
|
HIDE_APPLICATION_OUTPUT: 1
|
11
Makefile
11
Makefile
|
@ -47,14 +47,7 @@ TEST_DAMENG_HOST ?= dameng:5236
|
||||||
TEST_DAMENG_USERNAME ?= SYSDBA
|
TEST_DAMENG_USERNAME ?= SYSDBA
|
||||||
TEST_DAMENG_PASSWORD ?= SYSDBA
|
TEST_DAMENG_PASSWORD ?= SYSDBA
|
||||||
|
|
||||||
TEST_YDB_SCHEME ?= grpc
|
TEST_YDB_CONNECTION_STRING ?= grpc://ydb:2136/local?go_query_bind=table_path_prefix(/local/xorm/test),declare,numeric&go_fake_tx=scan,scheme,scripting
|
||||||
TEST_YDB_HOST ?= ydb:2136
|
|
||||||
TEST_YDB_DBNAME ?= local
|
|
||||||
TEST_YDB_TABLE_PATH_PREFIX ?= /local/xorm/test
|
|
||||||
TEST_YDB_QUERY_BIND ?= table_path_prefix($(TEST_YDB_TABLE_PATH_PREFIX)),declare,numeric
|
|
||||||
TEST_YDB_FAKE_TX ?= scan,scheme,scripting
|
|
||||||
TEST_YDB_USERNAME ?=
|
|
||||||
TEST_YDB_PASSWORD ?=
|
|
||||||
|
|
||||||
TEST_CACHE_ENABLE ?= false
|
TEST_CACHE_ENABLE ?= false
|
||||||
TEST_QUOTE_POLICY ?= always
|
TEST_QUOTE_POLICY ?= always
|
||||||
|
@ -290,7 +283,7 @@ test-dameng\#%: go-check
|
||||||
.PHONY: test-ydb
|
.PHONY: test-ydb
|
||||||
test-ydb: go-check
|
test-ydb: go-check
|
||||||
$(GO) test $(INTEGRATION_PACKAGES)/ydbtest -v -race -db=ydb -cache=$(TEST_CACHE_ENABLE) \
|
$(GO) test $(INTEGRATION_PACKAGES)/ydbtest -v -race -db=ydb -cache=$(TEST_CACHE_ENABLE) \
|
||||||
-conn_str="$(TEST_YDB_SCHEME)://$(TEST_YDB_HOST)/$(TEST_YDB_DBNAME)?go_query_bind=$(TEST_YDB_QUERY_BIND)&go_fake_tx=$(TEST_YDB_FAKE_TX)" \
|
-conn_str="$(TEST_YDB_CONNECTION_STRING)" \
|
||||||
-quote=$(TEST_QUOTE_POLICY) -coverprofile=ydb.$(TEST_QUOTE_POLICY).$(TEST_CACHE_ENABLE).coverage.out -covermode=atomic -timeout=20m
|
-quote=$(TEST_QUOTE_POLICY) -coverprofile=ydb.$(TEST_QUOTE_POLICY).$(TEST_CACHE_ENABLE).coverage.out -covermode=atomic -timeout=20m
|
||||||
|
|
||||||
.PHONY: vet
|
.PHONY: vet
|
||||||
|
|
|
@ -56,7 +56,7 @@ Drivers for Go's sql package which currently support database/sql includes:
|
||||||
- [github.com/sijms/go-ora](https://github.com/sijms/go-ora) (experiment)
|
- [github.com/sijms/go-ora](https://github.com/sijms/go-ora) (experiment)
|
||||||
|
|
||||||
* [YDB](https://github.com/ydb-platform/ydb)
|
* [YDB](https://github.com/ydb-platform/ydb)
|
||||||
- [github.com/ydb-platform/ydb-go-sdk](https://github.com/ydb-platform/ydb-go-sdk)
|
- [github.com/ydb-platform/ydb-go-sdk](https://github.com/ydb-platform/ydb-go-sdk) (experiment)
|
||||||
|
|
||||||
## Installation
|
## Installation
|
||||||
|
|
||||||
|
|
118
dialects/ydb.go
118
dialects/ydb.go
|
@ -289,128 +289,90 @@ const (
|
||||||
yql_List = "LIST"
|
yql_List = "LIST"
|
||||||
)
|
)
|
||||||
|
|
||||||
func toYQLDataType(t string, defaultLength, defaultLength2 int64) (yqlType string) {
|
func toYQLDataType(t string, defaultLength, defaultLength2 int64) string {
|
||||||
switch v := t; v {
|
switch v := t; v {
|
||||||
case schemas.Bool, schemas.Boolean:
|
case schemas.Bool, schemas.Boolean:
|
||||||
yqlType = yql_Bool
|
return yql_Bool
|
||||||
return
|
|
||||||
case schemas.TinyInt:
|
case schemas.TinyInt:
|
||||||
yqlType = yql_Int8
|
return yql_Int8
|
||||||
return
|
|
||||||
case schemas.UnsignedTinyInt:
|
case schemas.UnsignedTinyInt:
|
||||||
yqlType = yql_Uint8
|
return yql_Uint8
|
||||||
return
|
|
||||||
case schemas.SmallInt:
|
case schemas.SmallInt:
|
||||||
yqlType = yql_Int16
|
return yql_Int16
|
||||||
return
|
|
||||||
case schemas.UnsignedSmallInt:
|
case schemas.UnsignedSmallInt:
|
||||||
yqlType = yql_Uint16
|
return yql_Uint16
|
||||||
return
|
|
||||||
case schemas.MediumInt:
|
case schemas.MediumInt:
|
||||||
yqlType = yql_Int32
|
return yql_Int32
|
||||||
return
|
|
||||||
case schemas.UnsignedMediumInt:
|
case schemas.UnsignedMediumInt:
|
||||||
yqlType = yql_Uint32
|
return yql_Uint32
|
||||||
return
|
|
||||||
case schemas.BigInt:
|
case schemas.BigInt:
|
||||||
yqlType = yql_Int64
|
return yql_Int64
|
||||||
return
|
|
||||||
case schemas.UnsignedBigInt:
|
case schemas.UnsignedBigInt:
|
||||||
yqlType = yql_Uint64
|
return yql_Uint64
|
||||||
return
|
|
||||||
case schemas.Int, schemas.Integer:
|
case schemas.Int, schemas.Integer:
|
||||||
yqlType = yql_Int32
|
return yql_Int32
|
||||||
return
|
|
||||||
case schemas.UnsignedInt:
|
case schemas.UnsignedInt:
|
||||||
yqlType = yql_Uint32
|
return yql_Uint32
|
||||||
return
|
|
||||||
case schemas.Float:
|
case schemas.Float:
|
||||||
yqlType = yql_Float
|
return yql_Float
|
||||||
return
|
|
||||||
case schemas.Double:
|
case schemas.Double:
|
||||||
yqlType = yql_Double
|
return yql_Double
|
||||||
return
|
|
||||||
case schemas.Blob:
|
case schemas.Blob:
|
||||||
yqlType = yql_String
|
return yql_String
|
||||||
return
|
|
||||||
case schemas.Json:
|
case schemas.Json:
|
||||||
yqlType = yql_Json
|
return yql_Json
|
||||||
return
|
|
||||||
case schemas.Array:
|
case schemas.Array:
|
||||||
yqlType = yql_List
|
return yql_List
|
||||||
return
|
|
||||||
case schemas.Varchar, schemas.Text:
|
case schemas.Varchar, schemas.Text:
|
||||||
yqlType = yql_Utf8
|
return yql_Utf8
|
||||||
return
|
|
||||||
case schemas.TimeStamp, schemas.DateTime:
|
case schemas.TimeStamp, schemas.DateTime:
|
||||||
yqlType = yql_Timestamp
|
return yql_Timestamp
|
||||||
return
|
|
||||||
case schemas.Interval:
|
case schemas.Interval:
|
||||||
yqlType = yql_Interval
|
return yql_Interval
|
||||||
return
|
|
||||||
default:
|
default:
|
||||||
yqlType = yql_String
|
return yql_String
|
||||||
}
|
}
|
||||||
return
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func yqlToSQLType(yqlType string) (sqlType schemas.SQLType) {
|
func yqlToSQLType(yqlType string) schemas.SQLType {
|
||||||
switch yqlType {
|
switch yqlType {
|
||||||
case yql_Bool:
|
case yql_Bool:
|
||||||
sqlType = schemas.SQLType{Name: schemas.Bool, DefaultLength: 0, DefaultLength2: 0}
|
return schemas.SQLType{Name: schemas.Bool, DefaultLength: 0, DefaultLength2: 0}
|
||||||
return
|
|
||||||
case yql_Int8:
|
case yql_Int8:
|
||||||
sqlType = schemas.SQLType{Name: schemas.TinyInt, DefaultLength: 0, DefaultLength2: 0}
|
return schemas.SQLType{Name: schemas.TinyInt, DefaultLength: 0, DefaultLength2: 0}
|
||||||
return
|
|
||||||
case yql_Uint8:
|
case yql_Uint8:
|
||||||
sqlType = schemas.SQLType{Name: schemas.UnsignedTinyInt, DefaultLength: 0, DefaultLength2: 0}
|
return schemas.SQLType{Name: schemas.UnsignedTinyInt, DefaultLength: 0, DefaultLength2: 0}
|
||||||
return
|
|
||||||
case yql_Int16:
|
case yql_Int16:
|
||||||
sqlType = schemas.SQLType{Name: schemas.SmallInt, DefaultLength: 0, DefaultLength2: 0}
|
return schemas.SQLType{Name: schemas.SmallInt, DefaultLength: 0, DefaultLength2: 0}
|
||||||
return
|
|
||||||
case yql_Uint16:
|
case yql_Uint16:
|
||||||
sqlType = schemas.SQLType{Name: schemas.UnsignedSmallInt, DefaultLength: 0, DefaultLength2: 0}
|
return schemas.SQLType{Name: schemas.UnsignedSmallInt, DefaultLength: 0, DefaultLength2: 0}
|
||||||
return
|
|
||||||
case yql_Int32:
|
case yql_Int32:
|
||||||
sqlType = schemas.SQLType{Name: schemas.MediumInt, DefaultLength: 0, DefaultLength2: 0}
|
return schemas.SQLType{Name: schemas.MediumInt, DefaultLength: 0, DefaultLength2: 0}
|
||||||
return
|
|
||||||
case yql_Uint32:
|
case yql_Uint32:
|
||||||
sqlType = schemas.SQLType{Name: schemas.UnsignedMediumInt, DefaultLength: 0, DefaultLength2: 0}
|
return schemas.SQLType{Name: schemas.UnsignedMediumInt, DefaultLength: 0, DefaultLength2: 0}
|
||||||
return
|
|
||||||
case yql_Int64:
|
case yql_Int64:
|
||||||
sqlType = schemas.SQLType{Name: schemas.BigInt, DefaultLength: 0, DefaultLength2: 0}
|
return schemas.SQLType{Name: schemas.BigInt, DefaultLength: 0, DefaultLength2: 0}
|
||||||
return
|
|
||||||
case yql_Uint64:
|
case yql_Uint64:
|
||||||
sqlType = schemas.SQLType{Name: schemas.UnsignedBigInt, DefaultLength: 0, DefaultLength2: 0}
|
return schemas.SQLType{Name: schemas.UnsignedBigInt, DefaultLength: 0, DefaultLength2: 0}
|
||||||
return
|
|
||||||
case yql_Float:
|
case yql_Float:
|
||||||
sqlType = schemas.SQLType{Name: schemas.Float, DefaultLength: 0, DefaultLength2: 0}
|
return schemas.SQLType{Name: schemas.Float, DefaultLength: 0, DefaultLength2: 0}
|
||||||
return
|
|
||||||
case yql_Double:
|
case yql_Double:
|
||||||
sqlType = schemas.SQLType{Name: schemas.Double, DefaultLength: 0, DefaultLength2: 0}
|
return schemas.SQLType{Name: schemas.Double, DefaultLength: 0, DefaultLength2: 0}
|
||||||
return
|
|
||||||
case yql_String:
|
case yql_String:
|
||||||
sqlType = schemas.SQLType{Name: schemas.Blob, DefaultLength: 0, DefaultLength2: 0}
|
return schemas.SQLType{Name: schemas.Blob, DefaultLength: 0, DefaultLength2: 0}
|
||||||
return
|
|
||||||
case yql_Json:
|
case yql_Json:
|
||||||
sqlType = schemas.SQLType{Name: schemas.Json, DefaultLength: 0, DefaultLength2: 0}
|
return schemas.SQLType{Name: schemas.Json, DefaultLength: 0, DefaultLength2: 0}
|
||||||
return
|
|
||||||
case yql_List:
|
case yql_List:
|
||||||
sqlType = schemas.SQLType{Name: schemas.Array, DefaultLength: 0, DefaultLength2: 0}
|
return schemas.SQLType{Name: schemas.Array, DefaultLength: 0, DefaultLength2: 0}
|
||||||
return
|
|
||||||
case yql_Utf8:
|
case yql_Utf8:
|
||||||
sqlType = schemas.SQLType{Name: schemas.Varchar, DefaultLength: 255, DefaultLength2: 0}
|
return schemas.SQLType{Name: schemas.Varchar, DefaultLength: 255, DefaultLength2: 0}
|
||||||
return
|
|
||||||
case yql_Timestamp:
|
case yql_Timestamp:
|
||||||
sqlType = schemas.SQLType{Name: schemas.TimeStamp, DefaultLength: 0, DefaultLength2: 0}
|
return schemas.SQLType{Name: schemas.TimeStamp, DefaultLength: 0, DefaultLength2: 0}
|
||||||
return
|
|
||||||
case yql_Interval:
|
case yql_Interval:
|
||||||
sqlType = schemas.SQLType{Name: schemas.Interval, DefaultLength: 0, DefaultLength2: 0}
|
return schemas.SQLType{Name: schemas.Interval, DefaultLength: 0, DefaultLength2: 0}
|
||||||
return
|
|
||||||
default:
|
default:
|
||||||
sqlType = schemas.SQLType{Name: schemas.Blob, DefaultLength: 0, DefaultLength2: 0}
|
return schemas.SQLType{Name: schemas.Blob, DefaultLength: 0, DefaultLength2: 0}
|
||||||
}
|
}
|
||||||
return
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func removeOptional(s string) string {
|
func removeOptional(s string) string {
|
||||||
|
|
Loading…
Reference in New Issue