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

Commit e047947

Browse files
committed
Merge pull request #393 from UriHendler/master
Added test for incorrect join SQL when column on joined table has AliasAttribute
2 parents 8aa6b14 + 781ae80 commit e047947

File tree

1 file changed

+44
-0
lines changed

1 file changed

+44
-0
lines changed

tests/ServiceStack.OrmLite.Tests/UseCase/AliasedFieldUseCase.cs

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,24 @@ public class Foo
1515
public string Bar { get; set; }
1616
}
1717

18+
public class Bar
19+
{
20+
[AutoIncrement]
21+
public int Id { get; set; }
22+
23+
public string Baz { get; set; }
24+
}
25+
26+
public class User
27+
{
28+
[AutoIncrement]
29+
[Alias("User ID")]
30+
public int Id { get; set; }
31+
32+
[StringLength(100)]
33+
public string UserName { get; set; }
34+
}
35+
1836
[Test]
1937
public void CanResolveAliasedFieldNameInAnonymousType()
2038
{
@@ -38,5 +56,31 @@ public void CanResolveAliasedFieldNameInAnonymousType()
3856
}
3957
}
4058

59+
[Test]
60+
public void CanResolveAliasedFieldNameInJoinedTable()
61+
{
62+
using (IDbConnection db = OpenDbConnection())
63+
{
64+
db.DropAndCreateTable<Bar>();
65+
db.DropAndCreateTable<User>();
66+
67+
db.Insert(new User { UserName = "Peter" });
68+
db.Insert(new Bar { Baz = "Peter" });
69+
70+
var ev = db.From<Bar>()
71+
.Join<User>((x, y) => x.Id == y.Id);
72+
73+
var foos = db.Select<Foo>(ev);
74+
75+
ev = db.From<Bar>()
76+
.Join<User>((x, y) => x.Baz == y.UserName)
77+
.Where<User>(x => x.Id > 0);
78+
79+
foos = db.Select<Foo>(ev);
80+
81+
Assert.That(foos, Has.Count.EqualTo(1));
82+
}
83+
}
84+
4185
}
4286
}

0 commit comments

Comments
 (0)