Skip to content

Commit

Permalink
Enable current_timestamp() for current datetimeoffset
Browse files Browse the repository at this point in the history
  • Loading branch information
fubar-coder committed Aug 6, 2019
1 parent aea546b commit 0cf25c8
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
Expand Up @@ -101,6 +101,8 @@ public override string FormatSystemMethods(SystemMethods value)
return "now()";
case SystemMethods.CurrentUTCDateTime:
return "(now() at time zone 'UTC')";
case SystemMethods.CurrentDateTimeOffset:
return "current_timestamp()";
case SystemMethods.CurrentUser:
return "current_user";
}
Expand Down
Expand Up @@ -111,6 +111,17 @@ public void CanUseSystemMethodCurrentUTCDateTimeAsADefaultValueForAColumn()
result.ShouldBe("ALTER TABLE \"public\".\"NewTable\" ADD \"NewColumn\" varchar(5) NOT NULL DEFAULT (now() at time zone 'UTC');");
}

[Test]
public void CanUseSystemMethodCurrentDateTimeOffsetAsADefaultValueForAColumn()
{
const string tableName = "NewTable";
var columnDefinition = new ColumnDefinition { Name = "NewColumn", Size = 5, Type = DbType.String, DefaultValue = SystemMethods.CurrentDateTimeOffset };
var expression = new CreateColumnExpression { Column = columnDefinition, TableName = tableName };

var result = Generator.Generate(expression);
result.ShouldBe("ALTER TABLE \"public\".\"NewTable\" ADD \"NewColumn\" varchar(5) NOT NULL DEFAULT current_timestamp();");
}

[Test]
public void NonUnicodeQuotesCorrectly()
{
Expand Down

0 comments on commit 0cf25c8

Please sign in to comment.