Skip to content

Fix setting ScaleDefined in SqlType #3524

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
Apr 12, 2024
Merged
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
62 changes: 18 additions & 44 deletions src/NHibernate/SqlTypes/SqlType.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,71 +23,45 @@ namespace NHibernate.SqlTypes
[Serializable]
public class SqlType : IEquatable<SqlType>
{
private readonly DbType dbType;
private readonly int length;
private readonly byte precision;
private readonly byte scale;
private readonly bool lengthDefined;
private readonly bool precisionDefined;
private readonly int? _length;
private readonly byte? _precision;
private readonly byte? _scale;

public SqlType(DbType dbType)
{
this.dbType = dbType;
DbType = dbType;
}

public SqlType(DbType dbType, int length)
{
this.dbType = dbType;
this.length = length;
lengthDefined = true;
DbType = dbType;
_length = length;
}

public SqlType(DbType dbType, byte precision, byte scale)
{
this.dbType = dbType;
this.precision = precision;
this.scale = scale;
precisionDefined = true;
DbType = dbType;
_precision = precision;
_scale = scale;
}

public SqlType(DbType dbType, byte scale)
{
this.dbType = dbType;
this.scale = scale;
ScaleDefined = true;
DbType = dbType;
_scale = scale;
}

public DbType DbType
{
get { return dbType; }
}

public int Length
{
get { return length; }
}

public byte Precision
{
get { return precision; }
}
public DbType DbType { get; }

public byte Scale
{
get { return scale; }
}
public int Length => _length.GetValueOrDefault();
public byte Precision => _precision.GetValueOrDefault();
public byte Scale => _scale.GetValueOrDefault();
public bool LengthDefined => _length.HasValue;

public bool LengthDefined
{
get { return lengthDefined; }
}
public bool PrecisionDefined => _precision.HasValue;

public bool PrecisionDefined
{
get { return precisionDefined; }
}

public bool ScaleDefined { get; }
public bool ScaleDefined => _scale.HasValue;

#region System.Object Members

Expand Down
Loading