Skip to content

Boolean filters don't work #124

@bergice

Description

@bergice

Issue

It seems like this module is unable to filter using the ORM on boolean fields unless you pass an int to the filter.
This is the error that is triggered when passing a boolean:

SilverStripe\ORM\Connect\DatabaseException: Couldn't run query:
SELECT DISTINCT "LoginSession"."ClassName", "LoginSession"."LastEdited", "LoginSession"."Created", "LoginSession"."LastAccessed", "LoginSession"."IPAddress", "LoginSession"."UserAgent", "LoginSession"."Persistent", "LoginSession"."MemberID", "LoginSession"."ID", 
			CASE WHEN "LoginSession"."ClassName" IS NOT NULL THEN "LoginSession"."ClassName"
			ELSE  E'SilverStripe\\SessionManager\\Model\\LoginSession' END AS "RecordClassName"
FROM "LoginSession"
WHERE ("LoginSession"."LastAccessed" < $1)
 AND ("LoginSession"."Persistent" = $2)
ORDER BY "LoginSession"."LastAccessed" DESC
ERROR:  invalid input syntax for integer: ""

Failing travis build: https://travis-ci.com/github/silverstripe/silverstripe-session-manager/jobs/482489500

Steps to Replicate

  1. Use PostgreSQL with SilverStripe
  2. Execute the following code somewhere on a DataObject with a boolean column:
MyDataObject::get()->filter([
    'MyBooleanDBField' => true
]);

Expected Outcome

Booleans can be used with ORM filtering.

Version

2.3.1

Related issues

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions