Skip to content

Commit

Permalink
fixup! feat: redshift sdk driver
Browse files Browse the repository at this point in the history
  • Loading branch information
atzoum committed Mar 22, 2024
1 parent c62bd7b commit 63020ec
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 18 deletions.
33 changes: 33 additions & 0 deletions sqlconnect/internal/redshift/config_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
package redshift_test

import (
"encoding/json"
"testing"

"github.com/stretchr/testify/require"
"github.com/tidwall/gjson"

"github.com/rudderlabs/sqlconnect-go/sqlconnect/internal/redshift"
)

func TestRedshiftSDKConfig(t *testing.T) {
// Create a new SDKConfig
config := redshift.SDKConfig{
ClusterIdentifier: "cluster-identifier",
Database: "database",
User: "user",
Region: "region",
AccessKeyID: "access-key-id",
SecretAccessKey: "secret",
SessionToken: "token",
}
configJSON, err := json.Marshal(&config)
require.NoError(t, err)
require.Equal(t, "sdk", gjson.GetBytes(configJSON, "type").String())

// Unmarshal the JSON back into a new SDKConfig
var newConfig redshift.SDKConfig
err = newConfig.Parse(configJSON)
require.NoError(t, err)
require.Equal(t, config, newConfig)
}
Binary file not shown.
21 changes: 3 additions & 18 deletions sqlconnect/internal/redshift/legacy_mappings.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
package redshift

import "encoding/json"

var legacyColumnTypeMappings = map[string]string{
"int": "int",
"int2": "int",
Expand Down Expand Up @@ -33,22 +31,9 @@ var legacyColumnTypeMappings = map[string]string{

// legacyJsonRowMapper maps a row's scanned column to a json object's field
func legacyJsonRowMapper(databaseTypeName string, value any) any {
switch databaseTypeName {
case "JSON":
fallthrough
case "JSONB":
switch v := value.(type) {
case []byte:
return json.RawMessage(v)

case string:
return json.RawMessage(v)
}
default:
switch v := value.(type) {
case []byte:
return string(v)
}
switch v := value.(type) {
case []byte:
return string(v)
}
return value
}

0 comments on commit 63020ec

Please sign in to comment.