Jump to content

Checking for later added checkbox field


thomas
 Share

Recommended Posts

Hello,

I have about 1000 articles and now added a checkbox to the template (I know it's a bit late but sometimes problems arise where you don't expect them ...)

Now I can't seem to check for "not checked". Neither field=0 nor field<1 nor field!=1 yield any results. Only field=1 works but that's not really what I want. 

Maybe a DB expert can help?

Thanks,

thomas

Link to comment
Share on other sites

Hello Soma,

not sure about your second sentence ...

my checkbox field is called "is_private" ... the DB table field_is_private holds 3 entries with data "1", the ones I checked.

Now I try to select the ones which aren't checked:

$pages->find("template=video,is_private!=1")
$pages->find("template=video,is_private=0")
$pages->find("template=video,is_private<1")

... no results. The resulting MySQL query has no results either:


SELECT pages.id,pages.parent_id,pages.templates_id FROM `pages` 
JOIN field_is_private AS field_is_private ON field_is_private.pages_id=pages.id AND (((field_is_private.data!='1' ) )) 
LEFT JOIN pages_access ON (pages_access.pages_id=pages.id AND pages_access.templates_id IN(2,3)) 
WHERE (pages.templates_id=43) AND (pages.status<1024) AND pages_access.pages_id IS NULL AND pages.templates_id NOT IN(2,3) GROUP BY pages.id ORDER BY pages.created DESC

I'm not too good in MySQL but I guess that's because those entries simply don't exist. So they are neither "0" nor "not 1" nor "lower than 1" ...

Hope that clarifies my problem.

Thanks,

thomas

Link to comment
Share on other sites

Are you running the latest dev version? There are some selector bugs fixed there so I'd suggest you try that first.

I'm on a mobile now but I can check tomorrow if there are changes affecting this. Unless someone else gets there first :).

Link to comment
Share on other sites

Have tried no value? field=

Yes I tried it and there are results!

But here's the weird part: As soon as I do this, unpublished pages show up in the results. Sounds odd, but it's true! The resulting MySQL query is this:

SELECT SQL_CALC_FOUND_ROWS pages.id,pages.status,pages.parent_id,pages.templates_id FROM `pages` LEFT JOIN field_is_private ON field_is_private.pages_id=pages.id LEFT JOIN pages_access ON (pages_access.pages_id=pages.id AND pages_access.templates_id IN(2,3)) WHERE (pages.templates_id=43) AND field_is_private.pages_id IS NULL OR field_is_private.data='0' AND (pages.status<1024) AND pages_access.pages_id IS NULL AND pages.templates_id NOT IN(2,3) GROUP BY pages.id ORDER BY pages.created DESC 

with the important part being this:

[...]AND field_is_private.pages_id IS NULL OR field_is_private.data='0' AND (pages.status<1024)[...]

NOw if I add a set of paranthesis like so:

[...]AND (field_is_private.pages_id IS NULL OR field_is_private.data='0') AND (pages.status<1024)[...]

it works perfect, at least for my case. Bug?

Thanks,

thomas

  • Like 1
Link to comment
Share on other sites

It's sure sounds like a bug. I think it's best if you filed this as an issue on GitHub. That way it definitely gets the attention it needs from Ryan.

And I'm going to try and make the test suite cover at least some basic access checks as well.

  • Like 3
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...