Skip to content

Commit

Permalink
Handle floats
Browse files Browse the repository at this point in the history
  • Loading branch information
exAspArk committed Nov 5, 2024
1 parent 92ca814 commit 8329a85
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions src/proxy.go
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,9 @@ func (proxy *Proxy) generateDataRow(rows *sql.Rows, cols []*sql.ColumnType) (*pg
case "int64":
var value int64
valuePtrs[i] = &value
case "float64":
var value float64
valuePtrs[i] = &value
case "string":
var value string
valuePtrs[i] = &value
Expand All @@ -129,7 +132,7 @@ func (proxy *Proxy) generateDataRow(rows *sql.Rows, cols []*sql.ColumnType) (*pg
var value duckDB.Decimal
valuePtrs[i] = &value
default:
panic("Unsupported type")
panic("Unsupported type: " + col.ScanType().Name())
}
}

Expand All @@ -145,20 +148,22 @@ func (proxy *Proxy) generateDataRow(rows *sql.Rows, cols []*sql.ColumnType) (*pg
values = append(values, []byte(strconv.Itoa(int(*value))))
case *int64:
values = append(values, []byte(strconv.Itoa(int(*value))))
case *float64:
values = append(values, []byte(fmt.Sprintf("%v", *value)))
case *string:
values = append(values, []byte(*value))
case *time.Time:
switch cols[i].DatabaseTypeName() {
case "DATE":
values = append(values, []byte(value.Format("2006-01-02")))
default:
panic("Unsupported type")
panic("Unsupported type: " + cols[i].DatabaseTypeName())
}
case *duckDB.Decimal:
float64Value := (*value).Float64()
values = append(values, []byte(fmt.Sprintf("%v", float64Value)))
default:
panic("Unsupported type")
panic("Unsupported type: " + cols[i].ScanType().Name())
}
}
dataRow := pgproto3.DataRow{Values: values}
Expand Down

0 comments on commit 8329a85

Please sign in to comment.