mirror of
https://github.com/t8y2/dbx.git
synced 2026-10-21 06:00:39 +00:00
@@ -215,10 +215,9 @@ func parseConnectionConfig(params connectParams) (connectionConfig, error) {
|
||||
func newSessionClient(config connectionConfig) (*sessionClient, error) {
|
||||
var session client.Session
|
||||
var err error
|
||||
database := config.Database
|
||||
if config.Dialect == client.TableSqlDialect {
|
||||
database = ""
|
||||
}
|
||||
// DBX applies a table database with USE after switching dialects. Do not
|
||||
// include a tree database in openSession: IoTDB 2.x rejects it there, while
|
||||
// DBX still retains it for metadata and path qualification.
|
||||
if len(config.NodeURLs) > 1 {
|
||||
session, err = client.NewClusterSession(&client.ClusterConfig{
|
||||
NodeUrls: config.NodeURLs,
|
||||
@@ -227,7 +226,6 @@ func newSessionClient(config connectionConfig) (*sessionClient, error) {
|
||||
FetchSize: config.FetchSize,
|
||||
TimeZone: config.TimeZone,
|
||||
ConnectRetryMax: config.ConnectRetryMax,
|
||||
Database: database,
|
||||
TLSConfig: config.TLSConfig,
|
||||
})
|
||||
if err == nil {
|
||||
@@ -242,7 +240,6 @@ func newSessionClient(config connectionConfig) (*sessionClient, error) {
|
||||
FetchSize: config.FetchSize,
|
||||
TimeZone: config.TimeZone,
|
||||
ConnectRetryMax: config.ConnectRetryMax,
|
||||
Database: database,
|
||||
TLSConfig: config.TLSConfig,
|
||||
})
|
||||
err = session.Open(config.EnableCompression, config.ConnectTimeoutMS)
|
||||
|
||||
@@ -87,6 +87,30 @@ func TestLiveIoTDBAgentTreeAndTable(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestLiveIoTDBAgentTreeDatabaseConnection(t *testing.T) {
|
||||
if os.Getenv("DBX_IOTDB_LIVE") != "1" {
|
||||
t.Skip("set DBX_IOTDB_LIVE=1 to run against a real IoTDB server")
|
||||
}
|
||||
database := "root.dbx_go_connection_" + strconv.Itoa(os.Getpid())
|
||||
bootstrap := liveIoTDBServer(t, connectParams{})
|
||||
defer bootstrap.disconnect()
|
||||
mustExecuteNonQuery(t, bootstrap, "CREATE DATABASE "+database, "")
|
||||
defer func() { _ = bootstrap.executeNonQuery("DELETE DATABASE "+database, "", 0) }()
|
||||
|
||||
scoped := liveIoTDBServer(t, connectParams{Database: database})
|
||||
defer scoped.disconnect()
|
||||
if err := scoped.validateConnection(); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
tables, err := scoped.listTables(database, metadataListConstraints{})
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if tables == nil {
|
||||
t.Fatal("expected an initialized tree table list")
|
||||
}
|
||||
}
|
||||
|
||||
func TestLiveIoTDBAgentProcessMultiSessionAndCancellation(t *testing.T) {
|
||||
if os.Getenv("DBX_IOTDB_LIVE") != "1" {
|
||||
t.Skip("set DBX_IOTDB_LIVE=1 to run against a real IoTDB server")
|
||||
|
||||
Reference in New Issue
Block a user