System.Data.SQLite
Check-in [da44957e76]
Not logged in

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:Add the 'BindInvariantDecimal' connection flag, enabled by default, which forces Decimal parameters to be converted to strings using the invariant culture.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: da44957e767258c02c5417b440a6ba00bc0ef2c4
User & Date: mistachkin 2017-10-17 20:01:29
Context
2017-10-18
07:11
Update comments in the session test file. check-in: 7957c296b8 user: mistachkin tags: trunk
2017-10-17
20:01
Add the 'BindInvariantDecimal' connection flag, enabled by default, which forces Decimal parameters to be converted to strings using the invariant culture. check-in: da44957e76 user: mistachkin tags: trunk
19:59
Update SQLite core library to the latest 'branch-3.21' code. check-in: 1f07d53a90 user: mistachkin tags: trunk
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to System.Data.SQLite/SQLiteBase.cs.

1255
1256
1257
1258
1259
1260
1261






1262
1263
1264
1265
1266
1267
1268
....
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326





1327
1328
1329
1330
1331
1332
1333
      /// <summary>
      /// When returning column values, always return <see cref="Decimal" />
      /// values as though they were plain text (i.e. not <see cref="Double" />,
      /// which is the legacy behavior).
      /// </summary>
      GetDecimalAsText = 0x20000000000,







      /// <summary>
      /// When binding parameter values or returning column values, always
      /// treat them as though they were plain text (i.e. no numeric,
      /// date/time, or other conversions should be attempted).
      /// </summary>
      BindAndGetAllAsText = BindAllAsText | GetAllAsText,

................................................................................
               LogModuleException,
#else
      LogAll = LogPrepare | LogPreBind | LogBind |
               LogCallbackException | LogBackup,
#endif

      /// <summary>
      /// The default extra flags for new connections.
      /// </summary>
#if INTEROP_VIRTUAL_TABLE
      Default = LogCallbackException | LogModuleException,
#else
      Default = LogCallbackException,
#endif






      /// <summary>
      /// The default extra flags for new connections with all logging enabled.
      /// </summary>
      DefaultAndLogAll = Default | LogAll
  }

  /// <summary>







>
>
>
>
>
>







 







|


|

|


>
>
>
>
>







1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
....
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
      /// <summary>
      /// When returning column values, always return <see cref="Decimal" />
      /// values as though they were plain text (i.e. not <see cref="Double" />,
      /// which is the legacy behavior).
      /// </summary>
      GetDecimalAsText = 0x20000000000,

      /// <summary>
      /// When binding <see cref="Decimal" /> parameter values, always use
      /// the invariant culture when converting their values to strings.
      /// </summary>
      BindInvariantDecimal = 0x40000000000,

      /// <summary>
      /// When binding parameter values or returning column values, always
      /// treat them as though they were plain text (i.e. no numeric,
      /// date/time, or other conversions should be attempted).
      /// </summary>
      BindAndGetAllAsText = BindAllAsText | GetAllAsText,

................................................................................
               LogModuleException,
#else
      LogAll = LogPrepare | LogPreBind | LogBind |
               LogCallbackException | LogBackup,
#endif

      /// <summary>
      /// The default logging related flags for new connections.
      /// </summary>
#if INTEROP_VIRTUAL_TABLE
      LogDefault = LogCallbackException | LogModuleException,
#else
      LogDefault = LogCallbackException,
#endif

      /// <summary>
      /// The default extra flags for new connections.
      /// </summary>
      Default = LogDefault | BindInvariantDecimal,

      /// <summary>
      /// The default extra flags for new connections with all logging enabled.
      /// </summary>
      DefaultAndLogAll = Default | LogAll
  }

  /// <summary>

Changes to System.Data.SQLite/SQLiteStatement.cs.

436
437
438
439
440
441
442



443
444
445
446
447
448
449
450
451
452
453
454
455
...
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
...
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
              _sql.Bind_Text(this, _flags, index, invariantText ?
                  SQLiteConvert.ToStringWithProvider(obj, invariantCultureInfo) :
                  SQLiteConvert.ToStringWithProvider(obj, cultureInfo));
          }

          return;
      }




      if ((_flags & SQLiteConnectionFlags.BindDecimalAsText) == SQLiteConnectionFlags.BindDecimalAsText)
      {
          if (obj is Decimal)
          {
              _sql.Bind_Text(this, _flags, index, invariantText ?
                  SQLiteConvert.ToStringWithProvider(obj, invariantCultureInfo) :
                  SQLiteConvert.ToStringWithProvider(obj, cultureInfo));

              return;
          }
      }

................................................................................
          break;
        case DbType.UInt64:
          _sql.Bind_UInt64(this, _flags, index, Convert.ToUInt64(obj, cultureInfo));
          break;
        case DbType.Single:
        case DbType.Double:
        case DbType.Currency:
        //case DbType.Decimal: // Dont store decimal as double ... loses precision
          _sql.Bind_Double(this, _flags, index, Convert.ToDouble(obj, cultureInfo));
          break;
        case DbType.Binary:
          _sql.Bind_Blob(this, _flags, index, (byte[])obj);
          break;
        case DbType.Guid:
          if (_command.Connection._binaryGuid == true)
................................................................................
          {
            _sql.Bind_Text(this, _flags, index, invariantText ?
              SQLiteConvert.ToStringWithProvider(obj, invariantCultureInfo) :
              SQLiteConvert.ToStringWithProvider(obj, cultureInfo));
          }
          break;
        case DbType.Decimal: // Dont store decimal as double ... loses precision
          _sql.Bind_Text(this, _flags, index, invariantText ?
              SQLiteConvert.ToStringWithProvider(Convert.ToDecimal(obj, cultureInfo), invariantCultureInfo) :
              SQLiteConvert.ToStringWithProvider(Convert.ToDecimal(obj, cultureInfo), cultureInfo));
          break;
        default:
          _sql.Bind_Text(this, _flags, index, invariantText ?
              SQLiteConvert.ToStringWithProvider(obj, invariantCultureInfo) :
              SQLiteConvert.ToStringWithProvider(obj, cultureInfo));
          break;
      }







>
>
>





|







 







<







 







|
|
|







436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
...
494
495
496
497
498
499
500

501
502
503
504
505
506
507
...
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
              _sql.Bind_Text(this, _flags, index, invariantText ?
                  SQLiteConvert.ToStringWithProvider(obj, invariantCultureInfo) :
                  SQLiteConvert.ToStringWithProvider(obj, cultureInfo));
          }

          return;
      }

      bool invariantDecimal = ((_flags & SQLiteConnectionFlags.BindInvariantDecimal)
          == SQLiteConnectionFlags.BindInvariantDecimal);

      if ((_flags & SQLiteConnectionFlags.BindDecimalAsText) == SQLiteConnectionFlags.BindDecimalAsText)
      {
          if (obj is Decimal)
          {
              _sql.Bind_Text(this, _flags, index, invariantText || invariantDecimal ?
                  SQLiteConvert.ToStringWithProvider(obj, invariantCultureInfo) :
                  SQLiteConvert.ToStringWithProvider(obj, cultureInfo));

              return;
          }
      }

................................................................................
          break;
        case DbType.UInt64:
          _sql.Bind_UInt64(this, _flags, index, Convert.ToUInt64(obj, cultureInfo));
          break;
        case DbType.Single:
        case DbType.Double:
        case DbType.Currency:

          _sql.Bind_Double(this, _flags, index, Convert.ToDouble(obj, cultureInfo));
          break;
        case DbType.Binary:
          _sql.Bind_Blob(this, _flags, index, (byte[])obj);
          break;
        case DbType.Guid:
          if (_command.Connection._binaryGuid == true)
................................................................................
          {
            _sql.Bind_Text(this, _flags, index, invariantText ?
              SQLiteConvert.ToStringWithProvider(obj, invariantCultureInfo) :
              SQLiteConvert.ToStringWithProvider(obj, cultureInfo));
          }
          break;
        case DbType.Decimal: // Dont store decimal as double ... loses precision
          _sql.Bind_Text(this, _flags, index, invariantText || invariantDecimal ?
            SQLiteConvert.ToStringWithProvider(Convert.ToDecimal(obj, cultureInfo), invariantCultureInfo) :
            SQLiteConvert.ToStringWithProvider(Convert.ToDecimal(obj, cultureInfo), cultureInfo));
          break;
        default:
          _sql.Bind_Text(this, _flags, index, invariantText ?
              SQLiteConvert.ToStringWithProvider(obj, invariantCultureInfo) :
              SQLiteConvert.ToStringWithProvider(obj, cultureInfo));
          break;
      }