Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Affected rows is -1 #1

Closed
amjith opened this issue Jul 20, 2018 · 8 comments
Closed

Affected rows is -1 #1

amjith opened this issue Jul 20, 2018 · 8 comments

Comments

@amjith
Copy link
Member

amjith commented Jul 20, 2018

Create table results displays -1 as affected rows.

sqlite3 amjith::memory:> create table foo (id integer, name varchar);
Query OK, -1 rows affected
@delgermurun
Copy link
Member

@amjith How about replacing -1 with 0 :) ?

drop table foo returns -1 too. mycli returns 0 on both queries.

@amjith
Copy link
Member Author

amjith commented Jul 24, 2018

Replacing it with zero sounds fine. I just want to understand why it returns -1. Is that a latent bug in our code or is the sqlite connector behaving badly?

@delgermurun
Copy link
Member

Not our code's bug. sqlite3 library returns rowcount=-1 and cursor.fetchall() returns [] empty list.

@amjith
Copy link
Member Author

amjith commented Jul 24, 2018

If the rowcount is unreliable from the sqlite3 library let's not use it at all. We'll just rely on our own counting to report that number.

@delgermurun
Copy link
Member

Okay. Got it.

@delgermurun
Copy link
Member

insert, delete queries return correct row count while cursor.fetchall() returns []. So we need to use rowcount for those case, I think.

@delgermurun
Copy link
Member

@amjith I pushed little fix.

@amjith
Copy link
Member Author

amjith commented Aug 4, 2018

Works great!

@amjith amjith closed this as completed Aug 4, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants