db query builder bugfix and added todo
unit tests up for query builder