Issue 257 in dblinq2007: PostgreSql uuid data type

7 views
Skip to first unread message

dblin...@googlecode.com

unread,
Jun 2, 2010, 6:57:18 AM6/2/10
to dblin...@googlegroups.com
Status: New
Owner: ----

New issue 257 by guillaume.bibaut: PostgreSql uuid data type
http://code.google.com/p/dblinq2007/issues/detail?id=257

What steps will reproduce the problem?
1.Create a table TestTable with an identifier using the uuid type and a
second column with a character varying as testdata
2.generate the DataContext using sqlmetal
3.use the data context in some code to insert a "new TestTable {ID =
Guid.NewGuid(), TestData = "Data" }"
4.use DataContext.Log = Console.Out (or to a file)

What is the expected output? What do you see instead?
Expected :
in the WHERE statement after the INSERT statement has run, we should see :
WHERE ("ID" = ('7DCBA342-D28B-443b-8196-717014501B51')::uuid)

What we see instead :
WHERE ("ID" = 7DCBA342-D28B-443b-8196-717014501B51)

What version of the product are you using? On what operating system?
System.Data.Linq in Mono-2-6 branches (which is supposed to be 0.20 ?)
~/Mono/mono-2-6
$ svn info
Chemin : .
URL : svn://anonsvn.mono-project.com/source/branches/mono-2-6
Racine du dépôt : svn://anonsvn.mono-project.com/source
UUID du dépôt : e3ebcda4-bce8-0310-ba0a-eca2169e7518
Révision : 158311
...
$ sqlmetal /?
DbLinq Database mapping generator 2008 version 0.20
...

PostgreSql version : 8.4.4

Npgsql version : 2.0.9

Linux : ArchLinux (http://archlinux.org/)


In my understanding of the DbLinq code in this mono branch, UUID use is not
provided.

Here is my sample test DataContext.Log, it's not exactly the same as
described in my issue, but still shows that uuid use is not provided :

INSERT INTO "public"."Characters" ("Id", "Name") VALUES (:ID, :Name)
-- :ID: Input Guid (Size = 0; Prec = 0; Scale = 0)
[3e2731f1-4ce2-4d89-b310-6397c2d1197a]
-- :Name: Input String (Size = 0; Prec = 0; Scale = 0) [Toto]
-- Context: PostgreSQL Model: AttributedMetaModel Build: 3.5.0.0
SELECT "CharacterId", "DateRanking", "ExpInLevel", "Id", "Level"
FROM "public"."History"
WHERE ("CharacterId" = 3e2731f1-4ce2-4d89-b310-6397c2d1197a)
-- Context: PostgreSQL Model: AttributedMetaModel Build: 3.5.0.0

Unhandled Exception: Npgsql.NpgsqlException:
syntax error at or near "f1"
Severity: ERROR
Code: 42601
at
Npgsql.NpgsqlState+<ProcessBackendResponses_Ver_3>c__Iterator1.MoveNext ()
[0x00000] in <filename unknown>:0
at Npgsql.ForwardsOnlyDataReader.GetNextResponseObject () [0x00000] in
<filename unknown>:0

dblin...@googlecode.com

unread,
Sep 10, 2010, 10:35:08 AM9/10/10
to dblin...@googlegroups.com

Comment #1 on issue 257 by goossensjhm: PostgreSql uuid data type
http://code.google.com/p/dblinq2007/issues/detail?id=257

I had the same issue. Here' what I changed to fix it (in
src\DbLinq.PostgreSql\PgsqlSqlProvider.cs)


Index: PgsqlSqlProvider.cs
===================================================================
--- PgsqlSqlProvider.cs (revision 1411)
+++ PgsqlSqlProvider.cs (working copy)
@@ -55,6 +55,21 @@
return SqlStatement.Format("SELECT {0}",
SqlStatement.Join(", ", ids.ToArray()));
}

+ public SqlStatement GetLiteral(Guid literal)
+ {
+ return ("'" + literal.ToString("B") + "'");
+ }
+
+ public override SqlStatement GetLiteral(object literal)
+ {
+ if (literal is Guid)
+ {
+ return this.GetLiteral((Guid)literal);
+ }
+ return base.GetLiteral(literal);
+ }
+
+
public override SqlStatement GetLiteral(DateTime literal)
{
return "'" + literal.ToString("o") + "'::timestamp";
@@ -129,6 +144,7 @@

{typeof(DateTime),"timestamp"},
//{typeof(Guid),"uniqueidentifier"}
+ {typeof(Guid),"uuid"},
{typeof(byte[]),"bytea"},
};

dblin...@googlecode.com

unread,
Sep 18, 2012, 12:39:42 PM9/18/12
to dblin...@googlegroups.com

Comment #2 on issue 257 by kandrait...@gmail.com: PostgreSql uuid data type
http://code.google.com/p/dblinq2007/issues/detail?id=257

Hi!

I confirm this issue too. Though I have a slightly different patch to solve
it.

Dom

Attachments:
dblinq_postgresql_uuid_fix.patch 2.4 KB

Reply all
Reply to author
Forward
0 new messages