@@ -2850,6 +2850,15 @@ public static class Orm
2850
2850
public const int DefaultMaxStringLength = 140 ;
2851
2851
public const string ImplicitPkName = "Id" ;
2852
2852
public const string ImplicitIndexSuffix = "Id" ;
2853
+ public static readonly Newtonsoft . Json . JsonSerializerSettings JsonSerializerSettings = new Newtonsoft . Json . JsonSerializerSettings
2854
+ {
2855
+ ContractResolver = new Newtonsoft . Json . Serialization . CamelCasePropertyNamesContractResolver
2856
+ {
2857
+ IgnoreSerializableAttribute = true ,
2858
+ IgnoreSerializableInterface = true ,
2859
+ IgnoreShouldSerializeMembers = true
2860
+ } ,
2861
+ } ;
2853
2862
2854
2863
public static Type GetType ( object obj )
2855
2864
{
@@ -2896,7 +2905,7 @@ public static string SqlType (TableMapping.Column p, bool storeDateTimeAsTicks,
2896
2905
if ( len . HasValue )
2897
2906
return "varchar(" + len . Value + ")" ;
2898
2907
2899
- return "varchar " ;
2908
+ return "text " ;
2900
2909
}
2901
2910
else if ( clrType == typeof ( TimeSpan ) ) {
2902
2911
return storeTimeSpanAsTicks ? "bigint" : "time" ;
@@ -2919,8 +2928,9 @@ public static string SqlType (TableMapping.Column p, bool storeDateTimeAsTicks,
2919
2928
else if ( clrType == typeof ( Guid ) ) {
2920
2929
return "varchar(36)" ;
2921
2930
}
2922
- else {
2923
- throw new NotSupportedException ( "Don't know about " + clrType ) ;
2931
+ else { // fallback to JSON
2932
+ return SQLite3 . LibVersionNumber ( ) >= 3009000 ? "json" : "text" ;
2933
+ //throw new NotSupportedException ("Don't know about " + clrType);
2924
2934
}
2925
2935
}
2926
2936
@@ -3334,6 +3344,10 @@ internal static void BindParameter (Sqlite3Statement stmt, int index, object val
3334
3344
else
3335
3345
SQLite3 . BindInt ( stmt , index , enumIntValue ) ;
3336
3346
}
3347
+ else if ( SQLite3 . LibVersionNumber ( ) >= 3009000 ) {
3348
+ // fallback to JSON
3349
+ SQLite3 . BindText ( stmt , index , Newtonsoft . Json . JsonConvert . SerializeObject ( value , Orm . JsonSerializerSettings ) , - 1 , NegativePointer ) ;
3350
+ }
3337
3351
else {
3338
3352
throw new NotSupportedException ( "Cannot store type: " + Orm . GetType ( value ) ) ;
3339
3353
}
@@ -3454,6 +3468,11 @@ object ReadCol (Sqlite3Statement stmt, int index, SQLite3.ColType type, Type clr
3454
3468
var text = SQLite3 . ColumnString ( stmt , index ) ;
3455
3469
return new UriBuilder ( text ) ;
3456
3470
}
3471
+ else if ( SQLite3 . LibVersionNumber ( ) >= 3009000 ) {
3472
+ // fallback to JSON
3473
+ var text = SQLite3 . ColumnString ( stmt , index ) ;
3474
+ return Newtonsoft . Json . JsonConvert . DeserializeObject ( text , clrType , Orm . JsonSerializerSettings ) ;
3475
+ }
3457
3476
else {
3458
3477
throw new NotSupportedException ( "Don't know how to read " + clrType ) ;
3459
3478
}
0 commit comments