{"action":"reopened","issue":{"url":"https://api.github.com/repos/jarektkaczyk/eloquence/issues/71","repository_url":"https://api.github.com/repos/jarektkaczyk/eloquence","labels_url":"https://api.github.com/repos/jarektkaczyk/eloquence/issues/71/labels{/name}","comments_url":"https://api.github.com/repos/jarektkaczyk/eloquence/issues/71/comments","events_url":"https://api.github.com/repos/jarektkaczyk/eloquence/issues/71/events","html_url":"https://github.com/jarektkaczyk/eloquence/issues/71","id":141938392,"number":71,"title":"Search in models with MorphMany get frozen and get an 504 error from ngnix","user":{"login":"arandilopez","id":2985233,"avatar_url":"https://avatars.githubusercontent.com/u/2985233?v=3","gravatar_id":"","url":"https://api.github.com/users/arandilopez","html_url":"https://github.com/arandilopez","followers_url":"https://api.github.com/users/arandilopez/followers","following_url":"https://api.github.com/users/arandilopez/following{/other_user}","gists_url":"https://api.github.com/users/arandilopez/gists{/gist_id}","starred_url":"https://api.github.com/users/arandilopez/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/arandilopez/subscriptions","organizations_url":"https://api.github.com/users/arandilopez/orgs","repos_url":"https://api.github.com/users/arandilopez/repos","events_url":"https://api.github.com/users/arandilopez/events{/privacy}","received_events_url":"https://api.github.com/users/arandilopez/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":0,"created_at":"2016-03-18T18:04:22Z","updated_at":"2016-03-18T18:31:48Z","closed_at":null,"body":"I got a Client model with two morphed relations to phone model and email model...\r\nThe search query is something like this:\r\n\r\n```sql\r\nselect * from \r\n(select \"clientes\".*, max(\r\ncase when \"clientes\".\"nombre\" = ? then 15 else 0 end + case when \"clientes\".\"nombre\" like ? then 5 else 0 end + case when \"clientes\".\"nombre\" like ? then 1 else 0 end + case when \"clientes\".\"apellido_paterno\" = ? then 15 else 0 end + case when \"clientes\".\"apellido_paterno\" like ? then 5 else 0 end + case when \"clientes\".\"apellido_paterno\" like ? then 1 else 0 end + case when \"clientes\".\"apellido_materno\" = ? then 15 else 0 end + case when \"clientes\".\"apellido_materno\" like ? then 5 else 0 end + case when \"clientes\".\"apellido_materno\" like ? then 1 else 0 end + case when \"clientes\".\"calle\" = ? then 15 else 0 end + case when \"clientes\".\"calle\" like ? then 5 else 0 end + case when \"clientes\".\"calle\" like ? then 1 else 0 end + case when \"clientes\".\"numero_exterior\" = ? then 15 else 0 end + case when \"clientes\".\"numero_exterior\" like ? then 5 else 0 end + case when \"clientes\".\"numero_exterior\" like ? then 1 else 0 end + case when \"clientes\".\"numero_interior\" = ? then 15 else 0 end + case when \"clientes\".\"numero_interior\" like ? then 5 else 0 end + case when \"clientes\".\"numero_interior\" like ? then 1 else 0 end + case when \"clientes\".\"colonia\" = ? then 15 else 0 end + case when \"clientes\".\"colonia\" like ? then 5 else 0 end + case when \"clientes\".\"colonia\" like ? then 1 else 0 end + case when \"clientes\".\"codigo_postal\" = ? then 15 else 0 end + case when \"clientes\".\"codigo_postal\" like ? then 5 else 0 end + case when \"clientes\".\"codigo_postal\" like ? then 1 else 0 end + case when \"clientes\".\"ciudad\" = ? then 15 else 0 end + case when \"clientes\".\"ciudad\" like ? then 5 else 0 end + case when \"clientes\".\"ciudad\" like ? then 1 else 0 end + case when \"clientes\".\"municipio\" = ? then 15 else 0 end + case when \"clientes\".\"municipio\" like ? then 5 else 0 end + case when \"clientes\".\"municipio\" like ? then 1 else 0 end + case when \"clientes\".\"estado\" = ? then 15 else 0 end + case when \"clientes\".\"estado\" like ? then 5 else 0 end + case when \"clientes\".\"estado\" like ? then 1 else 0 end + case when \"clientes\".\"pais\" = ? then 15 else 0 end + case when \"clientes\".\"pais\" like ? then 5 else 0 end + case when \"clientes\".\"pais\" like ? then 1 else 0 end + case when \"clientes\".\"status\" = ? then 15 else 0 end + case when \"clientes\".\"status\" like ? then 5 else 0 end + case when \"clientes\".\"status\" like ? then 1 else 0 end + case when \"clientes\".\"fecha_nacimiento\" = ? then 15 else 0 end + case when \"clientes\".\"fecha_nacimiento\" like ? then 5 else 0 end + case when \"clientes\".\"fecha_nacimiento\" like ? then 1 else 0 end + case when \"clientes\".\"can_creditos\" = ? then 15 else 0 end + case when \"clientes\".\"can_creditos\" like ? then 5 else 0 end + case when \"clientes\".\"can_creditos\" like ? then 1 else 0 end + case when \"clientes\".\"notas\" = ? then 15 else 0 end + case when \"clientes\".\"notas\" like ? then 5 else 0 end + case when \"clientes\".\"notas\" like ? then 1 else 0 end + case when \"clientes\".\"donde_conocio\" = ? then 15 else 0 end + case when \"clientes\".\"donde_conocio\" like ? then 5 else 0 end + case when \"clientes\".\"donde_conocio\" like ? then 1 else 0 end + case when \"clientes\".\"tipo\" = ? then 15 else 0 end + case when \"clientes\".\"tipo\" like ? then 5 else 0 end + case when \"clientes\".\"tipo\" like ? then 1 else 0 end + case when \"clientes\".\"facebook\" = ? then 15 else 0 end + case when \"clientes\".\"facebook\" like ? then 5 else 0 end + case when \"clientes\".\"facebook\" like ? then 1 else 0 end + case when \"clientes\".\"twitter\" = ? then 15 else 0 end + case when \"clientes\".\"twitter\" like ? then 5 else 0 end + case when \"clientes\".\"twitter\" like ? then 1 else 0 end + case when \"clientes\".\"dias_credito\" = ? then 15 else 0 end + case when \"clientes\".\"dias_credito\" like ? then 5 else 0 end + case when \"clientes\".\"dias_credito\" like ? then 1 else 0 end + case when \"clientes\".\"maximo_credito\" = ? then 15 else 0 end + case when \"clientes\".\"maximo_credito\" like ? then 5 else 0 end + case when \"clientes\".\"maximo_credito\" like ? then 1 else 0 end + case when \"telefonos\".\"numero\" = ? then 15 else 0 end + case when \"telefonos\".\"numero\" like ? then 5 else 0 end + case when \"telefonos\".\"numero\" like ? then 1 else 0 end + case when \"emails\".\"email\" = ? then 15 else 0 end + case when \"emails\".\"email\" like ? then 5 else 0 end + case when \"emails\".\"email\" like ? then 1 else 0 end) as relevance from \"clientes\" left join \"telefonos\" on \"telefonos\".\"telefonable_id\" = \"clientes\".\"id\" and \"telefonos\".\"telefonable_type\" = ? left join \"emails\" on \"emails\".\"emailable_id\" = \"clientes\".\"id\" and \"emails\".\"emailable_type\" = ? where (\"clientes\".\"nombre\" like ? or \"clientes\".\"apellido_paterno\" like ? or \"clientes\".\"apellido_materno\" like ? or \"clientes\".\"calle\" like ? or \"clientes\".\"numero_exterior\" like ? or \"clientes\".\"numero_interior\" like ? or \"clientes\".\"colonia\" like ? or \"clientes\".\"codigo_postal\" like ? or \"clientes\".\"ciudad\" like ? or \"clientes\".\"municipio\" like ? or \"clientes\".\"estado\" like ? or \"clientes\".\"pais\" like ? or \"clientes\".\"status\" like ? or \"clientes\".\"fecha_nacimiento\" like ? or \"clientes\".\"can_creditos\" like ? or \"clientes\".\"notas\" like ? or \"clientes\".\"donde_conocio\" like ? or \"clientes\".\"tipo\" like ? or \"clientes\".\"facebook\" like ? or \"clientes\".\"twitter\" like ? or \"clientes\".\"dias_credito\" like ? or \"clientes\".\"maximo_credito\" like ? or \"telefonos\".\"numero\" like ? or \"emails\".\"email\" like ?) \r\ngroup by \"clientes\".\"id\") as \"clientes\" where \"clientes\".\"deleted_at\" is null and \"relevance\" >= 6 order by \"relevance\" desc;\r\n```\r\nIf I run this in mysql get lock too..."}}