litesuits / litesuits/android-lite-orm

更新数据失败

Open
#64 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Java
Stars
1.5k
Forks
359
PR merge metrics
No merged PRs in 30d

Description

日志如下:
06-14 11:15:48.229 22355-22355/com.xiaonengtech.ttwk.debug D/SQLStatement: SQL Execute: [UPDATE com_xiaonengtech_ttwk_api_type_Video SET is_publish=? WHERE uuid] ARGS--> [1, 481567e3-ef42-4766-8268-2c26fb78bad9]
06-14 11:15:48.231 22355-22355/com.xiaonengtech.ttwk.debug W/System.err: java.lang.IllegalArgumentException: Cannot bind argument at index 2 because the index is out of range. The statement has 1 parameters.
06-14 11:15:48.233 22355-22355/com.xiaonengtech.ttwk.debug W/System.err: at android.database.sqlite.SQLiteProgram.bind(SQLiteProgram.java:212)
06-14 11:15:48.233 22355-22355/com.xiaonengtech.ttwk.debug W/System.err: at android.database.sqlite.SQLiteProgram.bindString(SQLiteProgram.java:166)
06-14 11:15:48.233 22355-22355/com.xiaonengtech.ttwk.debug W/System.err: at com.litesuits.orm.db.assit.SQLStatement.bind(SQLStatement.java:65)
06-14 11:15:48.233 22355-22355/com.xiaonengtech.ttwk.debug W/System.err: at com.litesuits.orm.db.assit.SQLStatement.execUpdateWithMapping(SQLStatement.java:211)
06-14 11:15:48.233 22355-22355/com.xiaonengtech.ttwk.debug W/System.err: at com.litesuits.orm.db.assit.SQLStatement.execUpdate(SQLStatement.java:200)
06-14 11:15:48.233 22355-22355/com.xiaonengtech.ttwk.debug W/System.err: at com.litesuits.orm.LiteOrm.update(LiteOrm.java:298)
06-14 11:15:48.233 22355-22355/com.xiaonengtech.ttwk.debug W/System.err: at com.xiaonengtech.ttwk.view.fragments.PublishVideoFragment.publishCallback(PublishVideoFragment.java:187)
06-14 11:15:48.233 22355-22355/com.xiaonengtech.ttwk.debug W/System.err: at com.xiaonengtech.ttwk.presenter.PublishVideoPresenterImpl$1.accept(PublishVideoPresenterImpl.java:103)
06-14 11:15:48.233 22355-22355/com.xiaonengtech.ttwk.debug W/System.err: at com.xiaonengtech.ttwk.presenter.PublishVideoPresenterImpl$1.accept(PublishVideoPresenterImpl.java:99)
06-14 11:15:48.233 22355-22355/com.xiaonengtech.ttwk.debug W/System.err: at io.reactivex.internal.subscribers.LambdaSubscriber.onNext(LambdaSubscriber.java:61)
06-14 11:15:48.233 22355-22355/com.xiaonengtech.ttwk.debug W/System.err: at io.reactivex.internal.operators.flowable.FlowableObserveOn$ObserveOnSubscriber.runAsync(FlowableObserveOn.java:400)
06-14 11:15:48.233 22355-22355/com.xiaonengtech.ttwk.debug W/System.err: at io.reactivex.internal.operators.flowable.FlowableObserveOn$BaseObserveOnSubscriber.run(FlowableObserveOn.java:176)
06-14 11:15:48.233 22355-22355/com.xiaonengtech.ttwk.debug W/System.err: at io.reactivex.android.schedulers.HandlerScheduler$ScheduledRunnable.run(HandlerScheduler.java:109)
06-14 11:15:48.233 22355-22355/com.xiaonengtech.ttwk.debug W/System.err: at android.os.Handler.handleCallback(Handler.java:815)
06-14 11:15:48.233 22355-22355/com.xiaonengtech.ttwk.debug W/System.err: at android.os.Handler.dispatchMessage(Handler.java:104)
06-14 11:15:48.233 22355-22355/com.xiaonengtech.ttwk.debug W/System.err: at android.os.Looper.loop(Looper.java:194)
06-14 11:15:48.233 22355-22355/com.xiaonengtech.ttwk.debug W/System.err: at android.app.ActivityThread.main(ActivityThread.java:5556)
06-14 11:15:48.233 22355-22355/com.xiaonengtech.ttwk.debug W/System.err: at java.lang.reflect.Method.invoke(Native Method)
06-14 11:15:48.233 22355-22355/com.xiaonengtech.ttwk.debug W/System.err: at java.lang.reflect.Method.invoke(Method.java:372)
06-14 11:15:48.233 22355-22355/com.xiaonengtech.ttwk.debug W/System.err: at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:967)
06-14 11:15:48.233 22355-22355/com.xiaonengtech.ttwk.debug W/System.err: at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:762)
06-14 11:15:48.238 22355-22355/com.xiaonengtech.ttwk.debug E/PRETTYLOGGER: ╔════════════════════════════════════════════════════════════════════════════════════════
06-14 11:15:48.238 22355-22355/com.xiaonengtech.ttwk.debug E/PRETTYLOGGER: ║ Thread: main
06-14 11:15:48.238 22355-22355/com.xiaonengtech.ttwk.debug E/PRETTYLOGGER: ╟────────────────────────────────────────────────────────────────────────────────────────
06-14 11:15:48.239 22355-22355/com.xiaonengtech.ttwk.debug E/PRETTYLOGGER: ║ PublishVideoPresenterImpl$1.accept (PublishVideoPresenterImpl.java:103)
06-14 11:15:48.239 22355-22355/com.xiaonengtech.ttwk.debug E/PRETTYLOGGER: ║ PublishVideoFragment.publishCallback (PublishVideoFragment.java:191)
06-14 11:15:48.239 22355-22355/com.xiaonengtech.ttwk.debug E/PRETTYLOGGER: ╟────────────────────────────────────────────────────────────────────────────────────────
06-14 11:15:48.239 22355-22355/com.xiaonengtech.ttwk.debug E/PRETTYLOGGER: ║ update success is false
06-14 11:15:48.239 22355-22355/com.xiaonengtech.ttwk.debug E/PRETTYLOGGER: ╚════════════════════════════════════════════════════════════════════════════════════════

更新代码:
String uuid = getArguments().getString("uuid");

ColumnsValue columnsValue = new ColumnsValue(new String[]{"is_publish"}, new Object[]{1});
int update = Stores.db.update(
WhereBuilder.create(Video.class)
.where("uuid", uuid)
, columnsValue, ConflictAlgorithm.None);
Logger.e("update success is " + String.valueOf(update != -1));

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the update call in PublishVideoFragment.java:187 and trace it through LiteOrm.java:298 to SQLStatement.java:65, 200, and 211. Reproduce the update using the shown uuid and inspect the generated SQL and bound arguments. Done means the update no longer raises the SQLite parameter-index exception and reports a successful update.

Written by the indexing model from the issue text.

Assessment

Tech stack
android, java, sqlite
Domain
database, mobile-dev
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.