-
Notifications
You must be signed in to change notification settings - Fork 56
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fixed table name not escaped when needed #7.
- Loading branch information
Martin Kostov
committed
Jan 18, 2019
1 parent
c8b2d8d
commit bcb9af2
Showing
5 changed files
with
83 additions
and
28 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
using FluentAssertions; | ||
using System.Collections.Generic; | ||
using System.ComponentModel.DataAnnotations.Schema; | ||
using System.Linq; | ||
using Xunit; | ||
|
||
namespace Dapper.Bulk.Tests | ||
{ | ||
public class EscapeTableNameTests : SqlServerTestSuite | ||
{ | ||
[Table("10_Escapes")] | ||
private class Escape | ||
{ | ||
public int Id { get; set; } | ||
|
||
[Column("10_Name")] | ||
public string Name { get; set; } | ||
} | ||
|
||
[Fact] | ||
public void EscapesTest() | ||
{ | ||
var data = new List<Escape>(); | ||
for (var i = 0; i < 10; i++) | ||
{ | ||
data.Add(new Escape { | ||
Id = i, | ||
Name = i.ToString() | ||
}); | ||
} | ||
|
||
using (var connection = this.GetConnection()) | ||
{ | ||
connection.Open(); | ||
var inserted = connection.BulkInsertAndSelect(data).ToList(); | ||
for (var i = 0; i < data.Count; i++) | ||
{ | ||
IsValidInsert(inserted[i], data[i]); | ||
} | ||
} | ||
} | ||
|
||
private static void IsValidInsert(Escape inserted, Escape toBeInserted) | ||
{ | ||
inserted.Id.Should().BePositive(); | ||
inserted.Name.Should().Be(toBeInserted.Name); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters