Skip to content

Sql server default values #119

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Aug 19, 2025
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
1 change: 0 additions & 1 deletion src/Migrator/Providers/Impl/Oracle/OracleDialect.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
using System;
using System.Data;
using System.Linq;
using DotNetProjects.Migrator.Framework;

namespace DotNetProjects.Migrator.Providers.Impl.Oracle;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -558,21 +558,24 @@ public override Column[] GetColumns(string table)

if (!string.IsNullOrWhiteSpace(dataDefaultString))
{
// This is only necessary because older versions of this migrator added single quotes for numerics.
var singleQuoteStrippedString = dataDefaultString.Replace("'", "");

if (column.Type == DbType.Int16 || column.Type == DbType.Int32 || column.Type == DbType.Int64)
{
column.DefaultValue = long.Parse(dataDefaultString, CultureInfo.InvariantCulture);
column.DefaultValue = long.Parse(singleQuoteStrippedString, CultureInfo.InvariantCulture);
}
else if (column.Type == DbType.Double)
{
column.DefaultValue = double.Parse(dataDefaultString, CultureInfo.InvariantCulture);
column.DefaultValue = double.Parse(singleQuoteStrippedString, CultureInfo.InvariantCulture);
}
else if (column.Type == DbType.Single)
{
column.DefaultValue = float.Parse(dataDefaultString, CultureInfo.InvariantCulture);
column.DefaultValue = float.Parse(singleQuoteStrippedString, CultureInfo.InvariantCulture);
}
else if (column.Type == DbType.Decimal)
{
column.DefaultValue = decimal.Parse(dataDefaultString, CultureInfo.InvariantCulture);
column.DefaultValue = decimal.Parse(singleQuoteStrippedString, CultureInfo.InvariantCulture);
}
else if (column.Type == DbType.Boolean)
{
Expand Down
15 changes: 4 additions & 11 deletions src/Migrator/Providers/TransformationProvider.cs
Original file line number Diff line number Diff line change
Expand Up @@ -538,26 +538,19 @@

public virtual bool ColumnExists(string table, string column, bool ignoreCase)
{
try
if (ignoreCase)
{
if (ignoreCase)
{
return GetColumns(table).Any(col => col.Name.ToLower() == column.ToLower());
}

return GetColumns(table).Any(col => col.Name == column);
}
catch (Exception)
{
return false;
return GetColumns(table).Any(x => x.Name.Equals(column, StringComparison.OrdinalIgnoreCase));
}

return GetColumns(table).Any(x => x.Name == column);
}

public virtual void ChangeColumn(string table, Column column)
{
var isUniqueSet = column.ColumnProperty.IsSet(ColumnProperty.Unique);

Check warning on line 551 in src/Migrator/Providers/TransformationProvider.cs

View workflow job for this annotation

GitHub Actions / build

'ColumnProperty.Unique' is obsolete: 'Use method 'AddUniqueConstraint' instead. This is marked being obsolete since you cannot add a name for the constraint which makes it difficult to remove the constraint again.'

column.ColumnProperty = column.ColumnProperty.Clear(ColumnProperty.Unique);

Check warning on line 553 in src/Migrator/Providers/TransformationProvider.cs

View workflow job for this annotation

GitHub Actions / build

'ColumnProperty.Unique' is obsolete: 'Use method 'AddUniqueConstraint' instead. This is marked being obsolete since you cannot add a name for the constraint which makes it difficult to remove the constraint again.'

var mapper = _dialect.GetAndMapColumnProperties(column);

Expand Down
Loading