jonpryor / dblinq2007

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

problem with not lower column names in Postgresql #24

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
In Postgresql if your column name is not ONLY lowercase (it is upper case
or mix case) you need to put it in quotes in the query. 

I made a quick and unoptimized hack in RowEnumerator.cs, ExecuteSqlCommand
method. The column description is: something that starts with dot, then
everything different than space, comma or new line. Check if my regular
expression is correct.

cmd.CommandText =
System.Text.RegularExpressions.Regex.Replace(cmd.CommandText,
"\\.[^\\s,\\n]*", CapText);
XSqlDataReader _rdr = cmd.ExecuteReader();
rdr2 = new DataReader2(_rdr);

And added this method for the match evaluator:

static string CapText(System.Text.RegularExpressions.Match m)
        {
            // Get the matched string.
            string x = m.ToString();
            // If it is NOT lower case
            if (x != x.ToLower())
                x = ".\"" + x.Substring(1) + "\"";

            return x;
        }

And it worked! :)

Original issue reported on code.google.com by Tonch...@gmail.com on 19 Jan 2008 at 11:29

GoogleCodeExporter commented 9 years ago
Codefile:InsertClauseBuilder.cs
Method:GetUpdateCommand needs also a modification:

string columnName_safe = s_vendor.FieldName_Safe(colAtt.Name); 
if (columnName_safe != columnName_safe.ToLower()) //mycode
    columnName_safe = "\"" + columnName_safe + "\""; //mycode

Original comment by Tonch...@gmail.com on 20 Jan 2008 at 12:03

GoogleCodeExporter commented 9 years ago
to make the update work with mixed case column names 

Original comment by Tonch...@gmail.com on 20 Jan 2008 at 12:09

GoogleCodeExporter commented 9 years ago
in PostgreSql

Original comment by Tonch...@gmail.com on 20 Jan 2008 at 8:00

GoogleCodeExporter commented 9 years ago
This is the same thing for Oracle, and is it probably the same thing in some 
other
databases.

Original comment by picrap on 15 Mar 2008 at 10:53

GoogleCodeExporter commented 9 years ago

Original comment by picrap on 15 Mar 2008 at 11:22

GoogleCodeExporter commented 9 years ago
Currently there is a code in svn that handles most of the cases like columns and
sequences. 

I suggest that we all use: DbLinq\Util\QuotesHelper.cs to fix this issue. Later 
it
will be easier to remove it if the problem is fixed in a better way.

Original comment by Tonch...@gmail.com on 22 Mar 2008 at 10:56

GoogleCodeExporter commented 9 years ago
QuotesHelper does not use vendors specifity, so it may be a problem.
I suggest that each IVendor implementation provides its own quotes management 
(of
course, there can be a default management in Vendor, with standard quotes).
Anton, can you work on that?

Original comment by picrap on 28 Apr 2008 at 9:51

GoogleCodeExporter commented 9 years ago
Pascal adds quoting to DbMetal. So this issue should not appear and quoting 
needs 
removed from core.

Original comment by kobrule...@gmail.com on 16 May 2008 at 11:42

GoogleCodeExporter commented 9 years ago

Original comment by picrap on 21 Sep 2008 at 9:10