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

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

Overview
Comment:Stop using ToString calls within the parameter binding subsystem that do not take into account the configured culture information.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: fb6160ee72a69c9892a9bce426848fe6bc66e613
User & Date: mistachkin 2017-10-04 19:52:01
Context
2017-10-08
04:57
Pickup release archive verification tool changes from upstream. check-in: 2451d95590 user: mistachkin tags: trunk
2017-10-05
03:26
Work-in-progress on supporting the 'sessions' extension to the SQLite core library. check-in: 2ce0ba7f72 user: mistachkin tags: sessions
2017-10-04
19:52
Stop using ToString calls within the parameter binding subsystem that do not take into account the configured culture information. check-in: fb6160ee72 user: mistachkin tags: trunk
2017-09-29
16:59
Update Eagle in externals to the beta 40 release. check-in: e4d08f6098 user: mistachkin tags: trunk
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

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

412
413
414
415
416
417
418

419
420





421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
...
505
506
507
508
509
510
511
512
513
514
515
516


517
518
519
520
521
522
523
524
525
526
527
528
      if ((obj == null) || Convert.IsDBNull(obj))
      {
          _sql.Bind_Null(this, _flags, index);
        return;
      }

      CultureInfo invariantCultureInfo = CultureInfo.InvariantCulture;

      bool invariantText = ((_flags & SQLiteConnectionFlags.BindInvariantText)
          == SQLiteConnectionFlags.BindInvariantText);






      if ((_flags & SQLiteConnectionFlags.BindAllAsText) == SQLiteConnectionFlags.BindAllAsText)
      {
          if (obj is DateTime)
          {
              _sql.Bind_DateTime(this, _flags, index, (DateTime)obj);
          }
          else
          {
              _sql.Bind_Text(this, _flags, index, invariantText ?
                  SQLiteConvert.ToStringWithProvider(obj, invariantCultureInfo) :
                  obj.ToString());
          }

          return;
      }

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

              return;
          }
      }

      CultureInfo cultureInfo = CultureInfo.CurrentCulture;

      if ((_flags & SQLiteConnectionFlags.ConvertInvariantText) == SQLiteConnectionFlags.ConvertInvariantText)
          cultureInfo = invariantCultureInfo;

      switch (objType)
      {
        case DbType.Date:
        case DbType.Time:
        case DbType.DateTime:
          //
          // NOTE: The old method (commented below) does not honor the selected date format
................................................................................
          {
            _sql.Bind_Blob(this, _flags, index, ((Guid)obj).ToByteArray());
          }
          else
          {
            _sql.Bind_Text(this, _flags, index, invariantText ?
              SQLiteConvert.ToStringWithProvider(obj, invariantCultureInfo) :
              obj.ToString());
          }
          break;
        case DbType.Decimal: // Dont store decimal as double ... loses precision
          _sql.Bind_Text(this, _flags, index, Convert.ToDecimal(obj, cultureInfo).ToString(invariantCultureInfo));


          break;
        default:
          _sql.Bind_Text(this, _flags, index, invariantText ?
            SQLiteConvert.ToStringWithProvider(obj, invariantCultureInfo) :
            obj.ToString());
          break;
      }
    }

    internal string[] TypeDefinitions
    {
      get { return _types; }







>


>
>
>
>
>











|











|





<
<
<
<
<







 







|



|
>
>



|
|







412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455





456
457
458
459
460
461
462
...
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
      if ((obj == null) || Convert.IsDBNull(obj))
      {
          _sql.Bind_Null(this, _flags, index);
        return;
      }

      CultureInfo invariantCultureInfo = CultureInfo.InvariantCulture;

      bool invariantText = ((_flags & SQLiteConnectionFlags.BindInvariantText)
          == SQLiteConnectionFlags.BindInvariantText);

      CultureInfo cultureInfo = CultureInfo.CurrentCulture;

      if ((_flags & SQLiteConnectionFlags.ConvertInvariantText) == SQLiteConnectionFlags.ConvertInvariantText)
          cultureInfo = invariantCultureInfo;

      if ((_flags & SQLiteConnectionFlags.BindAllAsText) == SQLiteConnectionFlags.BindAllAsText)
      {
          if (obj is DateTime)
          {
              _sql.Bind_DateTime(this, _flags, index, (DateTime)obj);
          }
          else
          {
              _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;
          }
      }






      switch (objType)
      {
        case DbType.Date:
        case DbType.Time:
        case DbType.DateTime:
          //
          // NOTE: The old method (commented below) does not honor the selected date format
................................................................................
          {
            _sql.Bind_Blob(this, _flags, index, ((Guid)obj).ToByteArray());
          }
          else
          {
            _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;
      }
    }

    internal string[] TypeDefinitions
    {
      get { return _types; }