The unexpected varchar(255)

Yes, looks like it is hard-coded into the postgres driver - connection.ex has the following function:

    defp column_type(type, opts) do
      size      = Keyword.get(opts, :size)
      precision = Keyword.get(opts, :precision)
      scale     = Keyword.get(opts, :scale)
      type_name = ecto_to_db(type)

      cond do
        size            -> [type_name, ?(, to_string(size), ?)]
        precision       -> [type_name, ?(, to_string(precision), ?,, to_string(scale || 0), ?)]
        type == :string -> [type_name, "(255)"]
        true            -> type_name
      end
    end

as to why, you will have to ask the author. You can override by providing a size option when defining the column by the looks of things…

3 Likes