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

Exception thrown after the content type is changed #98

Closed
barteo opened this issue Sep 15, 2015 · 11 comments
Closed

Exception thrown after the content type is changed #98

barteo opened this issue Sep 15, 2015 · 11 comments

Comments

@barteo
Copy link

barteo commented Sep 15, 2015

I added a new field into existing content type. Model object was updated to reflect this field. Also I had previously many entries created for this content type. I got then the following exception in ModelHelper of that content type (fromCursor method):

Caused by: java.lang.IllegalStateException: Couldn't read row 0, col 6 from CursorWindow. Make sure the Cursor is initialized correctly before accessing data from it. at android.database.CursorWindow.nativeGetString(Native Method) at android.database.CursorWindow.getString(CursorWindow.java:438) at android.database.AbstractWindowedCursor.getString(AbstractWindowedCursor.java:51)

I think a null check should be added somewhere inside the appendFromCursor method of com.contentful.vault.compiler.ModelInjection class.

@tomxor
Copy link
Contributor

tomxor commented Sep 15, 2015

Can you please post the entire stacktrace?

@tomxor
Copy link
Contributor

tomxor commented Sep 15, 2015

This probably happens due to #97 - since the upgrade process fails (at runtime), the generated code does not correspond to your schema.

@barteo
Copy link
Author

barteo commented Sep 15, 2015

Rest of the stacktrace:

at a.b.c.Obj$$ModelHelper.fromCursor(Obj$$ModelHelper.java:49) at a.b.c.Obj$$ModelHelper.fromCursor(Obj$$ModelHelper.java:11) at com.contentful.vault.SqliteHelper.fromCursor(SqliteHelper.java:145) at com.contentful.vault.QueryResolver.all(QueryResolver.java:51) at com.contentful.vault.FetchQuery.resolveAll(FetchQuery.java:30) at com.contentful.vault.FetchQuery.resolveFirst(FetchQuery.java:37) at com.contentful.vault.LinkResolver.resourceForLink(LinkResolver.java:197) at com.contentful.vault.LinkResolver.getCachedResourceOrFetch(LinkResolver.java:96) at com.contentful.vault.LinkResolver.resolveLinksForField(LinkResolver.java:67) at com.contentful.vault.LinkResolver.resolveLinks(LinkResolver.java:55) at com.contentful.vault.LinkResolver.getCachedResourceOrFetch(LinkResolver.java:100) at com.contentful.vault.LinkResolver.resolveLinksForField(LinkResolver.java:67) at com.contentful.vault.LinkResolver.resolveLinks(LinkResolver.java:55) at com.contentful.vault.LinkResolver.getCachedResourceOrFetch(LinkResolver.java:100) at com.contentful.vault.LinkResolver.resolveLinksForField(LinkResolver.java:67) at com.contentful.vault.LinkResolver.resolveLinks(LinkResolver.java:55) at com.contentful.vault.QueryResolver.resolveLinks(QueryResolver.java:80) at com.contentful.vault.QueryResolver.all(QueryResolver.java:64) at com.contentful.vault.FetchQuery.resolveAll(FetchQuery.java:30) at com.contentful.vault.FetchQuery.resolveFirst(FetchQuery.java:37) at com.contentful.vault.FetchQuery.first(FetchQuery.java:57) at com.contentful.vault.FetchQuery.first(FetchQuery.java:53)

This is trigerred by executing the following code:
Vault.with(this, TestSpace.class).fetch(Obj.class).where("name = ?", name).first();

@barteo
Copy link
Author

barteo commented Sep 15, 2015

This probably happens due to #97 - since the upgrade process fails (at runtime), the generated code does not correspond to your schema.

No, this problem happened with freshly downloaded schema (empty local db before sync).

@tomxor
Copy link
Contributor

tomxor commented Sep 15, 2015

What do you mean by freshly downloaded schema? if the model existed and you've changed it, it is likely that a vault db (even though empty) existed beforehand. You can easily confirm this by simply uninstalling+reinstalling the app, and checking if the exception still happens.

@barteo
Copy link
Author

barteo commented Sep 15, 2015

I meant app was removed on device and then freshly installed. I also just noticed this happens when there is no data from contentful synced yet.

@tomxor
Copy link
Contributor

tomxor commented Sep 15, 2015

Can you provide a sample project where this issue reproduces?

@barteo
Copy link
Author

barteo commented Sep 15, 2015

We probably need to work on the same contentful dataset. Maybe it will be easier if we move discussion to the priv?

@tomxor
Copy link
Contributor

tomxor commented Sep 15, 2015

👍 please ping support@contentful.com, I'll pull the ticket once you do. Thanks!

@barteo
Copy link
Author

barteo commented Sep 15, 2015

It seems this problem exists when running on device with Android 6.0 prerelease version. I tried Android 5.1.1 and cannot trigger this exception anymore. I'd bet a new sqlite version on Android 6.0 is the cause.

@tomxor
Copy link
Contributor

tomxor commented Sep 17, 2015

This turned out to be a side effect of #97, causing a state where the generated code does not correspond with the schema. Issue #99 should prevent such things from happening in the future.

@tomxor tomxor closed this as completed Sep 17, 2015
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