Permalink
Browse files

Rearrange order in InsertIntoSelect test + switch to use command.Orig…

…inal
  • Loading branch information...
mythz committed Nov 30, 2018
1 parent 4b2e549 commit 4d59306f1a94ddb18a4ed9b640b4c6e6aeac9040
@@ -700,7 +700,7 @@ internal static long InsertIntoSelect<T>(this IDbCommand dbCmd, ISqlExpression q
.ParseCommands();

var fieldsOrAliases = selectFields
.Map(x => x.Name.LastRightPart("AS").Trim().StripQuotes());
.Map(x => x.Original.ToString().LastRightPart("AS").Trim().StripQuotes());

dialectProvider.PrepareParameterizedInsertStatement<T>(dbCmd, insertFields: fieldsOrAliases);

@@ -383,7 +383,7 @@ public void Can_InsertIntoSelect_using_Custom_Select()
{
db.DropAndCreateTable<UserAuth>();
db.DropAndCreateTable<SubUserAuth>();

var userAuth = new UserAuth {
Id = 1,
UserName = "UserName",
@@ -399,14 +399,16 @@ public void Can_InsertIntoSelect_using_Custom_Select()
};
db.Insert(userAuth);

// OrmLiteUtils.PrintSql();

var q = db.From<UserAuth>()
.Where(x => x.UserName == "UserName")
.Select(x => new {
x.UserName,
x.Email,
FullName = x.FirstName + " " + x.LastName,
GivenName = x.FirstName,
Surname = x.LastName,
FullName = x.FirstName + " " + x.LastName
x.Email,
x.UserName,
});

var rowsInserted = db.InsertIntoSelect<SubUserAuth>(q);

0 comments on commit 4d59306

Please sign in to comment.