redmine_task_board icon indicating copy to clipboard operation
redmine_task_board copied to clipboard

MyTaskboardController support for PostgreSQL

Open aVolpe opened this issue 11 years ago • 3 comments

If the database is MySql the column issue_statuses#is_closed is a integer 0 or 1, but if the database is PostgreSQL, the column is boolean.

A check for the database type is necesary to create the correct SQL to get the task of the current user.

aVolpe avatar Apr 29 '14 14:04 aVolpe

The controller my_task_controller work only for MySQL, because this:

.where("assigned_to_id = ? AND issue_statuses.is_closed = 0 AND projects.status = 1", @user.id) \

The issue_statuses.is_closed is a int in MySQL and a boolean in PostgreSQL.

With this change it works:

if ActiveRecord::Base.connection.adapter_name == 'MySQL'
    where = "assigned_to_id = ? AND issue_statuses.is_closed == 0 AND projects.status = 1"
else
    where = "assigned_to_id = ? AND not issue_statuses.is_closed AND projects.status = 1"
end

...

   .where(where, @user.id)

aVolpe avatar Apr 29 '14 14:04 aVolpe

Thanks for this, I had this problem too.

sbonnegent avatar Jun 05 '15 08:06 sbonnegent

Is this not the ORM job? I don't know much about RoR, but in the pony world (Django), this is how it works. You use the ORM which takes care of the conversion itself. Here's my take on it:

.where("assigned_to_id" => @user.id, "issue_statuses.is_closed" => false, "projects.status" => 1)

I hope ActiveRecord can convert it to appropriated database backend.

I've created a pull request #39 that implements it in an agnostic way.

AndreMiras avatar Jun 22 '15 15:06 AndreMiras