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

查询bug,有时候查询不到。 #661

Closed
Moster1h opened this issue Sep 27, 2020 · 6 comments
Closed

查询bug,有时候查询不到。 #661

Moster1h opened this issue Sep 27, 2020 · 6 comments

Comments

@Moster1h
Copy link

Moster1h commented Sep 27, 2020

数据库中存在这一条数据,但是打开应用有时候可以查询得到,有时候查询不到。关键是查询的是用户的登录信息,导致有的用户已经登录了,但是关闭应用重新打开应用又需要登录,这导致很多用户说我窃取他们的信息,真的好坑,查询也是最简单的。

public LoginUserModel getSelectedLoginUser() {
        try {
            return LitePal.where("isSelected=1").findFirst(LoginUserModel.class);
        } catch (Exception e) {
            e.printStackTrace();
        }
        return null;
    }

image

@guolindev
Copy link
Owner

你可以使用LitePal.findAll(LoginUserModel.class)试一试把整张表中的数据都查询出来,看一看里面的数据有没有isSelected是等于1的,我感觉还是因为条件指定的原因导致没能正常查询到数据,我按你写的这种场景又去做了下测试也都是正常的。

@guolindev
Copy link
Owner

表示不能理解,数据库的查询跟SharedPreferences有什么关系,如果你可以把测试demo提供给我最好,可以放到百度网盘里然后给我个链接吗?

@Moster1h
Copy link
Author

具体原因不是很清楚,简单的demo无法复现。但是去掉那段sp的代码,就好了。没有去掉sp代码之前,大概十几次就有一次查询不到。

@guolindev
Copy link
Owner

那查询不到的这次,是单单where("isSelected=1")这个条件下查询不到,还是整张表的所有数据都查询不到?

@Moster1h
Copy link
Author

这个没有尝试过,不过我去掉了sp的那段代码之后,就好了。这个问题有必要关吗?

@guolindev
Copy link
Owner

不知道啊,因为你说的这个情况太玄乎了,我甚至不能判断这是不是一个系统的bug。

既然这个bug不会再出现,那么我就先把这个issue关掉了,如果你又可以重现这个bug了,那么请再把这个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

2 participants