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

Unable to add column to table #222

Closed
HannanShaik opened this issue Apr 28, 2014 · 11 comments
Closed

Unable to add column to table #222

HannanShaik opened this issue Apr 28, 2014 · 11 comments

Comments

@HannanShaik
Copy link

Hi Team,

I have a table with below structure.

@table(name="books")
public class Books extends Model {
@column(name = "bookId")
public String bookId;
}

I want to Add a new column. I followed the steps mentioned in https://github.com/pardom/ActiveAndroid/wiki/Schema-migrations. But I am getting the below error:

Caused by: android.database.sqlite.SQLiteException: not an error (code 0)

This happens at My Application class where I am initializing active android.

Please Help.

Thanks.

@vonloxley
Copy link
Contributor

Could we have the full stacktrace and the migration-script, please?

@HannanShaik
Copy link
Author

Hi,

Here is the stack trace.

java.lang.RuntimeException: Unable to create application
com.hannan.delivery.MyApplication:
android.database.sqlite.SQLiteException: not an error (code 0)
at android.app.ActivityThread.handleBindApplication(ActivityThread.java:4154)
at android.app.ActivityThread.access$1300(ActivityThread.java:130)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1255)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:137)
at android.app.ActivityThread.main(ActivityThread.java:4745)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:511)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:786)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)
at dalvik.system.NativeStart.main(Native Method)
Caused by: android.database.sqlite.SQLiteException: not an error (code 0)
at android.database.sqlite.SQLiteConnection.nativeExecuteForChangedRowCount(Native
Method)
at android.database.sqlite.SQLiteConnection.executeForChangedRowCount(SQLiteConnection.java:727)
at android.database.sqlite.SQLiteSession.executeForChangedRowCount(SQLiteSession.java:754)
at android.database.sqlite.SQLiteStatement.executeUpdateDelete(SQLiteStatement.java:64)
at android.database.sqlite.SQLiteDatabase.executeSql(SQLiteDatabase.java:1665)
at android.database.sqlite.SQLiteDatabase.execSQL(SQLiteDatabase.java:1594)
at com.activeandroid.DatabaseHelper.executeSqlScript(DatabaseHelper.java:180)
at com.activeandroid.DatabaseHelper.executeMigrations(DatabaseHelper.java:150)
at com.activeandroid.DatabaseHelper.onUpgrade(DatabaseHelper.java:74)
at android.database.sqlite.SQLiteOpenHelper.getDatabaseLocked(SQLiteOpenHelper.java:257)
at android.database.sqlite.SQLiteOpenHelper.getWritableDatabase(SQLiteOpenHelper.java:164)
at com.activeandroid.Cache.openDatabase(Cache.java:102)
at com.activeandroid.Cache.initialize(Cache.java:75)
at com.activeandroid.ActiveAndroid.initialize(ActiveAndroid.java:44)
at com.activeandroid.ActiveAndroid.initialize(ActiveAndroid.java:34)
at com.activeandroid.ActiveAndroid.initialize(ActiveAndroid.java:30)
at com.activeandroid.app.Application.onCreate(Application.java:25)
at com.hannan.delivery.MyApplication.onCreate(MyApplication.java:51)
at android.app.Instrumentation.callApplicationOnCreate(Instrumentation.java:999)
at android.app.ActivityThread.handleBindApplication(ActivityThread.java:4151)
at android.app.ActivityThread.access$1300(ActivityThread.java:130)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1255)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:137)
at android.app.ActivityThread.main(ActivityThread.java:4745)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:511)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:786)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)
at dalvik.system.NativeStart.main(Native Method)

On Mon, Apr 28, 2014 at 5:54 PM, Niki Hansche notifications@github.comwrote:

Could we have the full stacktrace and the migration-script, please?


Reply to this email directly or view it on GitHubhttps://github.com//issues/222#issuecomment-41551929
.

@HannanShaik
Copy link
Author

Migration Script: (3.sql)
ALTER TABLE books ADD COLUMN bookAuthor TEXT;

Also Tried with
ALTER TABLE books ADD bookAuthor TEXT;

Both are resulting in same error.

@HannanShaik
Copy link
Author

I could also see the below errors:

1553-1553/com.hannan.delivery E/SQLiteLog﹕ (21) API called with NULL prepared statement
1553-1553/com.hannan.delivery E/SQLiteLog﹕ (21) misuse at line 63241 of [00bb9c9ce4]

Please check and let me know what has to be done?

@vonloxley
Copy link
Contributor

Hi HannanShaik!

I’m really sorry, but I couldn’t reproduce this error, which means the error is in your setup, not in ActiveAndroid.

If you want to, you can download http://uploaded.net/file/3zom6ayx
it is a git-bundle called aat. You can clone it with the command git clone /tmp/aat (if you saved it in /tmp). After that you can see what I did using git log -p.
Commit Version 1 is the initial project, Version 2 adds a new column.

@matthew-reilly
Copy link

I'm getting this as well. A fresh install works fine.

Although my scenario is a bit different. When I did my migration, a column would go missing in one of my tables. (I didn't remove it). Trying to add it manually with the migration script would result in this error.

@matthew-reilly
Copy link

Figured it out, I think. Would an empty line (blank space) cause an issue here? One migration script I had did and it failed. I removed it and it seemed to work.

@johnhamelink
Copy link

I also had this issue - the reason is because comments, newlines, and queries broken up across multiple lines are not processed correctly - my guess is because the migration is being ran line-by-line, so multi-line queries fail and comments and spaces become nulls.

@vonloxley
Copy link
Contributor

Please have a look at #215.

@johnhamelink
Copy link

@vonloxley thanks for the heads up, using that tag fixes it for me!

@SleeplessByte
Copy link

@HannanShaik You can now close this issue :)

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

5 participants