aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatthew Lemon <lemon@matthewlemon.com>2020-08-01 19:16:48 +0100
committerMatthew Lemon <lemon@matthewlemon.com>2020-08-01 19:17:16 +0100
commitadd51ef91b96e604c00b447f58d5df5fa638b90e (patch)
treeed81a01fb21fe60f40c551a27108d3cf04a1d6b2
parent52cc2c420d0b9f2a3e46769db2bb532a46700452 (diff)
fixed extraneous variable
-rw-r--r--pkg/datamaps/writer.go28
-rw-r--r--pkg/datamaps/writer_test.go7
2 files changed, 6 insertions, 29 deletions
diff --git a/pkg/datamaps/writer.go b/pkg/datamaps/writer.go
index 9af5207..cff9f4e 100644
--- a/pkg/datamaps/writer.go
+++ b/pkg/datamaps/writer.go
@@ -13,29 +13,6 @@ import (
)
func ExportMaster(opts *Options) error {
- // A master represents a set of file data from the database. Actually, in terms of the database,
- // it should represent a "return".
- //
- // The meat of the master is of the format:
- // Key 1 | Key_1_Value_for_FD_1 | Key_1_Value_for_FD_2 | Key_1_Value_for_FD_3 | ... etc
- // Key 2 | Key_2_Value_for_FD_1 | Key_2_Value_for_FD_2 | Key_2_Value_for_FD_3 | ... etc
- // Key 3 | Key_3_Value_for_FD_1 | Key_3_Value_for_FD_2 | Key_3_Value_for_FD_3 | ... etc
- // ...
- // Could be represented as a slice or a map[string][]string
- // SQL statement:
- //
- // SELECT datamap_line.key, return_data.value, return_data.filename
- // FROM (((return_data
- // INNER JOIN datamap_line ON return_data.dml_id=datamap_line.id)
- // INNER JOIN datamap ON datamap_line.dm_id=datamap.id)
- // INNER JOIN return on return_data.ret_id=return.id)
- // WHERE datamap.name="Tonk 1" AND return.name="Hunkers";
-
- // filename := filepath.Join(opts.MasterOutPutPath, "master.xlsx")
-
- // a test key
- targetKey := "A Rabbit"
-
wb := xlsx.NewFile()
sh, err := wb.AddSheet("Master Data")
@@ -77,11 +54,10 @@ func ExportMaster(opts *Options) error {
INNER JOIN datamap_line ON return_data.dml_id=datamap_line.id)
INNER JOIN datamap ON datamap_line.dm_id=datamap.id)
INNER JOIN return on return_data.ret_id=return.id)
- WHERE datamap.name=? AND return.name=? AND datamap_line.key=?
- GROUP BY datamap_line.key;`
+ WHERE datamap.name=? AND return.name=?;`
var rowCount int64
- rowCountRes := db.QueryRow(sqlCount, opts.DMName, opts.ReturnName, targetKey) // TODO: fix this
+ rowCountRes := db.QueryRow(sqlCount, opts.DMName, opts.ReturnName)
if err != nil {
return fmt.Errorf("cannot query for row count of return data - %v", err)
}
diff --git a/pkg/datamaps/writer_test.go b/pkg/datamaps/writer_test.go
index 5800d1f..4be87d9 100644
--- a/pkg/datamaps/writer_test.go
+++ b/pkg/datamaps/writer_test.go
@@ -2,6 +2,7 @@ package datamaps
import (
"os"
+ "path/filepath"
"testing"
)
@@ -27,9 +28,9 @@ func TestWriteMaster(t *testing.T) {
XLSXPath: "./testdata/",
}
- // defer func() {
- // os.Remove(filepath.Join(opts.MasterOutPutPath, "master.xlsx"))
- // }()
+ defer func() {
+ os.Remove(filepath.Join(opts.MasterOutPutPath, "master.xlsx"))
+ }()
if err := DatamapToDB(&opts); err != nil {
t.Errorf("Unable to write datamap to database file because %v.", err)