-
-
Couldn't load subscription status.
- Fork 519
Description
Hello Team,
I am trying to append "AT TIME ZONE 'UTC'" for date column, but when compiling It takes whole as column name.
var selectExpression= $"{tableFromAlias}.{column} {timeZone} AS {column}";
tableFromAlias : Customer
column: DoB
timeZone: AT TIME ZONE 'UTC'
selectExpression= "Customer.DoB AT TIME ZONE 'UTC' AS DoB";
Added this to Query
query.Select(selectExpression);
When SQL is generated, its combining Time Zone as Column.
Compiler: PostGresCompiler
Actual SQL = "Select "Customer.DoB AS TIME ZONE 'UTC'" as Dob From Customer"
Expected SQL = "Select "Customer.DoB" AS TIME ZONE 'UTC' as Dob From Customer"
In Comiler.cs, this method splits with Index od " as ", so it combine the TIME ZONE as same column.
public virtual string Wrap(string value)
{
if (value.ToLowerInvariant().Contains(" as "))
{
int num = value.ToLowerInvariant().IndexOf(" as ");
string value2 = value.Substring(0, num);
string value3 = value.Substring(num + 4);
return Wrap(value2) + " " + ColumnAsKeyword + WrapValue(value3);
}
if (value.Contains("."))
{
return string.Join(".", value.Split(new char[1] { '.' }).Select((string x, int index) => WrapValue(x)));
}
return WrapValue(value);
}
Can some help out how to achieve the Expected SQL.
Thanks