-
Notifications
You must be signed in to change notification settings - Fork 10
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
Add map_nulls_to_nil configuration #17
Conversation
…om in query responses to Elixir nil atom
94ddca4
to
b617ee8
Compare
lib/snowflex.ex
Outdated
@@ -75,6 +75,8 @@ defmodule Snowflex do | |||
end | |||
|
|||
defp process_results({:selected, headers, rows}) do | |||
null_to_nil? = Application.get_env(:snowflex, :map_nulls_to_nil?, true) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should this default to false to preserve current behavior and not introduce a breaking change?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes, it should
I think rather than an application-level setting, this can be an option on Also, please be sure to update the changelog with the new feature. 🙂 |
Should it perhaps be both? I can foresee library consumers not wanting to set the option for each query, so allowing them to set it as a default would be good. |
I am thinking of an option you can set like: defmodule MyApp.Snowflake.Warehouse do
use Snowflex.Connection,
otp_app: :my_app,
timeout: :timer.minutes(20),
map_nulls_to_nil?: true
end Then if the user wants to change per request, they can override with Warehouse.execute(query, map_nulls_to_nil?: false, timeout: :timer.seconds(1)) |
Good suggestion @zbarnes757 , I decided to add the configuration to the using block of the connection and replace the timeout variable with a keyword list argument containing the timeout and my |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
just change the order of the function arguments
The odbc used by Snowflex driver will, by default, return
:null
for empty values in a query rather thannil
, a value native to Elixir. This pull requests adds translation of:null
to:nil
along with configuration to disable this feature if desired.