Skip to content

Commit

Permalink
Merge pull request #82 from pepsico-ecommerce/bc/rollback-v1.0.0-chan…
Browse files Browse the repository at this point in the history
…ges-ecto-type

Revert "Merge pull request #81"
  • Loading branch information
BruceBC authored Aug 19, 2024
2 parents 77a50be + 70cf036 commit 808c600
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
4 changes: 2 additions & 2 deletions lib/snowflex/ecto/connection.ex
Original file line number Diff line number Diff line change
Expand Up @@ -253,7 +253,7 @@ defmodule Snowflex.EctoAdapter.Connection do

defp insert_all_value(nil), do: "DEFAULT"
defp insert_all_value({%Ecto.Query{} = query, _params_counter}), do: [?(, all(query), ?)]
defp insert_all_value(_), do: "?"
defp insert_all_value(_), do: '?'

@impl true
def update(prefix, table, fields, filters, _returning) do
Expand Down Expand Up @@ -598,7 +598,7 @@ defmodule Snowflex.EctoAdapter.Connection do
end

defp expr({:^, [], [_ix]}, _sources, _query) do
"?"
'?'
end

defp expr({{:., _, [{:parent_as, _, [as]}, field]}, _, []}, _sources, query)
Expand Down
10 changes: 8 additions & 2 deletions lib/snowflex/migration_generator.ex
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,15 @@ defmodule Snowflex.MigrationGenerator do

create table(@source, primary_key: false) do
for {name, type} <- @fields do
field_type = Ecto.Type.type(type)
field_type = ecto_type_to_db_type(type)
field_source = name
add(field_source, type, primary_key: name in primary_keys)
end
end
end

defp ecto_type_to_db_type({:parameterized, Ecto.Enum, _}), do: :string
defp ecto_type_to_db_type(any), do: any
end

Ecto.Migrator.up(
Expand All @@ -52,13 +55,16 @@ defmodule Snowflex.MigrationGenerator do
type =
:type
|> @module.__schema__(field)
|> Ecto.Type.type()
|> ecto_type_to_db_type()

field_source = @module.__schema__(:field_source, field)
add(field_source, type, primary_key: field in primary_keys)
end
end
end

defp ecto_type_to_db_type({:parameterized, Ecto.Enum, _}), do: :string
defp ecto_type_to_db_type(any), do: any
end

Ecto.Migrator.up(
Expand Down

0 comments on commit 808c600

Please sign in to comment.