Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 15 additions & 2 deletions executor.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import (
"fmt"
"io"
"strconv"
"strings"
"time"

"github.com/aws/aws-sdk-go/aws"
Expand Down Expand Up @@ -61,7 +62,7 @@ func (r *Result) Next(dest []driver.Value) error {
case "DATE":
layout = "2006-01-02"

case "DATETIME", "TIMESTAMP":
case "DATETIME", "TIMESTAMP", "timestamptz":
layout = "2006-01-02 15:04:05"

case "YEAR":
Expand Down Expand Up @@ -104,7 +105,11 @@ func (r *Result) RowsAffected() (int64, error) {
const prefix = "f"

func executeStatement(ctx context.Context, config *config, query, transactionID string, args ...driver.NamedValue) (*Result, error) {
query = nameParameters(prefix, query)
if strings.Contains(config.database, "postgres") {
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Realistically there should be a better way of doing this... although I'm not sure what would make the most sense.

query = nameParametersPsql(prefix, query, len(args))
} else {
query = nameParameters(prefix, query)
}
input := &rdsdataservice.ExecuteStatementInput{
Database: aws.String(config.database),
IncludeResultMetadata: aws.Bool(true),
Expand Down Expand Up @@ -160,3 +165,11 @@ func nameParameters(prefix, query string) string {
}
return string(got)
}

func nameParametersPsql(prefix, query string, numArgs int) string {
result := query
for i := 1; i <= numArgs; i++ {
result = strings.Replace(result, fmt.Sprint("$", i), fmt.Sprint(":", prefix, i), -1)
}
return result
}