Code Monkey home page Code Monkey logo

Comments (5)

iamed2 avatar iamed2 commented on June 9, 2024 1

I would accept a PR for a static version-guarded fix for old patch versions. Typically, old patch versions of Julia are not supported, as they are neither tested in CI nor recommended for installation by the Julia developers. And I do not want to impact performance for everyone by adding regex replacement to every parse call (which is why it is written as it is now). But a different version guarded by @static would have no performance impact and is clearly marked.

I cannot guarantee it will survive in perpetuity, especially if there is a refactor. Testing on old patch versions is wasteful. However, if you reference this issue, I will ping you before removing your changes in the future to check if you've moved to a patched version of Julia.

from libpq.jl.

iamed2 avatar iamed2 commented on June 9, 2024

Can you give an example please?

I cannot seem to replicate this on Julia 1.6.7 with LibPQ 1.15.1.

from libpq.jl.

Arkoniak avatar Arkoniak commented on June 9, 2024

Sure.

Julia 1.7.1, LibPQ 1.15.1:

using LibPQ
using Dates

LibPQ.pqparse(DateTime, "2023-03-03 12:34:56.789012")

yields output

ERROR: InexactError: convert(Dates.Decimal3, 789012)
Stacktrace:
 [1] tryparsenext
   @ ~/Languages/julia-1.7.1/share/julia/stdlib/v1.7/Dates/src/io.jl:153 [inlined]
 [2] tryparsenext
   @ ~/Languages/julia-1.7.1/share/julia/stdlib/v1.7/Dates/src/io.jl:41 [inlined]
 [3] macro expansion
   @ ~/Languages/julia-1.7.1/share/julia/stdlib/v1.7/Dates/src/parse.jl:64 [inlined]
 [4] tryparsenext_core(str::String, pos::Int64, len::Int64, df::DateFormat{Symbol("y-m-d HH:MM:SS.s"), Tuple{Dates.DatePart{'y'}, Dates.Delim{Char, 1}, Dates.DatePart{'m'}, Dates.Delim{Char, 1}, Dates.DatePart{'d'}, Dates.Delim{Char, 1}, Dates.DatePart{'H'}, Dates.Delim{Char, 1}, Dates.DatePart{'M'}, Dates.Delim{Char, 1}, Dates.DatePart{'S'}, Dates.Delim{Char, 1}, Dates.DatePart{'s'}}}, raise::Bool)
   @ Dates ~/Languages/julia-1.7.1/share/julia/stdlib/v1.7/Dates/src/parse.jl:38
 [5] macro expansion
   @ ~/Languages/julia-1.7.1/share/julia/stdlib/v1.7/Dates/src/parse.jl:150 [inlined]
 [6] tryparsenext_internal
   @ ~/Languages/julia-1.7.1/share/julia/stdlib/v1.7/Dates/src/parse.jl:125 [inlined]
 [7] tryparse(::Type{DateTime}, str::String, df::DateFormat{Symbol("y-m-d HH:MM:SS.s"), Tuple{Dates.DatePart{'y'}, Dates.Delim{Char, 1}, Dates.DatePart{'m'}, Dates.Delim{Char, 1}, Dates.DatePart{'d'}, Dates.Delim{Char, 1}, Dates.DatePart{'H'}, Dates.Delim{Char, 1}, Dates.DatePart{'M'}, Dates.Delim{Char, 1}, Dates.DatePart{'S'}, Dates.Delim{Char, 1}, Dates.DatePart{'s'}}})
   @ Dates ~/Languages/julia-1.7.1/share/julia/stdlib/v1.7/Dates/src/parse.jl:290
 [8] pqparse(#unused#::Type{DateTime}, str::String)
   @ LibPQ ~/.julia/packages/LibPQ/gYEIG/src/parsing.jl:262
 [9] top-level scope
   @ REPL[8]:1

In Julia 1.8.2, LibPQ 1.15.1

using LibPQ
using Dates

LibPQ.pqparse(DateTime, "2023-03-03 12:34:56.789012")

yields

2023-03-03T12:34:56.789

Also, Julia 1.7.1, LibPQ 1.14.1

julia> using LibPQ
julia> using Dates
julia> LibPQ.pqparse(DateTime, "2023-03-03 12:34:56.789123")
2023-03-03T12:34:56.789

from libpq.jl.

iamed2 avatar iamed2 commented on June 9, 2024

This works properly with LibPQ.jl 1.15.1 on Julia 1.7.3, Julia 1.6.7, and Julia 1.8.2+. Unfortunately my suggestion is to upgrade Julia to a later patch version, since the above error is a bug in Julia that was fixed.

from libpq.jl.

Arkoniak avatar Arkoniak commented on June 9, 2024

Sorry, I do not quite understand...
Why can't we do the same as in #248? It seems simple enough.

Or, even better, just change https://github.com/iamed2/LibPQ.jl/blob/master/src/parsing.jl#L262 from

parsed = tryparse(DateTime, str, TIMESTAMP_FORMAT)

to

parsed = tryparse(DateTime, _trunc_seconds(str), TIMESTAMP_FORMAT)

as it basically was in 1.14.1?

I can make a PR if you do not have time for these changes, no big deal.

from libpq.jl.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.