@@ -68,7 +68,7 @@ func (w Writer) Insert(values []string, schema schema.Schema, tableName string)
6868 var sb strings.Builder
6969 valuesLength := len (values )
7070
71- // we are creating a string for the insert template like: $1, $2, $3
71+ // Generate placeholder string. e.g. $1, $2, $3
7272 for i := 1 ; i < valuesLength + 1 ; i ++ {
7373
7474 sb .WriteRune ('$' )
@@ -80,13 +80,15 @@ func (w Writer) Insert(values []string, schema schema.Schema, tableName string)
8080 }
8181 }
8282
83+ // Build the INSERT statement
8384 statement := fmt .Sprintf (`INSERT INTO "%s" VALUES (%s);` , tableName , sb .String ())
8485
8586 var valuesGeneric = make ([]interface {}, len (values ))
8687 for i , value := range values {
8788 valuesGeneric [i ] = value
8889 }
8990
91+ // Execute the statement
9092 _ , err = w .db .Exec (statement , valuesGeneric ... )
9193
9294 if nil != err {
@@ -96,6 +98,7 @@ func (w Writer) Insert(values []string, schema schema.Schema, tableName string)
9698 return err
9799}
98100
101+ // getSQLColumnType converts types.BasicKind values to corresponding postgresql column types
99102func (w Writer ) getSQLColumnType (goType types.BasicKind ) (result string ) {
100103
101104 switch goType {
@@ -115,6 +118,8 @@ func (w Writer) getSQLColumnType(goType types.BasicKind) (result string) {
115118 result = "DOUBLE"
116119 case types .String :
117120 result = "TEXT"
121+ default :
122+ panic (fmt .Sprintf ("unsupported golang type: %d" , goType ))
118123 }
119124
120125 return result
0 commit comments