Skip to content

Commit

Permalink
Add more types for PG/Export
Browse files Browse the repository at this point in the history
Which are mapped to the correct Ecto counterpart.
  • Loading branch information
Patrick van de Glind committed Dec 24, 2020
1 parent ffab4d9 commit cd9b14b
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
9 changes: 6 additions & 3 deletions lib/database/postgresql.ex
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
5 changes: 4 additions & 1 deletion lib/io/export.ex
Original file line number Diff line number Diff line change
Expand Up @@ -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 """
Expand Down

0 comments on commit cd9b14b

Please sign in to comment.