-
-
Notifications
You must be signed in to change notification settings - Fork 317
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
Page publishing makes Ingredient::Boolean store String type #2190
Comments
Note: it seems the value |
This is confusing 😕 I just wasn't able to reproduce it locally, but I keep seeing this in production. The If I run the same locally in development ( |
What database are you using locally vs. remotely? Maybe it casts booleans differently?
|
I am using postgres in both environments. I even attached the production database locally to see if I can replicate the issue locally, but no. |
I just attached my production redis locally and let the job be queued with sidekiq and I am seeing the issue now when publishing the page from my local machine (but PublishPageJob processed on production). |
I have tried to isolate the possible options that could cause the issue.
Then, I replay the scenario by saving the element with the Boolean ingredient and publish the Page. And it works fine. 🤷 But if I publish the Page in my production heroku app using the IDENTICAL database, redis and memcache it does NOT work and stores a It must be related to the processing of the Job in heroku, but its not related to the database, redis, memcache. The funny (or sad) part is that I start the sidekiq worker on heroku I checked if I have some strange ENV var set on heroku, but I could not find anything suspicious. It sounds just impossible, but it's true. Any idea what could potentially be different and causing this on heroku? |
Now I've found something, but it doesn't yet help me understand the actual issue... I had a Okay, so that miracle is solved, but the issue with the ingredient for the element of the published Page remains. Note that the value for the Ingredient for the element on the The following 3 scenarios describe the behaviour of the Ingredient attached to the Element that is attached to the published Page:
My conclusion: Right now there is something very strange going on with Boolean ingredients when they are created for the published |
I think this is a form transmission issue: An unticked checkbox is not transmitted by the We can fix this easily by adding an hidden field with the value of |
Ok, that's not it. The hidden field is rendered out properly. Maybe it's how we set the default in the ingredient. |
I cannot reproduce the issue. I created a test in #2192 Feel free to make that test fail so we can reproduce the issue. |
The element/ingredient associated to the Thanks for adding the test. I think, though, since the test is a unit test and covers a creation of the ingredient without a wider context, it does not reflect the Page publishing scenario in which the issue appears to happen. I'll play around with it a bit more. |
I created a branch with a test showcasing the behaviour in a more integrative way using the If you checkout the branch and run the test locally (
The issue The boolean ingredient has a default value defined in elements.yml. I would expect this to be applied on the initial creation of the ingredient, but that is not the case. Funnily, it seems to get applied when the Page gets published and the element/ingredients get copied. The ingredient copy should really be a clone and must not have an altered value. Some other things around this issue to discuss
|
@tvdeyen I just reassigned you just in case you haven't seen my last two comments after you unassigned yourself from the issue. |
@robinboening thanks, but I do not know why the ingredient does not have the default value in your case. As you can see in #2192 the default works just fine.
Yes, I agree. This is a tradeoff. We could look into typecasting the values (like in https://github.com/byroot/activerecord-typedstore). It shouldnt be that hard to roll our own solution using ActiveRecords built in typecasting.
Yeah, I do not like three state booleans as well, but this is also due to the fact that this is a STI table and without type casting we need to deal with. |
Just a heads up here. We are in deed typecasting Boolean (and Date) values of ingredients. But we only do this while reading the value, we should probably typecast the attribute before writing it to the database. |
@robinboening now that #2257 got merged, has this also been fixed? |
I haven't been able to test yet. I'll report back once I got to it. |
This issue has not seen any activity in a long time. |
This issue has not seen any activity in a long time. |
Steps to reproduce
el.element.ingredient_by_type(:boolean)[:value]
in the element viewExpected behavior
The view should render
true
orfalse
, based on the previous user input (ornil
if it was just created without a default)Actual behavior
No matter what the user input was, the view always renders the value
t
(String), hence it always casts totrue
inAlchemy::Ingredients::Boolean#value
.System configuration
6.0.0-rc1
6.1
The text was updated successfully, but these errors were encountered: