-
Notifications
You must be signed in to change notification settings - Fork 39
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
Fixed deprecated functions (bytestring, is, symbol) #48
base: master
Are you sure you want to change the base?
Conversation
… symbol to Symbol - Compat.ASCIIString for pgtype, pgdata
Codecov Report
@@ Coverage Diff @@
## master #48 +/- ##
=======================================
Coverage 75.56% 75.56%
=======================================
Files 3 3
Lines 221 221
=======================================
Hits 167 167
Misses 54 54 Continue to review full report at Codecov.
|
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.
Two comments; looks good otherwise, thanks!
src/types.jl
Outdated
if VERSION < v"0.5-dev+4194" | ||
import Compat | ||
|
||
function pgtype(t::Type) |
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.
Rather than an if, these can just be three methods of pgtype
(e.g. pgtype{T<:Compat.ASCIIString}(::Type{T})
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.
fixed 😃
@@ -151,41 +175,37 @@ function pgdata(::Type{PostgresType{:numeric}}, ptr::Ptr{UInt8}, data::Number) | |||
ptr = storestring!(ptr, string(data)) | |||
end | |||
|
|||
function pgdata(::PGStringTypes, ptr::Ptr{UInt8}, data::ByteString) |
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.
These functions were here so that ByteString
s could be stored directly and strings which don't have a unsafe_convert(Ptr{UInt8}, str)
method would be converted to ByteString
s first. I think the correct way to fix these functions is to have this first one accept String
and have the other ones call String(data)
first.
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.
well, pgdata
functions have always call the function storestring!
.
and unsafe_convert(Ptr{UInt8}, str)
has been always called in the function storestring!
.
I need some test cases for this to investigate more.
thanks.
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.
The difference is that bytestring
converted an AbstractString
to a ByteString
in all the functions that took an AbstractString
, which ensured that the unsafe_convert
call would succeed. It could pass ByteString
directly through because it is backed by a null-terminated cstr, so unsafe_convert
will succeed. Some T<:AbstractString
don't have that backing, and need to be converted to a String
first before they can be passed to storestring!
.
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.
2285635
to
e87b3a5
Compare
* updates for Julia v0.5 compatibility (mostly related to Strings warnings) * added missing types definition + updated deprecated * removed io seek unused functions + duplicate function * Removed duplicate function declarations * Fixed type alias declaration * Changed bytestring to unsafe_string * Fixed String to be AbstractString * Fixed convert function redefinition warning * Fixed multiple type declarations * fixed getting byte array from strings * fixed deprecated bytestring in test * Fixed formatting * added abstact type for julia 0.6 (with compat support)
@@ -151,41 +175,37 @@ function pgdata(::Type{PostgresType{:numeric}}, ptr::Ptr{UInt8}, data::Number) | |||
ptr = storestring!(ptr, string(data)) | |||
end | |||
|
|||
function pgdata(::PGStringTypes, ptr::Ptr{UInt8}, data::ByteString) |
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.
The difference is that bytestring
converted an AbstractString
to a ByteString
in all the functions that took an AbstractString
, which ensured that the unsafe_convert
call would succeed. It could pass ByteString
directly through because it is backed by a null-terminated cstr, so unsafe_convert
will succeed. Some T<:AbstractString
don't have that backing, and need to be converted to a String
first before they can be passed to storestring!
.
Hello
bytestring
tounsafe_string
,is
to===
,symbol
toSymbol
Compat.ASCIIString
forpgtype
,pgdata
thanks.