question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

SQLiteDoneException when doing select().count() on empty table

See original GitHub issue
    long numpoints = new Select().from(ResponsePointData.class).count();

I expected that to do SELECT COUNT(*) FROM ResponsePointData

should probably just return 0 instead of throwing an error…

Issue Analytics

  • State:closed
  • Created 8 years ago
  • Reactions:2
  • Comments:8 (8 by maintainers)

github_iconTop GitHub Comments

6reactions
agrosnercommented, Oct 29, 2015

oooo now I see it.

new Select().from(ResponsePointData.class).count()

should be:

new Select().count().from(ResponsePointData.class).count()

In 3.0 this query is a little more straightforward:

new Select(Method.count()).from(ResponsePointData.class).count();

so Method.count() is an actual method of COUNT(*)

0reactions
agrosnercommented, Nov 15, 2015

Added a SQLite.selectCountOf() method to make it easier/more clear.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Why count doesn't return 0 on empty table - Stack Overflow
just a thought: select ID from #empty_table will only return a result row, if the table has at least one row, however, select...
Read more >
SQLiteStatement.simpleQueryForLong - Java - Tabnine
@Test public void simpleQueryTest() throws Exception { SQLiteStatement stmt = database.compileStatement("SELECT count(*) FROM `countme`"); assertThat(stmt.
Read more >
SQLite Android Bindings: SQLiteStatement.java at tip
executeForLastInsertedRowId( getSql(), getBindArgs(), getConnectionFlags() ... For example, SELECT COUNT(*) FROM table; * * @return The result of the query.
Read more >
Poor Performance on SELECT COUNT(*) from empty table ...
Hi @ all, after inserting a large no. of rows (> 100.000.000) into a table and deleting them at the same time, the...
Read more >
SQLiteDatabase | Android Developers
Execute a single SQL statement that is NOT a SELECT/INSERT/UPDATE/DELETE. ... Using this flag is more efficient than calling enableWriteAheadLogging() .
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found