Skip to content

queryValue requires awkward get.get!T #195

Open
@schveiguy

Description

@schveiguy

queryValue returns a Nullable!Variant. Let's say it returns a long (In my case, I was querying a COUNT(*) to get the total rows)

My code I put was:

auto total = conn.queryValue("select count(*) from ...").get!long

But this doesn't work, because Nullable intercepts the get call! So instead I have to do:

auto total = conn.queryValue("select count(*) from ...").get.get!long

Which IMO is ugly and annoying. Really this is an issue with Nullable and Variant reusing the same member name, but I doubt that will change.

Is it possible to instead specify the type to queryValue itself, and have it return a Nullable!T? something like:

// no need for get here, I know I'm going to get a value
long total = conn.queryValue!long("select count(*) from ...");

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions