Skip to content
This repository was archived by the owner on Dec 24, 2022. It is now read-only.

Commit f021be5

Browse files
committed
Fix SQL Server 2012 tests
1 parent 503d189 commit f021be5

File tree

6 files changed

+16
-6
lines changed

6 files changed

+16
-6
lines changed

src/ServiceStack.OrmLite.SqlServer/SqlServer2012OrmLiteDialectProvider.cs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -171,6 +171,12 @@ public override string ToCreateTableStatement(Type tableType)
171171

172172
sbColumns.Append(columnDefinition);
173173

174+
var sqlConstraint = GetCheckConstraint(fieldDef);
175+
if (sqlConstraint != null)
176+
{
177+
sbConstraints.Append(",\n" + sqlConstraint);
178+
}
179+
174180
if (fieldDef.ForeignKey == null || OrmLiteConfig.SkipForeignKeys)
175181
continue;
176182

tests/ServiceStack.OrmLite.Tests/CaptureSqlCommandFilterTests.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ public void Can_capture_command_all_Single_Apis()
118118
Assert.That(captured.SqlCommandHistory.Last().Sql.NormalizeSql(),
119119
Is.EqualTo("select id, firstname, lastname, age from person where (age = {0}) limit 1".Fmt(p)). //Sqlite
120120
Or.EqualTo("select top 1 id, firstname, lastname, age from person where (age = {0})".Fmt(p)). //SQLServer < 2012
121-
Or.EqualTo("select id, firstname, lastname, age from person where (age = {0}) order by person.id offset 0 rows fetch next 1 rows only".Fmt(p)). //SQLServer >= 2012
121+
Or.EqualTo("select id, firstname, lastname, age from person where (age = {0}) order by 1 offset 0 rows fetch next 1 rows only".Fmt(p)). //SQLServer >= 2012
122122
Or.EqualTo("select first 1 id, firstname, lastname, age from person where (age = {0})".Fmt(p))); //Firebird
123123

124124
i++; db.Exists<Person>("Age = @age", new { age = 42 });

tests/ServiceStack.OrmLite.Tests/CaptureSqlFilterTests.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,7 @@ public void Can_capture_all_Single_Apis()
118118
Assert.That(captured.SqlStatements.Last().NormalizeSql(),
119119
Is.EqualTo("select id, firstname, lastname, age from person where (age = {0}) limit 1".Fmt(p)). //sqlite
120120
Or.EqualTo("select top 1 id, firstname, lastname, age from person where (age = {0})".Fmt(p)). //SqlServer
121+
Or.EqualTo("select id, firstname, lastname, age from person where (age = {0}) order by 1 offset 0 rows fetch next 1 rows only".Fmt(p)). //SqlServer 2012+
121122
Or.EqualTo("select first 1 id, firstname, lastname, age from person where (age = {0})".Fmt(p)). //Firebird
122123
Or.EqualTo("select id, firstname, lastname, age from person where (age = {0}) order by person.id offset 0 rows fetch next 1 rows only".Fmt(p)). //VistaDB
123124
Or.EqualTo("select * from (\r select ssormlite1.*, rownum rnum from (\r select id, firstname, lastname, age from person where (age = {0}) order by person.id) ssormlite1\r where rownum <= 0 + 1) ssormlite2 where ssormlite2.rnum > 0".Fmt(p)) //Oracle

tests/ServiceStack.OrmLite.Tests/DefaultValueTests.cs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,8 @@ public void Can_filter_update_method1_to_insert_date()
110110

111111
ResetUpdateDate(db);
112112
db.Update(cmd => cmd.SetUpdateDate<DefaultValues>(nameof(DefaultValues.UpdatedDateUtc)),
113-
new DefaultValues { Id = 1, DefaultInt = 45 }, new DefaultValues { Id = 2, DefaultInt = 72 });
113+
new DefaultValues { Id = 1, DefaultInt = 45, CreatedDateUtc = DateTime.Now },
114+
new DefaultValues { Id = 2, DefaultInt = 72, CreatedDateUtc = DateTime.Now });
114115
VerifyUpdateDate(db);
115116
VerifyUpdateDate(db, id: 2);
116117
}
@@ -139,7 +140,7 @@ public void Can_filter_update_method2_to_insert_date()
139140
CreateAndInitialize(db);
140141

141142
ResetUpdateDate(db);
142-
db.Update(new DefaultValues { Id = 1, DefaultInt = 2342 }, p => p.Id == 1,
143+
db.Update(new DefaultValues { Id = 1, DefaultInt = 2342, CreatedDateUtc = DateTime.Now }, p => p.Id == 1,
143144
cmd => cmd.SetUpdateDate<DefaultValues>(nameof(DefaultValues.UpdatedDateUtc)));
144145
VerifyUpdateDate(db);
145146
}
@@ -183,7 +184,8 @@ public void Can_filter_updateAll_to_insert_date()
183184
CreateAndInitialize(db, 2);
184185

185186
ResetUpdateDate(db);
186-
db.UpdateAll(new [] { new DefaultValues { Id = 1, DefaultInt = 45 }, new DefaultValues { Id = 2, DefaultInt = 72 } },
187+
db.UpdateAll(new [] { new DefaultValues { Id = 1, DefaultInt = 45, CreatedDateUtc = DateTime.Now },
188+
new DefaultValues { Id = 2, DefaultInt = 72, CreatedDateUtc = DateTime.Now } },
187189
cmd => cmd.SetUpdateDate<DefaultValues>(nameof(DefaultValues.UpdatedDateUtc)));
188190
VerifyUpdateDate(db);
189191
VerifyUpdateDate(db, id: 2);

tests/ServiceStack.OrmLite.Tests/Expression/SqlCustomTests.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ public class SqlCustomTests : OrmLiteTestBase
3535
[Test]
3636
public void Can_use_CustomSelect_field_in_Typed_Query()
3737
{
38-
if (Dialect == Dialect.PostgreSql || Dialect == Dialect.SqlServer || Dialect == Dialect.MySql) return;
38+
if (Dialect == Dialect.PostgreSql || Dialect == Dialect.SqlServer || Dialect == Dialect.SqlServer2012 || Dialect == Dialect.MySql) return;
3939

4040
using (var db = OpenDbConnection())
4141
{

tests/ServiceStack.OrmLite.Tests/OrmLiteTestBase.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ namespace ServiceStack.OrmLite.Tests
1212
{
1313
public class Config
1414
{
15+
public const bool EnableDebugLogging = false;
1516
public static string SqliteMemoryDb = ":memory:";
1617
public static string SqliteFileDir = "~/App_Data/".MapAbsolutePath();
1718
public static string SqliteFileDb = "~/App_Data/db.sqlite".MapAbsolutePath();
@@ -124,7 +125,7 @@ private OrmLiteConnectionFactory Init()
124125
//OrmLiteConfig.UseParameterizeSqlExpressions = false;
125126

126127
//OrmLiteConfig.DeoptimizeReader = true;
127-
LogManager.LogFactory = new ConsoleLogFactory(debugEnabled: false);
128+
LogManager.LogFactory = new ConsoleLogFactory(debugEnabled: Config.EnableDebugLogging);
128129
switch (Dialect)
129130
{
130131
case Dialect.Sqlite:

0 commit comments

Comments
 (0)