NoamB/sorcery — Issue #110: Twitter oauth authorization not working (PostgreSQL >= 8.3)
Author: yagitoshiro
Created: 2011-10-26 01:04:22+00:00
State: open

Twitter oauth does not work with PostgreSQL >= 8.3.

```
PGError: ERROR: operator does not exist: character varying = integer
LINE 1: ...provider" = 'twitter' AND "authentications"."uid" = 6758552 ...
^
HINT: No operator matches the given name and argument type(s). You might need to add explicit type casts.
: SELECT "authentications".* FROM "authentications" WHERE "authentications"."provider" = 'twitter' AND "authentications"."uid" = 6758552 LIMIT 1
```

This is because the type of auto-generated "uid" column is string(varchar) but sorcery retrieve Twitter uid as integer. PostgreSQL had dropped its auto cast function on 8.3 so that you can't compare integer with string.

Workaround is rather simple.

```
lib/sorcery/controller/submodules/external/providers/twitter.rb
58c58
< user_hash[:uid] = user_hash[:user_info]['id']
---
> user_hash[:uid] = user_hash[:user_info]['id'].to_s
```