diff --git a/lib/database/postgresql.ex b/lib/database/postgresql.ex index 41cef1b..c1a9bfb 100644 --- a/lib/database/postgresql.ex +++ b/lib/database/postgresql.ex @@ -127,17 +127,20 @@ defimpl Plsm.Database, for: Plsm.Database.PostgreSQL do cond do String.starts_with?(upcase, "INTEGER") == true -> :integer String.starts_with?(upcase, "INT") == true -> :integer + String.starts_with?(upcase, "SMALLINT") == true -> :integer String.starts_with?(upcase, "BIGINT") == true -> :integer - String.contains?(upcase, "CHAR") == true -> :string + String.starts_with?(upcase, "CHAR") == true -> :string String.starts_with?(upcase, "TEXT") == true -> :string String.starts_with?(upcase, "FLOAT") == true -> :float String.starts_with?(upcase, "DOUBLE") == true -> :float String.starts_with?(upcase, "DECIMAL") == true -> :decimal String.starts_with?(upcase, "NUMERIC") == true -> :decimal + String.starts_with?(upcase, "JSON") == true -> :map String.starts_with?(upcase, "JSONB") == true -> :map String.starts_with?(upcase, "DATE") == true -> :date - String.starts_with?(upcase, "DATETIME") == true -> :date - String.starts_with?(upcase, "TIMESTAMP") == true -> :date + String.starts_with?(upcase, "DATETIME") == true -> :timestamp + String.starts_with?(upcase, "TIMESTAMP") == true -> :timestamp + String.starts_with?(upcase, "TIME") == true -> :time String.starts_with?(upcase, "BOOLEAN") == true -> :boolean true -> :none end diff --git a/lib/io/export.ex b/lib/io/export.ex index c815786..75148e4 100644 --- a/lib/io/export.ex +++ b/lib/io/export.ex @@ -9,12 +9,15 @@ defmodule Plsm.IO.Export do |> four_space() end + defp map_type(:boolean), do: ":boolean" defp map_type(:decimal), do: ":decimal" defp map_type(:float), do: ":float" defp map_type(:string), do: ":string" defp map_type(:text), do: ":string" defp map_type(:map), do: ":map" - defp map_type(:date), do: ":naive_datetime" + defp map_type(:date), do: ":date" + defp map_type(:time), do: ":time" + defp map_type(:timestamp), do: ":naive_datetime" defp map_type(:integer), do: ":integer" @doc """