Skip to content

Commit f3243c7

Browse files
authored
Merge pull request supabase#43 from dymium-io/db-type-change
changes in Go to reflect changes in DB Former-commit-id: 00c529ca71c28f0ff7ca182c32779f20ce56c7a2 [formerly a49e9b8bf1a41b22da38524343e98755137ff866] Former-commit-id: 7aa54bfe8a853dd8a1b7240857397bf12fadf816
2 parents 67ff951 + c37ae45 commit f3243c7

File tree

1 file changed

+6
-23
lines changed

1 file changed

+6
-23
lines changed

DbSync/go/main.go

+6-23
Original file line numberDiff line numberDiff line change
@@ -16,22 +16,6 @@ import (
1616

1717
var db *sql.DB
1818

19-
func conType(ct string) (types.ConnectionType, error) {
20-
switch ct {
21-
case "postgres":
22-
return types.CT_PostgreSQL, nil
23-
case "mysql":
24-
return types.CT_MySQL, nil
25-
case "mariadb":
26-
return types.CT_MariaDB, nil
27-
case "sqlserver":
28-
return types.CT_SqlServer, nil
29-
case "oracle":
30-
return types.CT_OracleDB, nil
31-
}
32-
return "", fmt.Errorf("Connection type %s is not supported yet", ct)
33-
}
34-
3519
func LambdaHandler(c types.Request) (interface{}, error) {
3620

3721
var cnf *conf
@@ -57,11 +41,14 @@ func LambdaHandler(c types.Request) (interface{}, error) {
5741
}
5842

5943

60-
if db == nil {
44+
if db == nil || db.Ping() != nil {
6145
if err := openDb(cnf); err != nil {
6246
return nil, err
6347
}
6448
}
49+
if err = db.Ping(); err != nil {
50+
return nil, err
51+
}
6552

6653
datascopes, err := getDatascopes(db, c.Customer, c.Datascope)
6754
if err != nil {
@@ -129,13 +116,9 @@ func getConnections(db *sql.DB, infoSchema string) (*map[string]types.Connection
129116
connections := map[string]types.Connection{}
130117
for rows.Next() {
131118
var c types.Connection
132-
var dt string
133-
rows.Scan(&c.Id, &c.Address, &c.Port, &c.Name, &dt, &c.Use_tls, &c.Dbname)
134-
if c.Database_type, err = conType(dt); err != nil {
135-
return nil, err
136-
}
119+
rows.Scan(&c.Id, &c.Address, &c.Port, &c.Name, &c.Database_type, &c.Use_tls, &c.Dbname)
137120
if c.Address == "localhost" {
138-
c.Address = "ocker.for.mac.host.internal"
121+
c.Address = "docker.for.mac.host.internal"
139122
}
140123
connections[c.Id] = c
141124
}

0 commit comments

Comments
 (0)