From d0fff8be36fd2b81262f64158359af448ce2dc92 Mon Sep 17 00:00:00 2001 From: Benoit Larroque Date: Fri, 2 Apr 2010 18:29:41 +0200 Subject: [PATCH] very basic select --- XMLConnection.go | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/XMLConnection.go b/XMLConnection.go index ad65a2e..698b871 100644 --- a/XMLConnection.go +++ b/XMLConnection.go @@ -145,6 +145,7 @@ func (e *XMLConnector) init() { } } +func (e *XMLConnector) Commit() { e.commit() } func (e *XMLConnector) commit() { e.db.Seek(0, 0) e.db.Truncate(0) @@ -243,8 +244,24 @@ func (e *XMLTable) Insert(val map[string]Value) { e.data.Push(val) } +func min(a,b int) int {if (a > b ) { return b}; return a } + func (e *XMLConnector) Query(r *Relation) *vector.Vector { - return new(vector.Vector) + ret := new(vector.Vector) + + + fmt.Println(r) + switch r.kind { + case SELECT: + dat := e.tables[r.table].data + limit:=0 + if(r.limit_count > 0 ){ limit=r.limit_offset+r.limit_count } + limit=min(limit,dat.Len()) + for i:=r.limit_offset; i < limit ; i++ { + ret.Push(dat.At(i)) + } + } + return ret } func OpenXML(conStr string) Connection {