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

Commit bd3ad95

Browse files
committed
Fix JoinsWithSchemas tests
1 parent 4d0d733 commit bd3ad95

File tree

3 files changed

+54
-2
lines changed

3 files changed

+54
-2
lines changed

src/ServiceStack.OrmLite/OrmLiteDialectProviderExtensions.cs

+2-2
Original file line numberDiff line numberDiff line change
@@ -37,9 +37,9 @@ public static string GetQuotedColumnName(this IOrmLiteDialectProvider dialect,
3737
}
3838

3939
public static string GetQuotedColumnName(this IOrmLiteDialectProvider dialect,
40-
ModelDefinition modelDef, FieldDefinition fieldDef)
40+
ModelDefinition tableDef, FieldDefinition fieldDef)
4141
{
42-
return dialect.GetQuotedTableName(modelDef.ModelName) +
42+
return dialect.GetQuotedTableName(tableDef) +
4343
"." +
4444
dialect.GetQuotedColumnName(fieldDef.FieldName);
4545
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
using NUnit.Framework;
2+
using ServiceStack.DataAnnotations;
3+
using ServiceStack.Text;
4+
5+
namespace ServiceStack.OrmLite.Tests.Issues
6+
{
7+
[Schema("schema1")]
8+
public class Entity1
9+
{
10+
public int Id { get; set; }
11+
12+
public int Entity2Fk { get; set; }
13+
}
14+
15+
[Schema("schema1")]
16+
public class Entity2
17+
{
18+
public int Id { get; set; }
19+
}
20+
21+
public class PlainModel
22+
{
23+
public int Entity1Id { get; set; }
24+
25+
public int Entity2Id { get; set; }
26+
}
27+
28+
public class JoinsWithSchemas : OrmLiteTestBase
29+
{
30+
[Test]
31+
public void Can_join_entities_with_Schema()
32+
{
33+
using (var db = OpenDbConnection())
34+
{
35+
db.DropAndCreateTable<Entity1>();
36+
db.DropAndCreateTable<Entity2>();
37+
38+
db.Insert(new Entity2 { Id = 1 });
39+
db.Insert(new Entity1 { Id = 2, Entity2Fk = 1 });
40+
41+
var results = db.Select<PlainModel>(
42+
db.From<Entity1>()
43+
.Join<Entity2>((e1, e2) => e1.Entity2Fk == e2.Id));
44+
45+
Assert.That(results.Count, Is.EqualTo(1));
46+
Assert.That(results[0].Entity1Id, Is.EqualTo(2));
47+
Assert.That(results[0].Entity2Id, Is.EqualTo(1));
48+
}
49+
}
50+
}
51+
}

tests/ServiceStack.OrmLite.Tests/ServiceStack.OrmLite.Tests.csproj

+1
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,7 @@
129129
<Compile Include="Expression\SqlExpressionTests.cs" />
130130
<Compile Include="Expression\SelectExpressionTests.cs" />
131131
<Compile Include="Issues\ComplexJoinWithAlias.cs" />
132+
<Compile Include="Issues\JoinsWithSchemas.cs" />
132133
<Compile Include="Issues\MismatchSchemaTests.cs" />
133134
<Compile Include="Issues\MultiColumnOrderByDescending.cs" />
134135
<Compile Include="Issues\MultiFieldReferenceTests.cs" />

0 commit comments

Comments
 (0)