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

Unsupported column type GUID #24

Closed
bubnenkoff opened this issue Apr 5, 2016 · 10 comments
Closed

Unsupported column type GUID #24

bubnenkoff opened this issue Apr 5, 2016 · 10 comments
Assignees
Labels

Comments

@bubnenkoff
Copy link

CREATE TABLE "USERS" (
guid uuid,
name text,
"FL" integer,
id bigint NOT NULL
);

INSERT INTO public."USERS"(guid, name, "FL", id)
VALUES ('cd3c7ffd-7919-f6c5-999d-5586d9f3b261', 'vasia', 10, 1);


I need any way to select and insert GUIDs to DB. Is there any way to do it now. Any way? Maybe not best, just to get it work.

auto rs = stmt.executeQuery(`SELECT guid, name, "FL", id FROM public."USERS";`);
while (rs.next())
writeln(to!string(rs.getString(1)) ~ "\t" ~ rs.getString(2) ~ "\t" );
@rjmcguire
Copy link

which database are you using? Could be mssql? Use uniqueidentifier rather
than GUID

On Tue, Apr 5, 2016 at 1:38 PM, Dmitry Bubnenkov notifications@github.com
wrote:

CREATE TABLE "USERS" (
guid uuid,
name text,
"FL" integer,
id bigint NOT NULL
);

INSERT INTO public."USERS"(guid, name, "FL", id)

VALUES ('cd3c7ffd-7919-f6c5-999d-5586d9f3b261', 'vasia', 10, 1);

I need any way to select and insert GUIDs to DB. Is there any way to do it
now. Any way? Maybe not best, just to get it work.

    auto rs = stmt.executeQuery(`SELECT guid, name, "FL", id FROM public."USERS";`);
    while (rs.next())
        writeln(to!string(rs.getString(1)) ~ "\t" ~ rs.getString(2) ~ "\t" );


You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub
#24

@bubnenkoff
Copy link
Author

PostgreSQL. And I need GUID...

@rjmcguire
Copy link

postgre seems to use uuid as that column type.

On Tue, Apr 5, 2016 at 1:52 PM, Dmitry Bubnenkov notifications@github.com
wrote:

PostgreSQL. And I need GUID...


You are receiving this because you commented.
Reply to this email directly or view it on GitHub
#24 (comment)

@bubnenkoff
Copy link
Author

Yeah, and is there any solution?

I found. I can do ::text

SELECT guid::text, name, "FL", id FROM public."USERS";

@rjmcguire
Copy link

On Tue, Apr 5, 2016 at 2:36 PM, Dmitry Bubnenkov notifications@github.com
wrote:

Yeah, and is there any solution?


You are receiving this because you commented.
Reply to this email directly or view it on GitHub
#24 (comment)

Its odd that the error is complaining about the field name as though it was
the type. Have you tried with a different column name, or by quoting the
column name?

E.g.
...
"guid" uuid,
...

@bubnenkoff
Copy link
Author

@rjmcguire
Copy link

On Wed, Apr 6, 2016 at 9:58 AM, Dmitry Bubnenkov
notifications@github.com wrote:

http://img.ctrlv.in/img/16/04/06/5704c18283091.png
same effect


You are receiving this because you commented.
Reply to this email directly or view it on GitHub

You would need to add support for UUID field type. ddbc seems to have
the UUIDOID definition but the field type has not been implemented.

for select support a start would be something like:
case UUIDOID:
import std.uuid;
v[col] = UUID(cast(ubyte[])s);

Not tested

@bubnenkoff
Copy link
Author

Do you mean something like this:

        auto rs = stmt.executeQuery(`SELECT guid, id, name, "FL" FROM public."USERS";`);
        while (rs.next())
        {
            //writeln(to!string(rs.getString(1)) ~ "\t" ~ rs.getString(2) ~ "\t" ~ "\t" ~ rs.getString(3));
            //md.guid = to!string(rs.getString(1));
            UUID x = UUID(cast(ubyte[])rs.getString(1));
}

source\app.d(67,12): Error: None of the overloads of '__ctor' are callable usin
argument types (ubyte[]), candidates are:
C:\D\dmd2\windows\bin....\src\phobos\std\uuid.d(251,34): std.uuid.UUID
this(ref const(ubyte[16]) uuidData)
C:\D\dmd2\windows\bin....\src\phobos\std\uuid.d(256,34): std.uuid.UUID
this(const(ubyte[16]) uuidData)
dmd failed with exit code 1.

@rjmcguire
Copy link

On Wed, Apr 6, 2016 at 1:11 PM, Dmitry Bubnenkov notifications@github.com
wrote:

Do you mean something like this:

    auto rs = stmt.executeQuery(`SELECT guid, id, name, "FL" FROM public."USERS";`);
    while (rs.next())
    {
        //writeln(to!string(rs.getString(1)) ~ "\t" ~ rs.getString(2) ~ "\t" ~ "\t" ~ rs.getString(3));
        //md.guid = to!string(rs.getString(1));
        UUID x = UUID(cast(ubyte[])rs.getString(1));

}

source\app.d(67,12): Error: None of the overloads of '__ctor' are callable
usin
argument types (ubyte[]), candidates are:
C:\D\dmd2\windows\bin....\src\phobos\std\uuid.d(251,34): std.uuid.UUID
this(ref const(ubyte[16]) uuidData)
C:\D\dmd2\windows\bin....\src\phobos\std\uuid.d(256,34): std.uuid.UUID
this(const(ubyte[16]) uuidData)
dmd failed with exit code 1.


You are receiving this because you commented.
Reply to this email directly or view it on GitHub
#24 (comment)

Nope, sorry for the lack of clarity in my previous message. What I am
saying is that ddbc does not support the uuid data type. You or someone
else will have to add it.
It should be fairly straight forward. The code I sent you was about
changing the file: ddbc/drivers/pgsqlddbc.d by adding a new case that
handles UUIDOID, the code for which would be similar to what I sent you in
my previous message. That should allow your select statement to work
because ddbc seems to be using std.variant for returning the row data.

@buggins buggins added the bug label Apr 27, 2016
@buggins buggins self-assigned this Apr 27, 2016
@buggins
Copy link
Owner

buggins commented Sep 21, 2016

Fixed.

@buggins buggins closed this as completed Sep 21, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants