Skip to content

Commit

Permalink
Don't replace DateTime and DateTimeOffset by strings:
Browse files Browse the repository at this point in the history
The user still has to process the query (e.g. passing it to the query engine),
and it is at that point that handling e.g. timezone decisions should be made.
  • Loading branch information
dgeelen-uipath committed Sep 1, 2021
1 parent 7473812 commit 31b0fb9
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 125 deletions.
97 changes: 0 additions & 97 deletions QueryBuilder.Tests/Snowflake/SnowflakeParameterTests.cs

This file was deleted.

28 changes: 0 additions & 28 deletions QueryBuilder/Compilers/SnowflakeCompiler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,34 +14,6 @@ public sealed class SnowflakeCompiler : PostgresCompiler
public override string LastId =>
throw new NotSupportedException($"LastId not supported in {EngineCode} compiler");

public override string Parameter(SqlResult ctx, object parameter)
{
switch (parameter)
{
case DateTimeOffset dto:
{
// DateTimeOffset is always w.r.t. UTC
ctx.Bindings.Add(dto.ToUniversalTime().ToString("u", CultureInfo.InvariantCulture));
return "?";
}

case DateTime dt:
{
if (dt.Kind != DateTimeKind.Utc)
{
throw new ArgumentException("Unsupported DateTime kind for Snowflake compiler (must be UTC)");
}
ctx.Bindings.Add(dt.ToUniversalTime().ToString("u", CultureInfo.InvariantCulture));
return "?";
}

default:
{
return base.Parameter(ctx, parameter);
}
}
}

private class SnowflakeAggregatePercentileApproxColumn : SqlKata.AggregatePercentileApproxColumn
{
public SnowflakeAggregatePercentileApproxColumn() : base() { }
Expand Down

0 comments on commit 31b0fb9

Please sign in to comment.