dlang-community / d2sqlite3

A small wrapper around SQLite for the D programming language
Boost Software License 1.0
75 stars 26 forks source link

Add length property #40

Open FraMecca opened 7 years ago

FraMecca commented 7 years ago

It is useful for test, currently WalkLength pops elements

biozic commented 7 years ago

Sorry, can you elaborate on where you would like to have a length property ?

FraMecca commented 7 years ago

I'd like to have a lenght on ResultEntities instances that could be useful for tests and other conditions. At the current state it is only possible to know if the range is empty or not.

biozic commented 7 years ago

You mean a length property that returns the total number of Rows in a ResultRange, right? There's no API to do that in SQLite: the rows are just stepped over until there is none. You should use SQL for this (or maybe use the deprecated not-recommended sqlite_get_table function).

Robert-M-Muench commented 6 years ago

This can be simulated by using: SELECT count(*) FROM... which gives you the length of the result set. SQLite is pretty quick so the costs are not to high.