You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
cursor.getInt() method can't return the right value of column that defined as TEXT #244
When the column is defined as TEXT,I found that cursor.getInt() method can't return the right value of that column.
I repreduced this issue with the SQLCipher for Android test suite. Condition: the value of the text should be larger than 10 Procedure:Change the value of the 'a' column from 5 to 500 in the TextAsIntegerTest.java file, then run the Tests,and the Text as integer Test will be failed.
It seems that corsor.getInt() just return the value of the first character in the Text.
Thank you for clarifying the issue. I have just pushed up some changes to address this, including new binaries within the SQLCipher for Android test suite. Would you give those a try and let me know your results? Thanks!
Hi @developernotes
I have tried the latest SQLCipher for Android test suite.Every test works very well and the result is OK.
I think this issue had been solved.Thanks for your correction.
Waiting for the release.
This issue still happens for us as well. We have a large database with about 45 columns. One of them (I think the 5th? 6th?) is a TEXT column but getInt() on it doesn't work correctly.
Would you create a reproducible test in the test suite so we can further investigate? The tests that we have for this specific issue are unable to highlight the behavior you are seeing. Thanks!
I'm actually having great difficulty creating a test case - no matter what I try, in the test the correct value is returned from the row. Interestingly enough, getBlob() returns the same bytes on both the test and the real app - but the real app has some stuff appended to the end of the number (for example, if the column value is the string "15", getInt() returns 157 but getBlob() returns the correct UTF-16 bytes for the string "15" [49, 0, 53, 0]).
The best I can think is that this is some UTF-16 conversion issue and in the main app there's some locale changes being done by the app that are not being done in the test. I noticed that in CursorWindow.cpp there's two different ways that a string is being generated:
in getLong_native, a Java String is being generated from the field data by the single line:
jstring data = env->NewString((const jchar*)window->offsetToPtr(field.data.buffer.offset), (jsize)size);
but in getString_native, the following code is used:
I'm not sure why the code is different, since both instances are supposed to be used to create a Java String from the field data. The final use of the string is different of course, one is returned to the caller and one is used to extract UTF-8 characters and then discarded.
I suspect this is where the discrepancy is occurring but I don't have the setup right now to do NDK debugging to confirm.
We believe we may have pinpointed the issue, however not having a test scenario makes it difficult to verify. Would you mind contacting us directly at support@zetetic.net and we can provide you with a direct build to test on your end? Thanks!
Activity
developernotes commentedon Jul 6, 2016
Hello @liuzhihuinb,
Thank you for clarifying the issue. I have just pushed up some changes to address this, including new binaries within the SQLCipher for Android test suite. Would you give those a try and let me know your results? Thanks!
CoconutByte commentedon Jul 7, 2016
Hi @developernotes
I have tried the latest SQLCipher for Android test suite.Every test works very well and the result is OK.
I think this issue had been solved.Thanks for your correction.
Waiting for the release.
jcb316733855 commentedon Jul 22, 2016
i have met the same issue, the save value is 1, but the query result is 10, if the column define as Integer this will ok
developernotes commentedon Jul 22, 2016
Hello @jcb316733855
What version of SQLCipher for Android are you using? We addressed this issue in the 3.5.2 release.
jcb316733855 commentedon Jul 23, 2016
the version is 3.5.2
developernotes commentedon Jul 25, 2016
Hi @jcb316733855
Are you able to reproduce it with the test suite? It appears to work correctly for me:
draak567 commentedon Jul 25, 2016
This issue still happens for us as well. We have a large database with about 45 columns. One of them (I think the 5th? 6th?) is a TEXT column but getInt() on it doesn't work correctly.
developernotes commentedon Jul 25, 2016
Hello @draak567
Would you create a reproducible test in the test suite so we can further investigate? The tests that we have for this specific issue are unable to highlight the behavior you are seeing. Thanks!
draak567 commentedon Jul 25, 2016
I'm actually having great difficulty creating a test case - no matter what I try, in the test the correct value is returned from the row. Interestingly enough, getBlob() returns the same bytes on both the test and the real app - but the real app has some stuff appended to the end of the number (for example, if the column value is the string "15", getInt() returns 157 but getBlob() returns the correct UTF-16 bytes for the string "15" [49, 0, 53, 0]).
The best I can think is that this is some UTF-16 conversion issue and in the main app there's some locale changes being done by the app that are not being done in the test. I noticed that in CursorWindow.cpp there's two different ways that a string is being generated:
in getLong_native, a Java String is being generated from the field data by the single line:
jstring data = env->NewString((const jchar*)window->offsetToPtr(field.data.buffer.offset), (jsize)size);but in getString_native, the following code is used:
I'm not sure why the code is different, since both instances are supposed to be used to create a Java String from the field data. The final use of the string is different of course, one is returned to the caller and one is used to extract UTF-8 characters and then discarded.
I suspect this is where the discrepancy is occurring but I don't have the setup right now to do NDK debugging to confirm.
developernotes commentedon Jul 26, 2016
Hello @draak567
We believe we may have pinpointed the issue, however not having a test scenario makes it difficult to verify. Would you mind contacting us directly at support@zetetic.net and we can provide you with a direct build to test on your end? Thanks!
CoconutByte commentedon Jul 27, 2016
Hi @developernotes
I reproduced this issue with the following code in the test suite.The Text as Integer test will be failed
database.execSQL("create table t1(a TEXT,b TEXT);");
database.execSQL("insert into t1(a,b) values(500,500);");
Cursor cursor = database.rawQuery("select * from t1;", new String[]{});
if(cursor != null){
cursor.moveToFirst();
long value = cursor.getLong(0);
return value == 500;
}
developernotes commentedon Jul 27, 2016
Hello @liuzhihuinb, @draak567,
Thank you for your help diagnosing this specific over read issue. We had addressed the issue in the source and published a new version, 3.5.3. Thanks!