@@ -22,12 +22,14 @@ public void ProductLevel_ReturnsRTM()
2222 public void EngineEdition_Returns3AsInt ( )
2323 => AreEqual ( 3 , new Simulation ( ) . ExecuteScalar ( "select serverproperty('EngineEdition')" ) ) ;
2424
25+ // The projection is sql_variant (like real); each cell surfaces its inner
26+ // CLR type — EngineEdition an int, SqlCharSet / SqlSortOrder a tinyint byte.
2527 [ TestMethod ]
26- public void EngineEdition_SurfacesAsIntType ( )
28+ public void EngineEdition_SurfacesAsVariantWithIntInner ( )
2729 {
2830 using var reader = new Simulation ( ) . ExecuteReader ( "select serverproperty('EngineEdition')" ) ;
2931 IsTrue ( reader . Read ( ) ) ;
30- AreEqual ( "int " , reader . GetDataTypeName ( 0 ) ) ;
32+ AreEqual ( "sql_variant " , reader . GetDataTypeName ( 0 ) ) ;
3133 _ = Assert . IsInstanceOfType < int > ( reader . GetValue ( 0 ) ) ;
3234 AreEqual ( 3 , reader . GetValue ( 0 ) ) ;
3335 }
@@ -37,7 +39,7 @@ public void SqlCharSet_ReturnsTinyIntOne()
3739 {
3840 using var reader = new Simulation ( ) . ExecuteReader ( "select serverproperty('SqlCharSet')" ) ;
3941 IsTrue ( reader . Read ( ) ) ;
40- AreEqual ( "tinyint " , reader . GetDataTypeName ( 0 ) ) ;
42+ AreEqual ( "sql_variant " , reader . GetDataTypeName ( 0 ) ) ;
4143 AreEqual ( ( byte ) 1 , reader . GetValue ( 0 ) ) ;
4244 }
4345
@@ -46,7 +48,7 @@ public void SqlSortOrder_ReturnsTinyInt52OnDefaultCollation()
4648 {
4749 using var reader = new Simulation ( ) . ExecuteReader ( "select serverproperty('SqlSortOrder')" ) ;
4850 IsTrue ( reader . Read ( ) ) ;
49- AreEqual ( "tinyint " , reader . GetDataTypeName ( 0 ) ) ;
51+ AreEqual ( "sql_variant " , reader . GetDataTypeName ( 0 ) ) ;
5052 AreEqual ( ( byte ) 52 , reader . GetValue ( 0 ) ) ;
5153 }
5254
@@ -74,20 +76,30 @@ public void ProductUpdateReference_ReturnsKb()
7476 public void ResourceVersion_ReturnsReferenceBuild ( )
7577 => AreEqual ( "17.00.4065" , new Simulation ( ) . ExecuteScalar ( "select serverproperty('ResourceVersion')" ) ) ;
7678
79+ // The result is always sql_variant, whether or not the name argument is a
80+ // compile-time constant (a runtime @variable resolves the same value).
7781 [ TestMethod ]
78- public void NonConstantName_FallsBackToNVarchar ( )
79- => AreEqual ( "3" , new Simulation ( ) . ExecuteScalar (
82+ public void NonConstantName_StillReturnsVariantInner ( )
83+ => AreEqual ( 3 , new Simulation ( ) . ExecuteScalar (
8084 "declare @p nvarchar(30) = 'EngineEdition'; select serverproperty(@p)" ) ) ;
8185
82- // Typed values must survive set-op schema unification. int (EngineEdition)
83- // and tinyint (SqlCharSet) promote to int per data-type precedence. Mixing
84- // a numeric property with a string one instead raises a conversion error
85- // (int outranks nvarchar) — a deliberate divergence from real SQL Server,
86- // where every SERVERPROPERTY is sql_variant so no promotion occurs.
86+ // sql_variant UNION ALL keeps each row's own inner base type — no schema
87+ // unification / promotion (matching real, where SERVERPROPERTY is
88+ // sql_variant). Mixing a numeric property with a string one now succeeds
89+ // where the old bare-type substitution raised a conversion error.
8790 [ TestMethod ]
88- public void UnionOfNumericProperties_PromotesToInt ( )
89- => AreEqual ( 3 , new Simulation ( ) . ExecuteScalar (
90- "SELECT SERVERPROPERTY('EngineEdition') UNION ALL SELECT SERVERPROPERTY('SqlCharSet')" ) ) ;
91+ public void UnionOfMixedInnerProperties_KeepsPerRowInnerTypes ( )
92+ {
93+ using var reader = new Simulation ( ) . ExecuteReader (
94+ "SELECT SERVERPROPERTY('EngineEdition') AS v UNION ALL SELECT SERVERPROPERTY('Edition')" ) ;
95+ AreEqual ( "sql_variant" , reader . GetDataTypeName ( 0 ) ) ;
96+ IsTrue ( reader . Read ( ) ) ;
97+ _ = Assert . IsInstanceOfType < int > ( reader . GetValue ( 0 ) ) ;
98+ AreEqual ( 3 , reader . GetValue ( 0 ) ) ;
99+ IsTrue ( reader . Read ( ) ) ;
100+ _ = Assert . IsInstanceOfType < string > ( reader . GetValue ( 0 ) ) ;
101+ AreEqual ( "Developer Edition (64-bit)" , reader . GetValue ( 0 ) ) ;
102+ }
91103
92104 [ TestMethod ]
93105 public void Collation_ReturnsServerCollation ( )
0 commit comments