File tree Expand file tree Collapse file tree 3 files changed +34
-24
lines changed
NHibernate.Test/TypesTest Expand file tree Collapse file tree 3 files changed +34
-24
lines changed Original file line number Diff line number Diff line change @@ -68,16 +68,16 @@ public void PropertyType()
68
68
var propertyType25 = Sfi . GetClassMetadata ( typeof ( ChangeDefaultTypeClass ) )
69
69
. GetPropertyType ( nameof ( ChangeDefaultTypeClass . StringTypeLengthInType25 ) ) ;
70
70
Assert . That (
71
- propertyType25 ,
72
- Is . EqualTo ( _testDefaultStringType ) ) ;
71
+ propertyType25 . GetType ( ) ,
72
+ Is . EqualTo ( _testDefaultStringType . GetType ( ) ) ) ;
73
73
Assert . That ( propertyType25 . SqlTypes ( Sfi ) [ 0 ] . Length , Is . EqualTo ( 25 ) ) ;
74
74
75
75
var propertyType20 = Sfi . GetClassMetadata ( typeof ( ChangeDefaultTypeClass ) )
76
76
. GetPropertyType ( nameof ( ChangeDefaultTypeClass . StringTypeExplicitLength20 ) ) ;
77
77
78
78
Assert . That (
79
- propertyType20 ,
80
- Is . EqualTo ( _testDefaultStringType ) ) ;
79
+ propertyType20 . GetType ( ) ,
80
+ Is . EqualTo ( _testDefaultStringType . GetType ( ) ) ) ;
81
81
Assert . That ( propertyType20 . SqlTypes ( Sfi ) [ 0 ] . Length , Is . EqualTo ( 20 ) ) ;
82
82
}
83
83
Original file line number Diff line number Diff line change @@ -69,17 +69,17 @@ public void PropertyType()
69
69
var propertyType1 = Sfi . GetClassMetadata ( typeof ( ChangeDefaultTypeClass ) )
70
70
. GetPropertyType ( nameof ( ChangeDefaultTypeClass . CurrencyTypeExplicitPrecision6And3 ) ) ;
71
71
Assert . That (
72
- propertyType1 ,
73
- Is . EqualTo ( _testDefaultType ) ) ;
72
+ propertyType1 . GetType ( ) ,
73
+ Is . EqualTo ( _testDefaultType . GetType ( ) ) ) ;
74
74
Assert . That ( propertyType1 . SqlTypes ( Sfi ) [ 0 ] . Precision , Is . EqualTo ( 6 ) ) ;
75
75
Assert . That ( propertyType1 . SqlTypes ( Sfi ) [ 0 ] . Scale , Is . EqualTo ( 3 ) ) ;
76
76
77
77
var propertyType2 = Sfi . GetClassMetadata ( typeof ( ChangeDefaultTypeClass ) )
78
78
. GetPropertyType ( nameof ( ChangeDefaultTypeClass . CurrencyTypePrecisionInType5And2 ) ) ;
79
79
80
80
Assert . That (
81
- propertyType2 ,
82
- Is . EqualTo ( _testDefaultType ) ) ;
81
+ propertyType2 . GetType ( ) ,
82
+ Is . EqualTo ( _testDefaultType . GetType ( ) ) ) ;
83
83
Assert . That ( propertyType2 . SqlTypes ( Sfi ) [ 0 ] . Precision , Is . EqualTo ( 5 ) ) ;
84
84
Assert . That ( propertyType2 . SqlTypes ( Sfi ) [ 0 ] . Scale , Is . EqualTo ( 2 ) ) ;
85
85
}
Original file line number Diff line number Diff line change @@ -21,7 +21,7 @@ namespace NHibernate.SqlTypes
21
21
/// </p>
22
22
/// </remarks>
23
23
[ Serializable ]
24
- public class SqlType
24
+ public class SqlType : IEquatable < SqlType >
25
25
{
26
26
private readonly DbType dbType ;
27
27
private readonly int length ;
@@ -125,24 +125,34 @@ public override bool Equals(object obj)
125
125
126
126
public bool Equals ( SqlType rhsSqlType )
127
127
{
128
+ if ( ReferenceEquals ( this , rhsSqlType ) )
129
+ return true ;
130
+
128
131
if ( rhsSqlType == null )
129
- {
130
132
return false ;
131
- }
132
133
133
- if ( LengthDefined )
134
- {
135
- return ( DbType . Equals ( rhsSqlType . DbType ) ) && ( Length == rhsSqlType . Length ) ;
136
- }
137
- if ( PrecisionDefined )
138
- {
139
- return ( DbType . Equals ( rhsSqlType . DbType ) ) && ( Precision == rhsSqlType . Precision ) && ( Scale == rhsSqlType . Scale ) ;
140
- }
141
- if ( ScaleDefined )
142
- {
143
- return DbType . Equals ( rhsSqlType . DbType ) && Scale == rhsSqlType . Scale ;
144
- }
145
- return ( DbType . Equals ( rhsSqlType . DbType ) ) ;
134
+ if ( DbType != rhsSqlType . DbType )
135
+ return false ;
136
+
137
+ if ( LengthDefined != rhsSqlType . LengthDefined )
138
+ return false ;
139
+
140
+ if ( PrecisionDefined != rhsSqlType . PrecisionDefined )
141
+ return false ;
142
+
143
+ if ( ScaleDefined != rhsSqlType . ScaleDefined )
144
+ return false ;
145
+
146
+ if ( Length != rhsSqlType . Length )
147
+ return false ;
148
+
149
+ if ( Precision != rhsSqlType . Precision )
150
+ return false ;
151
+
152
+ if ( Scale != rhsSqlType . Scale )
153
+ return false ;
154
+
155
+ return true ;
146
156
}
147
157
148
158
public override string ToString ( )
You can’t perform that action at this time.
0 commit comments