Closed randomizedthinking closed 6 years ago
@@ master #42 diff @@
==========================================
Files 3 3
Lines 221 221
Methods 0 0
Messages 0 0
Branches 0 0
==========================================
Hits 167 167
Misses 54 54
Partials 0 0
Powered by Codecov. Last update 0d13f02...0d13f02
The environment variables are wrong and are unnecessary; libpq will pick them up if passed C_NULL for a parameter.
A null should also be represented with a Nullable instead of an empty string.
The signature of the connect function is now updated to accept NULL values. Can you review again?
The connect function should take Nullables, not C_NULL. Read http://docs.julialang.org/en/latest/manual/types/#nullable-types-representing-missing-values for more info.
I tried Nullable
, yet the syntax is quite cumbersome. For instance, ASCIIString
can't be assigned to Nullable{AbstractString}
so we are forced to use Nullable("mydb")
to call the connect function.
Likely, using keyword arguments would be a better approach.
If you'd like the keyword approach better, please make a PR to DBI to include that, and then implement it here.
You could still take the Nullable approach if you had a method that accepted Union{AbstractString, Nullable}
and convert
ed the inputs to Nullable{AbstractString}
.
The updated PR now takes keyword arguments for the connect
function. Verified there is no need to modify the DBI
module. The function connect(::Type{PostgreSQL.Postgres}; dsn::AbstractString)
is converted to using positional argument connect(::Type{PostgreSQL.Postgres}, dsn::AbstractString)
. This is because keyword arguments are not part of the function signature; hence, we can only have one function with the given signature. Let me know how you think.
Better to use keyword parameters: requires updating DBI.connect. Leave it to future.