jonpryor / dblinq2007

Automatically exported from code.google.com/p/dblinq2007
0 stars 0 forks source link

Param name breaks Postgres #247

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. Run Mono on Mac.
2. Perform a query like so:

var login = "guy";
var qry = from u in db.Users where u.Login == login select u;
var user = qry.SingleOrDefault();

What is the expected output? What do you see instead?
The query is expected to complete w/o exception.  Instead, the parameter name 
that gets 
generated borks Postgres. The parameter has '<' and '>' characters in it which 
confuses Postgres.

What version of the product are you using? On what operating system?
Latest SVN on Mono / Mac OS 10.6

Please provide any additional information below.
I work-around that gets me running is:

InputParameterExpression.cs, Ln 63 - change to:
Alias = alias.Replace('<', '_').Replace('>', '_');

It seems wrong to me to rely on the expression's name to use as the parameter 
name.  Isn't that 
platform (.Net vs. Mono) specific?  Why not base it on the column name (e.g. 
":login") or just 
generate it (e.g. ":a", ":b", ":c", etc.)?

Original issue reported on code.google.com by abe.gill...@gmail.com on 27 Apr 2010 at 5:53

GoogleCodeExporter commented 9 years ago
What's the actual SQL that's generated.  You can hook up a TextWriter to the 
DataContext.Log property to see all the SQL that's generated.

Did you follow the installation instructions properly?  See: 
http://code.google.com/p/dblinq2007/wiki/Installation#To_use_DbLinq

Specifically, are you using the correct DbLinqProvider to work with PostgreSQL?

Original comment by jonmpr...@gmail.com on 27 Apr 2010 at 7:05

GoogleCodeExporter commented 9 years ago
This is the generated SQL:

SELECT "account_id", "created_on", "email", "email_key", "name", 
"password_hash", "password_salt", 
"updated_on"
        FROM "public"."accounts"
        WHERE ("email" = :<login>__1) LIMIT 2

The DbLinq provider is correct because I'm hacking my generated class and 
setting my DataContext class to 
inherit from the PgsqlDataContext class that's in the DbLinq.PostgreSql project 
so that it looks like this:

public partial class MyDbContext : PgsqlDataContext { ... }

I have to admit that I don't fully understand the MONO_STRICT conditional 
compilation symbols.  But I'm pretty 
sure it's working as it should.  Lemme know, I'll be happy to continue to help.

Original comment by abe.gill...@gmail.com on 27 Apr 2010 at 11:28