forked from Morabaraba/teleport
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Implement COPY FROM support for DML initial load.
- Loading branch information
1 parent
565655c
commit a643933
Showing
18 changed files
with
236 additions
and
150 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,46 @@ | ||
package action | ||
|
||
import ( | ||
"encoding/json" | ||
) | ||
|
||
type Row struct { | ||
Value interface{} | ||
Column Column | ||
} | ||
|
||
type Rows []Row | ||
|
||
func (r *Row) GetValue() interface{} { | ||
// pq cannot handle nested JSON objects | ||
if obj, ok := r.Value.(*map[string]interface{}); ok { | ||
jsonStr, err := json.Marshal(obj) | ||
|
||
if err != nil { | ||
return err | ||
} | ||
|
||
return string(jsonStr) | ||
} | ||
|
||
// text/varchar are converted to slice of bytes. | ||
// Convert back to string... | ||
if bytea, ok := r.Value.([]byte); ok { | ||
return string(bytea) | ||
} | ||
|
||
return r.Value | ||
} | ||
|
||
// Implement Interface | ||
func (slice Rows) Len() int { | ||
return len(slice) | ||
} | ||
|
||
func (slice Rows) Less(i, j int) bool { | ||
return slice[i].Column.Name < slice[j].Column.Name | ||
} | ||
|
||
func (slice Rows) Swap(i, j int) { | ||
slice[i], slice[j] = slice[j], slice[i] | ||
} |
Oops, something went wrong.