diff --git a/src/FirebirdSql.EntityFrameworkCore.Firebird.Tests/Storage/FbTimeSpanTypeMappingTests.cs b/src/FirebirdSql.EntityFrameworkCore.Firebird.Tests/Storage/FbTimeSpanTypeMappingTests.cs new file mode 100644 index 000000000..95f76427c --- /dev/null +++ b/src/FirebirdSql.EntityFrameworkCore.Firebird.Tests/Storage/FbTimeSpanTypeMappingTests.cs @@ -0,0 +1,34 @@ +/* + * The contents of this file are subject to the Initial + * Developer's Public License Version 1.0 (the "License"); + * you may not use this file except in compliance with the + * License. You may obtain a copy of the License at + * https://github.com/FirebirdSQL/NETProvider/raw/master/license.txt. + * + * Software distributed under the License is distributed on + * an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either + * express or implied. See the License for the specific + * language governing rights and limitations under the License. + * + * All Rights Reserved. + */ + +//$Authors = Niek Schoemaker + +using System; +using FirebirdSql.Data.FirebirdClient; +using FirebirdSql.EntityFrameworkCore.Firebird.Storage.Internal; +using NUnit.Framework; + +namespace FirebirdSql.EntityFrameworkCore.Firebird.Tests.Storage; + +public class FbTimeSpanTypeMappingTests +{ + [Test] + public void GeneratesTimeLiteral() + { + var mapping = new FbTimeSpanTypeMapping("TIME", FbDbType.Time); + + Assert.AreEqual("CAST('07:08:09.1234' AS TIME)", mapping.GenerateSqlLiteral(new TimeSpan(0, 7, 8, 9, 123) + TimeSpan.FromTicks(4000))); + } +} diff --git a/src/FirebirdSql.EntityFrameworkCore.Firebird/Storage/Internal/FbTimeSpanTypeMapping.cs b/src/FirebirdSql.EntityFrameworkCore.Firebird/Storage/Internal/FbTimeSpanTypeMapping.cs index 0dac60aff..35c4a459d 100644 --- a/src/FirebirdSql.EntityFrameworkCore.Firebird/Storage/Internal/FbTimeSpanTypeMapping.cs +++ b/src/FirebirdSql.EntityFrameworkCore.Firebird/Storage/Internal/FbTimeSpanTypeMapping.cs @@ -48,7 +48,7 @@ protected override string GenerateNonNullSqlLiteral(object value) switch (_fbDbType) { case FbDbType.Time: - return $"CAST('{value:hh\\:mm\\:ss.ffff}' AS TIME)"; + return $"CAST('{value:hh\\:mm\\:ss\\.ffff}' AS TIME)"; default: throw new ArgumentOutOfRangeException(nameof(_fbDbType), $"{nameof(_fbDbType)}={_fbDbType}"); }