Packages
ecto_raw_sql_helpers
0.1.2
EctoRawSQLHelpers aims to improve raw SQL support in Ecto by providing helper functions, such as: - Named parameters support - Response parsing (getting query results as lists of maps, number of rows affected on statements, etc) - Stream support for dealing with big result sets
Current section
Files
Jump to
Current section
Files
lib/internals/Helpers.ex
defmodule EctoRawSQLHelpers.Helpers do
def string_to_atom_if_enabled(string, options) do
is_enabled?(options)
|> case do
false -> string
true -> String.to_atom(string)
end
end
defp is_enabled?(options) do
Keyword.get(options, :column_names_as_atoms)
|> case do
nil -> Application.get_env(:ecto_raw_sql_helpers, :column_names_as_atoms, false)
value -> value
end
end
end