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

Fixed deprecated functions (bytestring, is, symbol) #48

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

wookay
Copy link

@wookay wookay commented Nov 25, 2016

Hello

  • Fixed deprecated functions: bytestring to unsafe_string, is to ===, symbol to Symbol
  • Compat.ASCIIString for pgtype, pgdata
  • requires DataFrames.jl v0.8.0

thanks.

… symbol to Symbol

- Compat.ASCIIString for pgtype, pgdata
@coveralls
Copy link

coveralls commented Nov 25, 2016

Coverage Status

Coverage increased (+1.1%) to 76.682% when pulling ae714f0 on wookay:deprecated_bytestring_is into a29b45f on JuliaDB:master.

@codecov-io
Copy link

codecov-io commented Nov 25, 2016

Codecov Report

Merging #48 into master will not change coverage.
The diff coverage is n/a.

Impacted file tree graph

@@           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.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update a29b45f...4d9ea7f. Read the comment docs.

Copy link
Contributor

@iamed2 iamed2 left a 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)
Copy link
Contributor

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})

Copy link
Author

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)
Copy link
Contributor

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 ByteStrings could be stored directly and strings which don't have a unsafe_convert(Ptr{UInt8}, str) method would be converted to ByteStrings 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.

Copy link
Author

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.

Copy link
Contributor

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!.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@iamed2 You can see in the last commit all calls to storestring! have been converted from bytestring to String not unsafe_string in order to make the call to unsafe_convert work.

@coveralls
Copy link

coveralls commented Nov 25, 2016

Coverage Status

Coverage increased (+0.8%) to 76.364% when pulling e87b3a5 on wookay:deprecated_bytestring_is into a29b45f on JuliaDB:master.

@coveralls
Copy link

coveralls commented Nov 25, 2016

Coverage Status

Coverage increased (+0.8%) to 76.364% when pulling e87b3a5 on wookay:deprecated_bytestring_is into a29b45f on JuliaDB:master.

* 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)
@coveralls
Copy link

Coverage Status

Coverage increased (+0.3%) to 75.909% when pulling 4d9ea7f on wookay:deprecated_bytestring_is into a29b45f on JuliaDB:master.

@@ -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)
Copy link
Contributor

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!.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants