Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Revert "Merge pull request #81" #82

Merged
merged 1 commit into from
Aug 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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