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
6 changes: 5 additions & 1 deletion docs/migration-guide-12.1-to-13.md
Original file line number Diff line number Diff line change
Expand Up @@ -305,7 +305,11 @@ a UNIQUE table clause. No ownership decision may be inferred from that syntax.
Oracle now rejects nonempty `Index.IncludeColumns` and `Index.Clustered = true` before
DDL. Version 12.1 silently ignored them. Remove these options for an ordinary Oracle
index or author an explicit Oracle-specific design; a SQL Server clustered-index
request is not translated to an Oracle index-organized table.
request is not translated to an Oracle index-organized table.

Oracle column changes and default removal use `MODIFY (...)`. This disambiguates
valid column names such as `Element`, which Oracle can interpret as syntax in the
unparenthesized form, rejecting the statement with ORA-00903 or ORA-01735.

Structured metadata preserves SQL Server nonclustered primary keys and Oracle
ordered foreign-key pairs/delete actions. Foreign-key constructor arrays are copied,
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
using System;
using System.Data;
using DotNetProjects.Migrator.Framework;
using DotNetProjects.Migrator.Providers.Impl.Oracle;
using Migrator.Tests.Settings;
using NUnit.Framework;
using Oracle.ManagedDataAccess.Client;

namespace Migrator.Tests.Providers.OracleProvider;

[TestFixture]
[Category("Oracle")]
public class OracleDefaultSyntaxTests
{
[TestCase(false)]
[TestCase(true)]
public void ElementColumnDefaultCanBeRemoved(bool throughChangeColumn)
{
var connectionString = new ConfigurationReader().GetDatabaseConnectionConfigById("Oracle")?.ConnectionString;
if (string.IsNullOrEmpty(connectionString)) Assert.Ignore("No Oracle connection configured.");
using var connection = new OracleConnection(connectionString);
connection.Open();
using var provider = new OracleTransformationProvider(new OracleDialect(), connection, null, "default", "Oracle.ManagedDataAccess.Client");
var table = "Default_" + Guid.NewGuid().ToString("N")[..12];
provider.AddTable(table, new Column("Id", DbType.Int32),
new Column("Element", DbType.String, 32) { DefaultValue = "fallback" });
try
{
provider.Insert(table, ["Id"], [1]);
if (throughChangeColumn)
provider.ChangeColumn(table, new Column("Element", DbType.String, 64));
else
provider.RemoveColumnDefaultValue(table, "Element");
provider.Insert(table, ["Id"], [2]);
Assert.That(provider.ExecuteScalar("SELECT Element FROM " + table + " WHERE Id=1"), Is.EqualTo("fallback"));
Assert.That(provider.ExecuteScalar("SELECT Element FROM " + table + " WHERE Id=2"), Is.EqualTo(DBNull.Value));
}
finally
{
provider.RemoveTable(table);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -248,7 +248,7 @@

table = QuoteTableNameIfRequired(table);

ExecuteNonQuery(string.Format("ALTER TABLE {0} MODIFY {1}", table, sqlColumn));
ExecuteNonQuery(string.Format("ALTER TABLE {0} MODIFY ({1})", table, sqlColumn));
}

public override void AddColumn(string table, string sqlColumn)
Expand Down Expand Up @@ -300,7 +300,7 @@
return tables.ToArray();
}

public override Column[] GetColumns(string table)

Check warning on line 303 in src/Migrator/Providers/Impl/Oracle/OracleTransformationProvider.cs

View workflow job for this annotation

GitHub Actions / Test (Sybase)

'GetColumns' has a cyclomatic complexity of '52'. Rewrite or refactor the code to decrease its complexity below '26'. (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca1502)
{
var stringBuilder = new StringBuilder();
stringBuilder.AppendLine("SELECT");
Expand Down Expand Up @@ -655,7 +655,7 @@

public override void RemoveColumnDefaultValue(string table, string column)
{
var sql = string.Format("ALTER TABLE {0} MODIFY {1} DEFAULT NULL", QuoteTableNameIfRequired(table), QuoteColumnNameIfRequired(column));
var sql = string.Format("ALTER TABLE {0} MODIFY ({1} DEFAULT NULL)", QuoteTableNameIfRequired(table), QuoteColumnNameIfRequired(column));
ExecuteNonQuery(sql);
}

Expand Down
Loading