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

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 | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: d81d546e990940f5222c723325b7af7e8479ceae
User & Date: mistachkin 2013-05-29 23:04:29
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
Hide Diffs Side-by-Side Diffs Ignore Whitespace Patch

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

    36     36   
    37     37       /// <summary>
    38     38       /// The format string for DateTime values when using the InvariantCulture or CurrentCulture formats.
    39     39       /// </summary>
    40     40       private const string FullFormat = "yyyy-MM-ddTHH:mm:ss.fffffffK";
    41     41   
    42     42       /// <summary>
    43         -    /// An array of ISO8601 datetime formats we support conversion from
           43  +    /// An array of ISO-8601 DateTime formats that we support parsing.
    44     44       /// </summary>
    45     45       private static string[] _datetimeFormats = new string[] {
    46     46         "THHmmssK",
    47     47         "THHmmK",
    48     48         "HH:mm:ss.FFFFFFFK",
    49     49         "HH:mm:ssK",
    50     50         "HH:mmK",
................................................................................
   315    315                       return DateTime.SpecifyKind(DateTime.Parse(
   316    316                           dateText, DateTimeFormatInfo.CurrentInfo,
   317    317                           kind == DateTimeKind.Utc ?
   318    318                               DateTimeStyles.AdjustToUniversal :
   319    319                               DateTimeStyles.None),
   320    320                           kind);
   321    321                   }
   322         -            default:
          322  +            default: /* ISO-8601 */
   323    323                   {
   324    324                       return DateTime.SpecifyKind(DateTime.ParseExact(
   325    325                           dateText, _datetimeFormats,
   326    326                           DateTimeFormatInfo.InvariantInfo,
   327    327                           kind == DateTimeKind.Utc ?
   328    328                               DateTimeStyles.AdjustToUniversal :
   329    329                               DateTimeStyles.None),

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

   313    313         {
   314    314             _sql.Bind_Null(this, _flags, index);
   315    315           return;
   316    316         }
   317    317   
   318    318         if ((_flags & SQLiteConnectionFlags.BindAllAsText) == SQLiteConnectionFlags.BindAllAsText)
   319    319         {
   320         -          _sql.Bind_Text(this, _flags, index, obj.ToString());
          320  +          if (obj is DateTime)
          321  +              _sql.Bind_DateTime(this, _flags, index, (DateTime)obj);
          322  +          else
          323  +              _sql.Bind_Text(this, _flags, index, obj.ToString());
          324  +
   321    325             return;
   322    326         }
   323    327   
   324    328         switch (objType)
   325    329         {
   326    330           case DbType.Date:
   327    331           case DbType.Time:

Changes to Tests/basic.eagle.

  2342   2342     list $result(1) $result(2) $result(3) $result(4) $result(5) $result(6) \
  2343   2343         $result(7) $result(8)
  2344   2344   } -cleanup {
  2345   2345     unset -nocomplain result sql
  2346   2346   } -constraints {eagle monoBug28 SQLite System.Data.SQLite} -match regexp \
  2347   2347   -result {^\{\} 1 System#DBNull#\d+ System#Data#SQLite#SQLiteDataReader#\d+ \{\}\
  2348   2348   1 1 System#Data#SQLite#SQLiteDataReader#\d+$}}
         2349  +
         2350  +###############################################################################
         2351  +
         2352  +runTest {test data-1.49 {BindAllAsText w/DateTime} -setup {
         2353  +  setupDb [set fileName data-1.49.db] "" Ticks Utc BindAllAsText
         2354  +} -body {
         2355  +  sql execute $db "CREATE TABLE t1(x);"
         2356  +
         2357  +  list [sql execute $db "INSERT INTO t1 (x) VALUES(?);" \
         2358  +      [list param1 DateTime [set dateTime [object invoke DateTime Parse \
         2359  +      "2000.02.29 13:59:58.1234567Z"]]]] [sql execute -execute reader \
         2360  +      -format list $db "SELECT x FROM t1;"]
         2361  +} -cleanup {
         2362  +  cleanupDb $fileName
         2363  +
         2364  +  unset -nocomplain dateTime db fileName
         2365  +} -constraints \
         2366  +{eagle monoBug28 command.sql compile.DATA SQLite System.Data.SQLite} -result \
         2367  +{1 630874007980000000}}
  2349   2368   
  2350   2369   ###############################################################################
  2351   2370   
  2352   2371   unset -nocomplain systemDataSQLiteDllFile systemDataSQLiteLinqDllFile \
  2353   2372       testExeFile testLinqExeFile northwindEfDbFile testLinqOutFile
  2354   2373   
  2355   2374   ###############################################################################
  2356   2375   
  2357   2376   runSQLiteTestEpilogue
  2358   2377   runTestEpilogue