-
Notifications
You must be signed in to change notification settings - Fork 163
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
#421 induced strange behaviour for first transition (not_most_recent_value & db_null methods) #424
Comments
Hey @Paul-Yves, thanks for getting in touch. Yeah, this looks like this was me! I think you may be right with your patch, but I will take a look and we'll see how we can fix this. Was there anything in particular you were doing that caused the issue? Would you be able to provide anything that helps me reproduce it? |
Thank you for answering, I'll try my best : class OrderWorkflowStateMachine
include Statesman::Machine
state :new, initial: true
state :state_1
state :state_2
state :state_3
states.each do |state|
transition from: state, to: states - [state]
end
end and I used a breakpoint when doing Our database is PostgreSQL 10.15 and we use the pg gem. Relevant part of our database scheme would be CREATE TABLE public.order_workflow_transitions (
id bigint NOT NULL,
to_state character varying NOT NULL,
metadata text,
sort_key integer NOT NULL,
order_id bigint NOT NULL,
most_recent boolean,
created_at timestamp without time zone NOT NULL,
updated_at timestamp without time zone NOT NULL
); |
Any news about this ? Couldn't we simply revert to the previous implementation of db_null, since it was not a type casting, the change seems irrelevant to the original issue (deprecation warning) |
hey @Paul-Yves was about to message apologising for not being able to look at this, it's been a busy week. Yes, I'm pretty sure I know the fix, the fix isn't the issue here, my concern is that this wasn't caught by tests. So I want to reproduce it so I can confirm that it fixes it, not only for postgres but for mysql as well. |
Ok, thank you very much for your dedication. |
Quick update, I've managed to reproduce the issue with the script below, and the breaking is case is Postgres + Here is the script I used:
|
hey @Paul-Yves closing this as the PR has been merged, will bump the version shortly |
Thank you for the fix |
When doing a transition, I now (after updating to 8.0.0) have a "no implicit conversion of nil into String" error. I tracked it down to the first transition, inside module Statesman::Adapters::ActiveRecord when not_most_recent_value is null,
db_null
returns nil when it used to return "null" before this PR.I managed to patch this by reverting to the old implementation of
Arel::Nodes::SqlLiteral.new("NULL")
or by copying the methods above with a::ActiveRecord::Base.connection.quote(type_cast(nil))
.The first solutions seemed the most logical since the comment of type_cast says
Type casting against a column is deprecated and will be removed in Rails 6.2.
and the original implementation of db_null did not type cast against a column.However I am not sure to fully understand the situation so I would like to have your inputs before submitting a PR
The text was updated successfully, but these errors were encountered: