diff --git a/all_test.go b/all_test.go index df6b66b..b6138c1 100644 --- a/all_test.go +++ b/all_test.go @@ -276,7 +276,7 @@ func rnds16(rng *rand.Rand, n int) string { return strings.Join(a, "") } -func benchmarkSelect(b *testing.B, n int, sel list, ts testDB) { +func benchmarkSelect(b *testing.B, n int, sel List, ts testDB) { db, err := ts.setup() if err != nil { b.Error(err) @@ -390,7 +390,9 @@ func TestString(t *testing.T) { continue } - _ = l.String() + if s := l.String(); len(s) == 0 { + t.Fatal("List.String() returned empty string") + } } } diff --git a/builtin.go b/builtin.go index 4201842..76d18ca 100644 --- a/builtin.go +++ b/builtin.go @@ -12,7 +12,7 @@ import ( "time" ) -//TODO agg bigint, bigrat, time, duration +//DONE agg bigint, bigrat, time, duration var builtin = map[string]struct { f func([]interface{}, map[interface{}]interface{}) (interface{}, error) diff --git a/ql.go b/ql.go index 79f9dd7..e38d4d0 100644 --- a/ql.go +++ b/ql.go @@ -50,11 +50,12 @@ const ( stCollectingTriggered ) -type list struct { +type List struct { l []stmt } -func (l list) String() string { +// String implements fmt.Stringer +func (l List) String() string { var b bytes.Buffer f := strutil.IndentFormatter(&b, "\t") for _, s := range l.l { @@ -806,13 +807,13 @@ func (db *DB) Run(ctx *TCtx, ql string, arg ...interface{}) (rs []Recordset, ind // DB.Execute or an error if any. // // Compile is safe for concurrent use by multiple goroutines. -func Compile(src string) (list, error) { +func Compile(src string) (List, error) { l := newLexer(src) if yyParse(l) != 0 { - return list{}, l.errs[0] + return List{}, l.errs[0] } - return list{l.list}, nil + return List{l.list}, nil } // MustCompile is like Compile but panics if the ql statements in src cannot be @@ -820,7 +821,7 @@ func Compile(src string) (list, error) { // compiled statement lists for DB.Execute. // // MustCompile is safe for concurrent use by multiple goroutines. -func MustCompile(src string) list { +func MustCompile(src string) List { list, err := Compile(src) if err != nil { panic("ql: Compile(" + strconv.Quote(src) + "): " + err.Error()) // panic ok here @@ -908,7 +909,7 @@ func MustCompile(src string) list { // Durability: Transactions are durable. A two phase commit protocol and a // write ahead log is used. Database is recovered after a crash from the write // ahead log automatically on open. -func (db *DB) Execute(ctx *TCtx, l list, arg ...interface{}) (rs []Recordset, index int, err error) { +func (db *DB) Execute(ctx *TCtx, l List, arg ...interface{}) (rs []Recordset, index int, err error) { tnl0 := -1 var s stmt diff --git a/storage_test.go b/storage_test.go index 5f518b8..e4290c6 100644 --- a/storage_test.go +++ b/storage_test.go @@ -187,7 +187,7 @@ const sample = ` COMMIT; ` -func parse(t *testing.T, src string) (ls list, err error) { +func parse(t *testing.T, src string) (ls List, err error) { //dbg("----\n%s----\n", src) //t.Log(src) @@ -203,7 +203,7 @@ func parse(t *testing.T, src string) (ls list, err error) { return } - return list{l.list}, nil + return List{l.list}, nil } // Test provides a testing facility for alternative storage implementations.