-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
Redesign database related shadows #800
Conversation
cc @jberkel |
i think this is the right way forward, there are way too many shadows in the current db code. if it helps it is definitely worth dropping the jdbc layer too - we don't need to support any other databases than sqlite anyway. i wouldn't worry about backwards compatibility, although i don't see how this would be an issue here since the connection is never exposed to the clients? |
As for older Android versions. To illustrate, look at What will we be able to do when Robolectric tests are run with old Android code? AFAIK this is a planned feature (choosing API level to run tests). |
I think this is a great idea. As for compatibility with older versions of Android, I think this is a bridge that can be crossed when we get there. At one point (can't remember how much is still there) we did have some code in the 4.3 work that would do slightly different things on 4.3 and 4.1, so we can certainly come up with a solution. To quote everyone working on Robolectric this year, "Death to shadows!!" |
Ok, then I'll go on with picking some SQLite java wrapper and push here as soon as it is wired. |
I switched to sqlite4java. Working on getting more tests passing... Currently the only function I could not implement with the wrapper is collator creation. |
Why not just use Xerial SQLite JDBC Driver? |
@dant3 That was the first thing I was looking at. Yet it does not seem to fit our needs. |
Am I allowed to remove |
Well, looks like I've finally managed to have all the tests passing. |
I will try to resolve the issue next week but would be grateful if somebody else looked at it too. |
This PR also brings some changes to public Robolectric API. Please review how tests are changed. |
i'll take a look at it soon |
i tried your branch with one of my projects and the native libs got loaded fine (on osx, using maven). however i could not run tests from within intellij - this is fixed in 7dba412 what native platform are you on? i have some more test failures with NPEs in nativeGetLong / nativeGetDouble, investigating at the moment. |
I'm on osx too. I'll try your branch tomorrow. |
I've finally resolved my issue with loading natives. I'm using Gradle and it does not resolve maven dependencies from profile section in POM. http://issues.gradle.org/browse/GRADLE-1997 So I'm currently trying this branch with a project which I was working on some time ago. And in this project there are some tests that run query operations in an I think I'll make native SQLiteConnection to be a thread local variable (actually Android's SQLiteConnection is thread local too). |
With another project I've worked recently everything works well except the fact that I had to fix |
let's move all the native libraries into one jar file, similar to what xerial-jdbc does. would be good if users don't have to worry about which platform specific dependencies they have to pull in. or does gradle have something similar to mavennatives ? |
<version>3.7.2</version> | ||
<groupId>com.github.axet</groupId> | ||
<artifactId>litedb</artifactId> | ||
<version>0.2.2</version> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
0.2.3 is the latest published version
…ract with shadows) and tests for query methods
…repository) add tests for behavior on different os
…e reset from ShadowSQLiteConnection make a test for use from another thread
De-staticized SQLiteLibaryLoader, added more tests for archs Move version number into property
This case was failing when sqlite-jdbc 3.7.2 was used.
Rebased. Logging muted. |
Redesign database related shadows
hooray! |
Nice job! |
For some reason, the SQLiteLoader tests fail on my MacBook Air, but work fine on the iMacs we have at work. I have no idea why there would be a difference. I'll see if I can track it down and/or post a stacktrace of the failures. |
Removes a lot of shadows connected with
SQLiteDatabase
andCursor
, makes Robolectric behaviour much closer to how real Android behaves.Instead of a bunch of removed shadows we introduce implementations of
SQLiteConntection
andCursorWindow
based on sqlite4java. This approach let us drop a lot of shadowing code and use real Android classes. However both implemented classes belong to a hidden Android API, which means we should be careful when add some new Android API level to what is supported by Robolectric (especially adding 2.x APIs).Worth to mention in release notes:
SQLiteDatabase#openDatabase
opens on-disk database until itspath
parameter is set with":memory:"
value;DatabaseConfig
annotation is goneSQLiteDatabase
:setThrowOnInsert
,hasOpenCursors
,getQuerySql
,getConnection
History notes
Some time ago I faced with some inconsistencies in shadows of cursors and started digging first removing shadow of matrix cursor and then...
This request is not a merge candidate right now but rather a proposal.
I'm playing with removing cursor shadows completely and shadowing only
SQLiteConnection
andCursorWindow
instead (ShadowSQLiteConnection, ShadowCursorWindow).I've already made some progress in this direction and have some of database related tests passing. And now I'd like someone from the main team to take a look at the approach and start discussion. Perhaps it's not the way worth to be implemented.
Currently I have 2 main points that do not allow me to sleep sweetly:
SQLiteConnection
belongs to hidden API, and I'm not pretty sure what to do with old Android versions.So please take a look and tell what you think: should I go on or would I rather stop, delete this branch, and forget :).