Issue with Select Filter for SoftDelete

I’ve implemented a softdelete select filter as specified in your documentation, but when i do certain queries I get an error due to some issues with the sql statement that’s emitted. Example is below:


“42601: syntax error at or near “:””

Sql Statement Emitted:

{SELECT "errortype", Count(*) AS "total" FROM "foo"WHERE (("importid" = $1) AND ("isprocessed" = $2)) AND ("deleted" <> :2)GROUP BY "errortype"}

SoftDelete Setup:

  OrmLiteConfig.SqlExpressionSelectFilter = q =>
            if (q.ModelDef.ModelType.HasInterface(typeof(IBaseModel)))
                q.Where<IBaseModel>(x => x.Deleted != true);


var q = Db.From<Foo>()
            .Where(x => x.ImportId == importId && x.IsProcessed == isProcessed)
            .GroupBy(x => x.ErrorType)
            .Select(x => new { x.ErrorType, Total = Sql.As(Sql.Count("*"), "Total") });

        return Db.Dictionary<int, long>(q);

What database are you using and are you using multiple databases in the same project?

Single database project using postgresql.

I’ve added a fix for an issue I’ve found when trying to reproduce this in this commit. I’m not sure if it resolves this issue which was failing with a different Exception which I was unable to reproduce. Can you try the latest v5.0.3 available on MyGet and let me know if it resolves it. If you had v5.0.3 installed previously you’ll need to clear your NuGet cache:

$ nuget locals all -clear

If the issue persists can you provide a stand-alone example I can run to repro the issue.

Looks like this fixed it thanks!

1 Like