j256 / ormlite-android

ORMLite Android functionality used in conjunction with ormlite-core
http://ormlite.com/
ISC License
1.59k stars 366 forks source link

android ,执行update操作,总是返回0 #114

Closed geolo123 closed 2 years ago

geolo123 commented 4 years ago

dao.updateBuilder.update() always return 0

int result; try { stmt = db.compileStatement("SELECT CHANGES()"); result = (int)stmt.simpleQueryForLong(); } catch (android.database.SQLException var11) { result = 1; } finally { if (stmt != null) { stmt.close(); } always return 0;

geolo123 commented 4 years ago

image

Gradle: com.tencent.wcdb:wcdb-android:1.0.8@aar com.tencent.wcdb.database SQLiteDatabase execSQL(String) executeSql(sql, null, null); execSQL(String, Object[]) executeSql(sql, bindArgs, null); execSQL(String, Object[], CancellationSignal) executeSql(sql, bindArgs, cancellationSignal);

跟踪了代码,这几个接口,都设置成void类型; 导致 原本调用 JNI的 nativeExecuteForChangedRowCount 接口 返回的 int 给过滤掉了;

想问,还有其他的update方式,可以获取到正确的 changed Rows value 吗?

j256 commented 4 years ago

I'm sorry, is there a test that you can show? Can you show an example instead of the ormlite code?

WonShaw commented 2 years ago

check this PR: #131 , hope it helps.

j256 commented 2 years ago

Fixed in 7b0467ee0b63b7a65d748ceca5495885cbc8a1de.