MyTaskboardController support for PostgreSQL
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.
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)
Thanks for this, I had this problem too.
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.