aboutsummaryrefslogtreecommitdiffstats
path: root/pkg/data/get.go
diff options
context:
space:
mode:
authorJP Appel <jeanpierre.appel01@gmail.com>2025-07-28 23:40:23 -0400
committerJP Appel <jeanpierre.appel01@gmail.com>2025-07-28 23:40:23 -0400
commit209af758b64d586e1c0aec3ad2eb4b56740aeddf (patch)
tree61d8fcebabb925456a87671558df035097560329 /pkg/data/get.go
parentf829b01a1c92e788f5114cf66c24856be23ec88f (diff)
Resolve multiple todos
Diffstat (limited to 'pkg/data/get.go')
-rw-r--r--pkg/data/get.go23
1 files changed, 17 insertions, 6 deletions
diff --git a/pkg/data/get.go b/pkg/data/get.go
index 840ca53..396f132 100644
--- a/pkg/data/get.go
+++ b/pkg/data/get.go
@@ -3,13 +3,12 @@ package data
import (
"context"
"database/sql"
+ "fmt"
"time"
"github.com/jpappel/atlas/pkg/index"
)
-// TODO: rename struct
-//
// Use to build a document from a database connection
type Fill struct {
Path string
@@ -18,8 +17,6 @@ type Fill struct {
doc *index.Document
}
-// TODO: rename struct
-//
// Use to build documents and aliases from a database connection
type FillMany struct {
docs map[string]*index.Document
@@ -108,8 +105,22 @@ func (f *FillMany) documents(ctx context.Context, rows *sql.Rows) error {
return err
}
defer rows.Close()
- } else {
- // TODO: check if rows.ColumnTypes() matches expected
+ } else if cols, err := rows.ColumnTypes(); err != nil {
+ return err
+ } else if len(cols) != 6 {
+ return fmt.Errorf("Not enough columns to fill documents with")
+ } else if t := cols[0].DatabaseTypeName(); t != "INTEGER" {
+ return fmt.Errorf("Expected integer for id column fill, got %s", t)
+ } else if t := cols[1].DatabaseTypeName(); t != "TEXT" {
+ return fmt.Errorf("Expected text for path column fill, got %s", t)
+ } else if t := cols[2].DatabaseTypeName(); t != "TEXT" {
+ return fmt.Errorf("Expected text for title column fill, got %s", t)
+ } else if t := cols[3].DatabaseTypeName(); t != "INT" {
+ return fmt.Errorf("Expected integer for date column fill, got %s", t)
+ } else if t := cols[4].DatabaseTypeName(); t != "INT" {
+ return fmt.Errorf("Expected integer for filetime column fill, got %s", t)
+ } else if t := cols[5].DatabaseTypeName(); t != "BLOB" {
+ return fmt.Errorf("Expected text for meta column fill, got %s", t)
}
var id int