QueryIterator compiles.
authorMaxime Bourget <bmx007@gmail.com>
Mon, 27 May 2013 18:16:37 +0000 (19:16 +0100)
committerMaxime Bourget <bmx007@gmail.com>
Mon, 27 May 2013 18:16:37 +0000 (19:16 +0100)
haxe/ItemScheduler.hx

index 2ce0fa0783c3874237c4dd99f1e31383c02a2aa1..cec9f27e30439e2dd4329fb320be616594742d5d 100644 (file)
@@ -15,25 +15,28 @@ class QueryIterator<T> {
        }
 
        private function fetch() {
-               var next = untyped __call__('db_fetch', this.result);
+               var next : Dynamic = untyped __call__('db_fetch', this.result);
                this.nextValue = if(next) Just(next) else Nothing;
        }
 
        public function  hasNext() : Bool {
-               return this.next == Nothing;
+               return this.nextValue == Nothing;
        }
 
        public function next() : T {
                switch(this.nextValue) {
                case Nothing : throw 'Iterator exhausted';
-               case Just(v) : return v;
+               case Just(v) :  {
+                       this.fetch();
+                       return v;
+               };
                }
        }
 }
 class FA {
        static public function query(sql: String) {
                var result = untyped __call__('db_query', sql);
-               return QueryIterator(result);
+               return new QueryIterator(result);
        }
 }
 class ItemScheduler {