Skip to content

Commit

Permalink
Merge pull request supabase#43 from dymium-io/db-type-change
Browse files Browse the repository at this point in the history
changes in Go to reflect changes in DB

Former-commit-id: 00c529ca71c28f0ff7ca182c32779f20ce56c7a2 [formerly a49e9b8bf1a41b22da38524343e98755137ff866]
Former-commit-id: 7aa54bfe8a853dd8a1b7240857397bf12fadf816
  • Loading branch information
gazillion101 authored Jun 30, 2022
2 parents 67ff951 + c37ae45 commit f3243c7
Showing 1 changed file with 6 additions and 23 deletions.
29 changes: 6 additions & 23 deletions DbSync/go/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,22 +16,6 @@ import (

var db *sql.DB

func conType(ct string) (types.ConnectionType, error) {
switch ct {
case "postgres":
return types.CT_PostgreSQL, nil
case "mysql":
return types.CT_MySQL, nil
case "mariadb":
return types.CT_MariaDB, nil
case "sqlserver":
return types.CT_SqlServer, nil
case "oracle":
return types.CT_OracleDB, nil
}
return "", fmt.Errorf("Connection type %s is not supported yet", ct)
}

func LambdaHandler(c types.Request) (interface{}, error) {

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


if db == nil {
if db == nil || db.Ping() != nil {
if err := openDb(cnf); err != nil {
return nil, err
}
}
if err = db.Ping(); err != nil {
return nil, err
}

datascopes, err := getDatascopes(db, c.Customer, c.Datascope)
if err != nil {
Expand Down Expand Up @@ -129,13 +116,9 @@ func getConnections(db *sql.DB, infoSchema string) (*map[string]types.Connection
connections := map[string]types.Connection{}
for rows.Next() {
var c types.Connection
var dt string
rows.Scan(&c.Id, &c.Address, &c.Port, &c.Name, &dt, &c.Use_tls, &c.Dbname)
if c.Database_type, err = conType(dt); err != nil {
return nil, err
}
rows.Scan(&c.Id, &c.Address, &c.Port, &c.Name, &c.Database_type, &c.Use_tls, &c.Dbname)
if c.Address == "localhost" {
c.Address = "ocker.for.mac.host.internal"
c.Address = "docker.for.mac.host.internal"
}
connections[c.Id] = c
}
Expand Down

0 comments on commit f3243c7

Please sign in to comment.