@@ -88,17 +88,19 @@ void Sys(string name, HeapColumn[] columns, Func<Parser.BatchContext, Database,
8888 // attached to schemas / tables / columns / etc. via the
8989 // sp_addextendedproperty / sp_updateextendedproperty /
9090 // sp_dropextendedproperty trio. Real SQL Server's `value` column is
91- // typed `sql_variant` — the simulator surfaces it as `nvarchar(MAX)`
92- // since sql_variant isn't modeled; AW's 538 properties are all
93- // nvarchar values so functional fidelity is preserved.
91+ // typed `sql_variant`, carrying the base type of the value the sproc
92+ // stored (nvarchar for an N'…' literal, varchar for a plain literal).
93+ // The simulator surfaces it as sql_variant too so DacFx reads the
94+ // base type off the wire and re-scripts the value with the correct
95+ // N-prefix on export — a BACPAC round-trip preserves nvarchar.
9496 Sys ( "extended_properties" ,
9597 [
9698 new ( "class" , SqlType . TinyInt , null , false ) ,
9799 new ( "class_desc" , SqlType . SystemName , 60 , true ) ,
98100 new ( "major_id" , SqlType . Int32 , null , false ) ,
99101 new ( "minor_id" , SqlType . Int32 , null , false ) ,
100102 new ( "name" , SqlType . SystemName , 128 , false ) ,
101- new ( "value" , NVarcharSqlType . Get ( - 1 , Collation . Baseline , Coercibility . CoercibleDefault ) , SqlType . MaxLengthSentinel , true ) ,
103+ new ( "value" , SqlType . SqlVariant , null , true ) ,
102104 ] , EnumerateSysExtendedProperties ) ;
103105
104106 // sys.database_principals: probe-confirmed shipped subset of columns
@@ -471,10 +473,10 @@ void Sys(string name, HeapColumn[] columns, Func<Parser.BatchContext, Database,
471473 /// derived from the class number per real SQL Server's enum (0 =
472474 /// DATABASE, 1 = OBJECT_OR_COLUMN, 3 = SCHEMA — the only classes the
473475 /// simulator currently emits; others fall through as the string form
474- /// of the class number for forward compat). Value is coerced to
475- /// <c>nvarchar(MAX) </c> since the simulator doesn't model
476- /// <c>sql_variant</c>; for AW's all- nvarchar workload, this is a
477- /// lossless surfacing .
476+ /// of the class number for forward compat). Value is surfaced as a
477+ /// <c>sql_variant </c> wrapping the stored value's own type, so the value's
478+ /// base type ( nvarchar vs varchar) survives to <c>SQL_VARIANT_PROPERTY</c>
479+ /// and the TDS wire — DacFx reads it to re-script the correct N-prefix .
478480 /// </summary>
479481 private static IEnumerable < SqlValue [ ] > EnumerateSysExtendedProperties ( Parser . BatchContext batch , Database database )
480482 {
@@ -495,7 +497,7 @@ private static IEnumerable<SqlValue[]> EnumerateSysExtendedProperties(Parser.Bat
495497 SqlValue . FromInt32 ( key . MajorId ) ,
496498 SqlValue . FromInt32 ( key . MinorId ) ,
497499 SqlValue . FromSystemName ( key . Name ) ,
498- kvp . Value . IsNull ? SqlValue . Null ( NVarcharSqlType . Get ( - 1 , Collation . Baseline , Coercibility . CoercibleDefault ) ) : kvp . Value . CoerceTo ( NVarcharSqlType . Get ( - 1 , Collation . Baseline , Coercibility . CoercibleDefault ) ) ,
500+ kvp . Value . IsNull ? SqlValue . Null ( SqlType . SqlVariant ) : SqlValue . FromVariant ( kvp . Value ) ,
499501 ] ;
500502 }
501503 }
0 commit comments