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

Boolean filters don't work #124

Open
bergice opened this issue Feb 15, 2021 · 1 comment · May be fixed by silverstripe/silverstripe-framework#9865
Open

Boolean filters don't work #124

bergice opened this issue Feb 15, 2021 · 1 comment · May be fixed by silverstripe/silverstripe-framework#9865

Comments

@bergice
Copy link

bergice commented Feb 15, 2021

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

@maxime-rainville
Copy link
Contributor

Actually, filtering for true works fine for me. It's only false that throws a fit.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants