title: bigint versus integer error in Ecto with Legacy database
body: <p>I'm in the following situation: There's a PostgreSQL legacy database from a Rails application I need to interact with.</p>
  
  <p>Phoenix is using Repo with a schema to connect to that database, and so far it seems to work OK, I can retrieve elements and perform some basic queries with the expected results.</p>
  
  <p>Now, I started playing with some advance queries, and I'm getting some issues that I don't how to solve. For example:</p>
  
  <p><code>from(is in acc, or_where: ^current_user.id in [is.transcriber_id, is.radiologist_id, is.validator_id])</code></p>
  
  <p>returns the following error</p>
  
  <pre><code>** (Postgrex.Error) ERROR 42P08 (ambiguous_parameter): inconsistent types deduced for parameter $2
  
  bigint versus integer
      (ecto) lib/ecto/adapters/sql.ex:431: Ecto.Adapters.SQL.execute_and_cache/7
      (ecto) lib/ecto/repo/queryable.ex:133: Ecto.Repo.Queryable.execute/5
      (ecto) lib/ecto/repo/queryable.ex:37: Ecto.Repo.Queryable.all/4
  </code></pre>
  
  <p>After some research, I discovered that ActiveRecord in Rails, stores integers as <code>bigints</code> but I'm not sure Postgrex or Ecto (I really don't who is in charge of this) is interpreting correctly the integer <code>current_user.id</code> I'm using in the query.</p>
  
  <p>I have the feeling that the expression <code>in [is.transcriber_id, is.radiologist_id, is.validator_id]</code> is a bit greedy and maybe I should go with fragments.</p>
  
  <p><strong>UPDATE</strong>:</p>
  
  <p><code>is</code> stands for ImagingStudy. The Rails migration of this model is as follows:</p>
  
  <pre class="lang-rb prettyprint-override"><code>class CreateImagingStudies &lt; ActiveRecord::Migration[5.2]
    def change
      create_table :imaging_studies do |t|
        t.string :status_name
        t.bigint :validator_id
        t.bigint :radiologist_id
        t.bigint :transcriber_id
  
        t.timestamps
      end
    end
  end
  </code></pre>
  
  <p>The Phoenix schema for manipulating the table corresponding to the imaging_studies is as follows</p>
  
  <pre><code>defmodule Worklist.Studies.ImagingStudy do
    use Ecto.Schema
  
    schema "imaging_studies" do
      field :transcriber_id, :integer
      field :radiologist_id, :integer
      field :validator_id, :integer
  
      timestamps(inserted_at: :created_at, updated_at: :updated_at)
    end
  
  </code></pre>
  
  <p>There's no schema for users, since they are managed in another service. Consider the <code>current_user</code> a map with an integer field named <code>id</code>.</p>