Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
using System.Data;
using DotNetProjects.Migrator.Framework;
using Migrator.Tests.Providers.PostgreSQL.Base;
using NUnit.Framework;

namespace Migrator.Tests.Providers.PostgreSQL;

[TestFixture]
[Category("Postgre")]
public class PostgreSQLTransformationProvider_ReservedWordsTests : PostgreSQLTransformationProviderTestBase
{
[Test]
public void AddIndex_IncludeColumnsWithReservedWord_Succeeds()
{
// Arrange
const string testTableName = "MyDefaultTestTable";
const string propertyName1 = "Color1";
const string propertyName2 = "Host";

Provider.AddTable(testTableName,
new Column(propertyName1, DbType.Int32, ColumnProperty.PrimaryKeyWithIdentity),
new Column(propertyName2, DbType.Int32, ColumnProperty.Unsigned)
);

// Act/Assert
Provider.AddIndex(testTableName, new Index
{
Name = "IX_WMS_OTO_Sta_OT_Pri_OTOPos",
Unique = false,
Clustered = false,
KeyColumns = [propertyName1],
IncludeColumns = [propertyName2]
});
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,9 @@ public override string AddIndex(string table, Index index)

if (index.IncludeColumns != null && index.IncludeColumns.Length > 0)
{
includeString = $"INCLUDE ({string.Join(", ", index.IncludeColumns)})";
var includeColumnsQuoted = index.IncludeColumns.Select(x => QuoteColumnNameIfRequired(x)).ToList();

includeString = $"INCLUDE ({string.Join(", ", includeColumnsQuoted)})";
}

if (index.FilterItems != null && index.FilterItems.Count > 0)
Expand Down
Loading