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

"Where" clause doesn't work with bool when record is migrated until the record is updated #1245

Open
VNGames opened this issue Jul 21, 2024 · 0 comments

Comments

@VNGames
Copy link

VNGames commented Jul 21, 2024

I have a table

public class FocusSelection
{
    [PrimaryKey, AutoIncrement]
    public int Id { get; set; }
    // some properties
}

I add a record into that table. It is there. Everything is fine. Now to implement a new feature I add the SomeProperty below.

Then update the app version and run it.

public class FocusSelection
{
    [PrimaryKey, AutoIncrement]
    public int Id { get; set; }
    // some properties
    public bool SomeProperty { get; set; }
}

At the very start of the app I execute the code.

await _databaseService.Connection.RunInTransactionAsync(connection => 
{
     // this returns that record with SomeProperty = false as expected
     var all = connection.Table<Models.Database.FocusSelection>().ToList();
     // But this returns 0 records
     var t = connection.Table<Models.Database.FocusSelection>().Where(x => !x.SomeProperty).ToList();
}

And the only way to make query work is to do this

await _databaseService.Connection.RunInTransactionAsync(connection => 
{
     var all = connection.Table<Models.Database.FocusSelection>().ToList();
     // updating records
     all.ForEach(x => connection.Update(x));

     // Now this query works fine
     var t = connection.Table<Models.Database.FocusSelection>().Where(x => !x.SomeProperty).ToList();
}
@VNGames VNGames changed the title Where clause doesn't work with bool when record is migrated until the record is updated "Where" clause doesn't work with bool when record is migrated until the record is updated Jul 21, 2024
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

1 participant