{"action":"created","issue":{"url":"https://api.github.com/repos/thoughtbot/administrate/issues/178","labels_url":"https://api.github.com/repos/thoughtbot/administrate/issues/178/labels{/name}","comments_url":"https://api.github.com/repos/thoughtbot/administrate/issues/178/comments","events_url":"https://api.github.com/repos/thoughtbot/administrate/issues/178/events","html_url":"https://github.com/thoughtbot/administrate/issues/178","id":115534277,"number":178,"title":"Devise inet fields may be treated as Field::String in Administrate, which results in SQL errors when searching","user":{"login":"maxkwallace","id":3249377,"avatar_url":"https://avatars.githubusercontent.com/u/3249377?v=3","gravatar_id":"","url":"https://api.github.com/users/maxkwallace","html_url":"https://github.com/maxkwallace","followers_url":"https://api.github.com/users/maxkwallace/followers","following_url":"https://api.github.com/users/maxkwallace/following{/other_user}","gists_url":"https://api.github.com/users/maxkwallace/gists{/gist_id}","starred_url":"https://api.github.com/users/maxkwallace/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/maxkwallace/subscriptions","organizations_url":"https://api.github.com/users/maxkwallace/orgs","repos_url":"https://api.github.com/users/maxkwallace/repos","events_url":"https://api.github.com/users/maxkwallace/events{/privacy}","received_events_url":"https://api.github.com/users/maxkwallace/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":3,"created_at":"2015-11-06T16:08:30Z","updated_at":"2015-11-07T10:56:55Z","closed_at":null,"body":"I'm seeing an `ActiveRecord::StatementInvalid` error when searching over my Users in Administrate.\r\n\r\nPostgres gives the following error:\r\n```\r\nPG::UndefinedFunction: ERROR:  function lower(inet) does not exist\r\n```\r\n\r\nThe SQL query that's erroring looks like:\r\n```\r\nSELECT  \"users\".* FROM \"users\" WHERE (lower(email) LIKE '%george%' OR lower(current_sign_in_ip) LIKE '%george%' ... ) LIMIT 20 OFFSET 0\r\n```\r\n\r\nAs far as I can tell, this is because the `current_sign_in_ip` attribute (managed by Devise) is treated as a String in Administrate:\r\n\r\n```\r\n    current_sign_in_ip: Field::String,\r\n```\r\n\r\nwhereas it's actually an inet in Postgres:\r\n\r\n```\r\nt.inet     \"current_sign_in_ip\"\r\n```\r\n\r\nso attempting to use `lower` on it fails.\r\n\r\nThis isn't an urgent issue-- simply deleting the offending attributes from `ATTRIBUTE_TYPES` in my `user_dashboard.rb` file allows me to search just fine. The only downside is that I can't see the `current_sign_in_ip` attribute in Administrate, which really doesn't matter.  But I thought it was worth reporting."},"comment":{"url":"https://api.github.com/repos/thoughtbot/administrate/issues/comments/154691203","html_url":"https://github.com/thoughtbot/administrate/issues/178#issuecomment-154691203","issue_url":"https://api.github.com/repos/thoughtbot/administrate/issues/178","id":154691203,"user":{"login":"maxkwallace","id":3249377,"avatar_url":"https://avatars.githubusercontent.com/u/3249377?v=3","gravatar_id":"","url":"https://api.github.com/users/maxkwallace","html_url":"https://github.com/maxkwallace","followers_url":"https://api.github.com/users/maxkwallace/followers","following_url":"https://api.github.com/users/maxkwallace/following{/other_user}","gists_url":"https://api.github.com/users/maxkwallace/gists{/gist_id}","starred_url":"https://api.github.com/users/maxkwallace/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/maxkwallace/subscriptions","organizations_url":"https://api.github.com/users/maxkwallace/orgs","repos_url":"https://api.github.com/users/maxkwallace/repos","events_url":"https://api.github.com/users/maxkwallace/events{/privacy}","received_events_url":"https://api.github.com/users/maxkwallace/received_events","type":"User","site_admin":false},"created_at":"2015-11-07T10:56:55Z","updated_at":"2015-11-07T10:56:55Z","body":"Yup, that would definitely work. My main concern when opening this issue was not finding a solution as much as making sure Administrate doesn't appear to have bugs when people first set it up (hurts their impression of the gem, bad UX). So it may be worth adding a check for `inet` fields and excluding them from `ATTRIBUTE_TYPES` by default.\r\n\r\nAfter checking:\r\n- https://community.oracle.com/thread/290732\r\n- https://msdn.microsoft.com/en-us/library/ms187752.aspx\r\n- https://docs.mongodb.org/v3.0/reference/bson-types/\r\n- http://stackoverflow.com/questions/5133580/which-mysql-datatype-for-an-ip-address\r\n\r\nIt looks like none of Oracle, SQL Server, Mongo or MySQL support a native `inet` type, so I assume Postgres is alone in this regard."}}