-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #188 from OctopusDeploy/core/change-default-select…
…-behaviour Change default TableColumnNameResolver back to Select All
- Loading branch information
Showing
8 changed files
with
92 additions
and
11 deletions.
There are no files selected for viewing
28 changes: 28 additions & 0 deletions
28
source/Nevermore.IntegrationTests/Advanced/JsonLastTableColumnResolverFixture.cs
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,28 @@ | ||
using System; | ||
using FluentAssertions; | ||
using Nevermore.IntegrationTests.Model; | ||
using Nevermore.IntegrationTests.SetUp; | ||
using Nevermore.TableColumnNameResolvers; | ||
using NUnit.Framework; | ||
|
||
namespace Nevermore.IntegrationTests.Advanced | ||
{ | ||
public class JsonLastTableColumnResolverFixture : FixtureWithRelationalStore | ||
{ | ||
public override void OneTimeSetUp() | ||
{ | ||
base.OneTimeSetUp(); | ||
NoMonkeyBusiness(); | ||
Configuration.TableColumnNameResolver = executor => new JsonLastTableColumnNameResolver(executor); | ||
} | ||
|
||
[Test] | ||
public void ShouldSelectAllColumnNamesWithJsonLast() | ||
{ | ||
using var readTransaction = Store.BeginReadTransaction(); | ||
var selectQuery = readTransaction.Query<Customer>().DebugViewRawQuery(); | ||
|
||
selectQuery.Should().Be($"SELECT Id,FirstName,LastName,Nickname,Roles,Balance,IsVip,JSON{Environment.NewLine}FROM [TestSchema].[Customer]{Environment.NewLine}ORDER BY [Id]"); | ||
} | ||
} | ||
} |
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,56 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using FluentAssertions; | ||
using Nevermore.TableColumnNameResolvers; | ||
using NUnit.Framework; | ||
|
||
namespace Nevermore.Tests | ||
{ | ||
public class CachingTableColumnNamesFixture | ||
{ | ||
class MockTableNameResolverForCaching : ITableColumnNameResolver | ||
{ | ||
public static int TimesQueried; | ||
|
||
readonly Dictionary<string, string[]> tableToColumnNames; | ||
|
||
public MockTableNameResolverForCaching(Dictionary<string, string[]> tableToColumnNames) | ||
{ | ||
this.tableToColumnNames = tableToColumnNames; | ||
} | ||
|
||
public string[] GetColumnNames(string schemaName, string tableName) | ||
{ | ||
TimesQueried++; | ||
if (tableToColumnNames.ContainsKey(tableName)) | ||
{ | ||
return tableToColumnNames[tableName]; | ||
} | ||
|
||
throw new Exception($"Column names for table {tableName} were not specified in creation"); | ||
} | ||
} | ||
|
||
[Test] | ||
public void ShouldCacheColumnNameForSchema() | ||
{ | ||
const string tableName = "VideoGame"; | ||
var columnNames = new[] {"Title", "Genre", "ReleaseDate"}; | ||
|
||
var tableCache = new TableColumnsCache(); | ||
var map = new Dictionary<string, string[]>(); | ||
map.Add(tableName, columnNames); | ||
var cachingColumnNameResolvers = new CachingTableColumnNameResolver( | ||
new MockTableNameResolverForCaching(map), tableCache); | ||
|
||
var columns = cachingColumnNameResolvers.GetColumnNames("", tableName); | ||
columns.Should().BeEquivalentTo(columnNames); | ||
|
||
// Query again to hit the caching | ||
cachingColumnNameResolvers.GetColumnNames("", tableName); | ||
columns.Should().BeEquivalentTo(columnNames); | ||
|
||
MockTableNameResolverForCaching.TimesQueried.Should().Be(1); | ||
} | ||
} | ||
} |
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