aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatthew Lemon <lemon@matthewlemon.com>2020-08-01 08:25:59 +0100
committerMatthew Lemon <lemon@matthewlemon.com>2020-08-01 08:25:59 +0100
commit875434e637fa37c62903b15922fc3f1e1b01807a (patch)
tree954528e8c12c3b742630ff431898b4bf50d8fda8
parent7bbc32eff827ad28d5d3c4a69b3fb30fa1bd1572 (diff)
fixed test and remove prepare
-rw-r--r--pkg/datamaps/writer.go14
-rw-r--r--pkg/datamaps/writer_test.go2
2 files changed, 7 insertions, 9 deletions
diff --git a/pkg/datamaps/writer.go b/pkg/datamaps/writer.go
index 5f3790f..d6cf8b9 100644
--- a/pkg/datamaps/writer.go
+++ b/pkg/datamaps/writer.go
@@ -2,7 +2,6 @@ package datamaps
import (
"database/sql"
- "fmt"
"log"
"path/filepath"
@@ -56,18 +55,17 @@ func ExportMaster(opts *Options) error {
WHERE datamap.name=? AND return.name=? AND datamap_line.key=?
GROUP BY datamap_line.key;`
- rowCountStmt, err := db.Prepare(sqlCount)
+ var rowCount int64
+ rowCountRes := db.QueryRow(sqlCount, opts.DMName, opts.ReturnName, targetKey)
if err != nil {
return err
}
- defer rowCountStmt.Close()
-
- var rowCount int64
- _ = rowCountStmt.QueryRow(opts.DMName, opts.ReturnName, targetKey).Scan(&rowCount)
- fmt.Println(rowCount)
+ if err := rowCountRes.Scan(&rowCount); err != nil {
+ return err
+ }
- _ = `SELECT datamap_line.key, return_data.value, return_data.filename
+ getDataSQL := `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)
diff --git a/pkg/datamaps/writer_test.go b/pkg/datamaps/writer_test.go
index da9dc9d..4be87d9 100644
--- a/pkg/datamaps/writer_test.go
+++ b/pkg/datamaps/writer_test.go
@@ -22,7 +22,7 @@ func TestWriteMaster(t *testing.T) {
opts := Options{
DBPath: "./testdata/test.db",
DMName: "First Datamap",
- DMPath: "./testdata/datamap.csv",
+ DMPath: "./testdata/datamap_matches_test_template.csv",
ReturnName: "Unnamed Return",
MasterOutPutPath: "./testdata/",
XLSXPath: "./testdata/",