Defect #18830
openWorkflow always "current state" not working
0%
Description
Hi guys
I've been having an issue where when I go to edit the workflow, the "always" grid at the top does not show the current state, that is, all of the checkboxes are unticked.
If I tick some of them, and then save, the workflow for the selected tracker and role are updated to only the ones i've ticked, that is, the ones that were ticked no longer apply and the status/workflow transitions that were there are gone.
Of note, I'm using SQL server.
I am not really familiar with ruby/activerecord but I am a .net/windows developer, hence the use of sqlserver (our production SQL is replicated for redundancy so I'd prefer to use this as my dbms)
Reviewing the data in the workflow database table, the records are as I'd expect them to be - with some records having 0 for author and 0 for assignee, and others with the appropriate truthy values in those columns.
Using a SQL subselect insert, I deleted all of the records where author=0 and assignee=0 then re-inserted them, copying them from where author=1 and observed that this made no difference, that is, the data was not the problem.
The schema of the database table shows the author and assignee columns defined as smallint for me, which is not a boolean type in SQL server (this would typically be "bit not null default 0")
The activerecord tests for sqlserver (https://github.com/rails-sqlserver/activerecord-sqlserver-adapter/blob/master/test/cases/specific_schema_test_sqlserver.rb) have an explicit test to ensure that smallint is not treated as a boolean ala mysql, but there is no test for tinyint or bit.
I dumped the contents of the workflows array; defined as follows:
@workflows = {} @workflows['always'] = workflows.select {|w| !w.author && !w.assignee} @workflows['author'] = workflows.select {|w| w.author} @workflows['assignee'] = workflows.select {|w| w.assignee}
with the command <%=@workflows.to_json%>
and observed that the always array was empty, and the author and assignee arrays contained the records where author and assignee contained falsy values.
If I change the workflows code to
@workflows['always'] = workflows.select {|w| w.author==0 && w.assignee==0} @workflows['author'] = workflows.select {|w| w.author==1} @workflows['assignee'] = workflows.select {|w| w.assignee==1}
Then all works as expected - the always grid has the appropriate tickboxes that I would expect by default
This seems to be a boolean/casting issue with sqlserver to me, and may affect other places in the codebase, so I doubt my fix for this one screen is the correct one.
Here are my enviornment details:
@Environment: Redmine version 2.6.1.stable Ruby version 1.9.3-p545 (2014-02-24) [x86_64-linux] Rails version 3.2.21 Environment production Database adapter SQLServer SCM: Subversion 1.8.5 Mercurial 2.0.2 Git 1.8.5.2 Filesystem Redmine plugins: redmine_inline_attach_screenshot 0.4.6 redmine_issue_checklist 2.0.5
Updated by Gareth Evans almost 10 years ago
Sorry, mistake in the comment about tests, there's a test for tinyint but not one for smallint or bit
Updated by Gareth Evans almost 10 years ago
This may be an issue from my database conversion as I was originally using mysql and this was imported to sqlserver
I may just need to tweak the column types used on the boolean columns