lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


On 18/06/2015, at 4:51 pm, Coda Highland <chighland@gmail.com> wrote:
> 
> If you're going to mark one for arrays too, then instead of calling it
> rows() you could call it results() or something, such that you don't
> actually invoke the database API until you've selected the appropriate
> output form.

I quite like the idea results():values(), but I’m having trouble working out if it's practical.

First, by the time you call the existing rows(), you’re pretty committed to invoking the DB API, so there doesn’t seem much point putting it off.

Second, what does results() return?  Another object that’s really just there to make things look pretty?  It’s probably a good idea to avoid excess objects?

And then, there’s not just a row api, there’s a single (or no) result exec which just return values, not an iterator so there’s twice as many cases, and the sql can be an argument, as can arguments to the sql:

for name in db:results(“SELECT name FROM table WHERE id = :1”, 20):values() do…

I s’pose it could work?