System.Data.SQLite

Check-in [d81d546e99]
Login

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

Overview
Comment:Honor the DateTimeFormat and DateTimeKind connection string properties even when the BindAllAsText connection flag is in use.
Downloads: Tarball | ZIP archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: d81d546e990940f5222c723325b7af7e8479ceae
User & Date: mistachkin 2013-05-29 23:04:29.653
Context
2013-05-30
00:44
Add DateTimeFormatString connection string property to allow the DateTime format string used for all parsing and formatting to be overridden. Disable use of the new connection string parsing algorithm when the No_SQLiteConnectionNewParser environment variable is set. Pursuant to [bbdda6eae2]. check-in: 4f933521a1 user: mistachkin tags: trunk
2013-05-29
23:04
Honor the DateTimeFormat and DateTimeKind connection string properties even when the BindAllAsText connection flag is in use. check-in: d81d546e99 user: mistachkin tags: trunk
23:03
Adjust CryptoAPI codec to support v2 interfaces. check-in: 4a11e7c65a user: mistachkin tags: trunk
Changes
Unified Diff Show Whitespace Changes Patch
Changes to System.Data.SQLite/SQLiteConvert.cs.
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50

    /// <summary>
    /// The format string for DateTime values when using the InvariantCulture or CurrentCulture formats.
    /// </summary>
    private const string FullFormat = "yyyy-MM-ddTHH:mm:ss.fffffffK";

    /// <summary>
    /// An array of ISO8601 datetime formats we support conversion from
    /// </summary>
    private static string[] _datetimeFormats = new string[] {
      "THHmmssK",
      "THHmmK",
      "HH:mm:ss.FFFFFFFK",
      "HH:mm:ssK",
      "HH:mmK",







|







36
37
38
39
40
41
42
43
44
45
46
47
48
49
50

    /// <summary>
    /// The format string for DateTime values when using the InvariantCulture or CurrentCulture formats.
    /// </summary>
    private const string FullFormat = "yyyy-MM-ddTHH:mm:ss.fffffffK";

    /// <summary>
    /// An array of ISO-8601 DateTime formats that we support parsing.
    /// </summary>
    private static string[] _datetimeFormats = new string[] {
      "THHmmssK",
      "THHmmK",
      "HH:mm:ss.FFFFFFFK",
      "HH:mm:ssK",
      "HH:mmK",
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
                    return DateTime.SpecifyKind(DateTime.Parse(
                        dateText, DateTimeFormatInfo.CurrentInfo,
                        kind == DateTimeKind.Utc ?
                            DateTimeStyles.AdjustToUniversal :
                            DateTimeStyles.None),
                        kind);
                }
            default:
                {
                    return DateTime.SpecifyKind(DateTime.ParseExact(
                        dateText, _datetimeFormats,
                        DateTimeFormatInfo.InvariantInfo,
                        kind == DateTimeKind.Utc ?
                            DateTimeStyles.AdjustToUniversal :
                            DateTimeStyles.None),







|







315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
                    return DateTime.SpecifyKind(DateTime.Parse(
                        dateText, DateTimeFormatInfo.CurrentInfo,
                        kind == DateTimeKind.Utc ?
                            DateTimeStyles.AdjustToUniversal :
                            DateTimeStyles.None),
                        kind);
                }
            default: /* ISO-8601 */
                {
                    return DateTime.SpecifyKind(DateTime.ParseExact(
                        dateText, _datetimeFormats,
                        DateTimeFormatInfo.InvariantInfo,
                        kind == DateTimeKind.Utc ?
                            DateTimeStyles.AdjustToUniversal :
                            DateTimeStyles.None),
Changes to System.Data.SQLite/SQLiteStatement.cs.
313
314
315
316
317
318
319



320

321
322
323
324
325
326
327
      {
          _sql.Bind_Null(this, _flags, index);
        return;
      }

      if ((_flags & SQLiteConnectionFlags.BindAllAsText) == SQLiteConnectionFlags.BindAllAsText)
      {



          _sql.Bind_Text(this, _flags, index, obj.ToString());

          return;
      }

      switch (objType)
      {
        case DbType.Date:
        case DbType.Time:







>
>
>

>







313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
      {
          _sql.Bind_Null(this, _flags, index);
        return;
      }

      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, obj.ToString());

          return;
      }

      switch (objType)
      {
        case DbType.Date:
        case DbType.Time:
Changes to Tests/basic.eagle.
2342
2343
2344
2345
2346
2347
2348



















2349
2350
2351
2352
2353
2354
2355
  list $result(1) $result(2) $result(3) $result(4) $result(5) $result(6) \
      $result(7) $result(8)
} -cleanup {
  unset -nocomplain result sql
} -constraints {eagle monoBug28 SQLite System.Data.SQLite} -match regexp \
-result {^\{\} 1 System#DBNull#\d+ System#Data#SQLite#SQLiteDataReader#\d+ \{\}\
1 1 System#Data#SQLite#SQLiteDataReader#\d+$}}




















###############################################################################

unset -nocomplain systemDataSQLiteDllFile systemDataSQLiteLinqDllFile \
    testExeFile testLinqExeFile northwindEfDbFile testLinqOutFile

###############################################################################







>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>







2342
2343
2344
2345
2346
2347
2348
2349
2350
2351
2352
2353
2354
2355
2356
2357
2358
2359
2360
2361
2362
2363
2364
2365
2366
2367
2368
2369
2370
2371
2372
2373
2374
  list $result(1) $result(2) $result(3) $result(4) $result(5) $result(6) \
      $result(7) $result(8)
} -cleanup {
  unset -nocomplain result sql
} -constraints {eagle monoBug28 SQLite System.Data.SQLite} -match regexp \
-result {^\{\} 1 System#DBNull#\d+ System#Data#SQLite#SQLiteDataReader#\d+ \{\}\
1 1 System#Data#SQLite#SQLiteDataReader#\d+$}}

###############################################################################

runTest {test data-1.49 {BindAllAsText w/DateTime} -setup {
  setupDb [set fileName data-1.49.db] "" Ticks Utc BindAllAsText
} -body {
  sql execute $db "CREATE TABLE t1(x);"

  list [sql execute $db "INSERT INTO t1 (x) VALUES(?);" \
      [list param1 DateTime [set dateTime [object invoke DateTime Parse \
      "2000.02.29 13:59:58.1234567Z"]]]] [sql execute -execute reader \
      -format list $db "SELECT x FROM t1;"]
} -cleanup {
  cleanupDb $fileName

  unset -nocomplain dateTime db fileName
} -constraints \
{eagle monoBug28 command.sql compile.DATA SQLite System.Data.SQLite} -result \
{1 630874007980000000}}

###############################################################################

unset -nocomplain systemDataSQLiteDllFile systemDataSQLiteLinqDllFile \
    testExeFile testLinqExeFile northwindEfDbFile testLinqOutFile

###############################################################################