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

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

Overview
Comment:For column types that resolve to boolean, recognize case-insensitive prefixes of 'True' and 'False'. Fix for [dbd65441a5]. Add NoVerifyTextAffinity connection flag to skip type affinity checking when fetching a column value as a string. Pursuant to [dbd65441a5].
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: ecf9a72b79755c26e4c2f717bb71cb94464db463
User & Date: mistachkin 2016-01-13 00:06:54
References
2016-01-13
00:09 Closed ticket [dbd65441a5]: BOOLEAN fields with value "t" or "f" cause plus 5 other changes artifact: 9bd717f8f4 user: mistachkin
Context
2016-01-13
07:22
Add more tracing related to the connection pool. check-in: 1a0dd87d00 user: mistachkin tags: trunk
00:06
For column types that resolve to boolean, recognize case-insensitive prefixes of 'True' and 'False'. Fix for [dbd65441a5]. Add NoVerifyTextAffinity connection flag to skip type affinity checking when fetching a column value as a string. Pursuant to [dbd65441a5]. check-in: ecf9a72b79 user: mistachkin tags: trunk
2016-01-12
23:19
Mark a 'Potentially Incompatible Change' in the 1.0.99.0 release, per ticket [dbd65441a5]. check-in: b45629dfee user: mistachkin tags: trunk
Changes
Hide Diffs Side-by-Side Diffs Ignore Whitespace Patch

Changes to Doc/Extra/Provider/version.html.

    43     43       <div id="mainSection">
    44     44       <div id="mainBody">
    45     45       <h1 class="heading">Version History</h1>
    46     46       <p><b>1.0.100.0 - February XX, 2016 <font color="red">(release scheduled)</font></b></p>
    47     47       <ul>
    48     48         <li>Updated to <a href="https://www.sqlite.org/releaselog/3_10_0.html">SQLite 3.10.0</a>.</li>
    49     49         <li>Properly handle NULL values in the &quot;name&quot; column of the results returned by PRAGMA index_info(). Fix for <a href="https://system.data.sqlite.org/index.html/info/5251bd0878">[5251bd0878]</a>.</li>
           50  +      <li>For column types that resolve to boolean, recognize case-insensitive prefixes of &quot;True&quot; and &quot;False&quot;. Fix for <a href="https://system.data.sqlite.org/index.html/info/dbd65441a5">[dbd65441a5]</a>.</li>
           51  +      <li>Add NoVerifyTextAffinity connection flag to skip type affinity checking when fetching a column value as a string. Pursuant to <a href="https://system.data.sqlite.org/index.html/info/dbd65441a5">[dbd65441a5]</a>.</li>
    50     52       </ul>
    51     53       <p><b>1.0.99.0 - December 9, 2015</b></p>
    52     54       <ul>
    53     55         <li>Updated to <a href="https://www.sqlite.org/releaselog/3_9_2.html">SQLite 3.9.2</a>.</li>
    54     56         <li>Add preliminary support for the .NET Framework 4.6.1.</li>
    55     57         <li>Fix handling of sqlite3_index_info members not available with older versions of the SQLite core library.&nbsp;<b>** Potentially Incompatible Change **</b></li>
    56     58         <li>Update and improve documentation comments for the native virtual table methods.</li>

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

  1145   1145   
  1146   1146         /// <summary>
  1147   1147         /// Attempt to unbind all functions provided by other managed assemblies
  1148   1148         /// when closing the connection.
  1149   1149         /// </summary>
  1150   1150         UnbindFunctionsOnClose = 0x100000000,
  1151   1151   
         1152  +      /// <summary>
         1153  +      /// When returning column values as a <see cref="String" />, skip
         1154  +      /// verifying their affinity.
         1155  +      /// </summary>
         1156  +      NoVerifyTextAffinity = 0x200000000,
         1157  +
  1152   1158         /// <summary>
  1153   1159         /// When binding parameter values or returning column values, always
  1154   1160         /// treat them as though they were plain text (i.e. no numeric,
  1155   1161         /// date/time, or other conversions should be attempted).
  1156   1162         /// </summary>
  1157   1163         BindAndGetAllAsText = BindAllAsText | GetAllAsText,
  1158   1164   

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

  1169   1169         if (source is bool) return (bool)source;
  1170   1170   
  1171   1171         return ToBoolean(ToStringWithProvider(
  1172   1172             source, CultureInfo.InvariantCulture));
  1173   1173       }
  1174   1174   
  1175   1175       /// <summary>
  1176         -    /// Convert a string to true or false.
         1176  +    /// Attempts to convert a <see cref="String" /> into a <see cref="Boolean" />.
  1177   1177       /// </summary>
  1178         -    /// <param name="source">A string representing true or false</param>
  1179         -    /// <returns></returns>
         1178  +    /// <param name="source">
         1179  +    /// The <see cref="String" /> to convert, cannot be null.
         1180  +    /// </param>
         1181  +    /// <returns>
         1182  +    /// The converted <see cref="Boolean" /> value.
         1183  +    /// </returns>
  1180   1184       /// <remarks>
  1181         -    /// "yes", "no", "y", "n", "0", "1", "on", "off" as well as Boolean.FalseString and Boolean.TrueString will all be
  1182         -    /// converted to a proper boolean value.
         1185  +    /// The supported strings are "yes", "no", "y", "n", "on", "off", "0", "1",
         1186  +    /// as well as any prefix of the strings <see cref="Boolean.FalseString" />
         1187  +    /// and <see cref="Boolean.TrueString" />.  All strings are treated in a
         1188  +    /// case-insensitive manner.
  1183   1189       /// </remarks>
  1184   1190       public static bool ToBoolean(string source)
  1185   1191       {
  1186         -      if (String.Compare(source, bool.TrueString, StringComparison.OrdinalIgnoreCase) == 0) return true;
  1187         -      else if (String.Compare(source, bool.FalseString, StringComparison.OrdinalIgnoreCase) == 0) return false;
         1192  +        if (source == null) throw new ArgumentNullException("source");
         1193  +        if (String.Compare(source, 0, bool.TrueString, 0, source.Length, StringComparison.OrdinalIgnoreCase) == 0) return true;
         1194  +        else if (String.Compare(source, 0, bool.FalseString, 0, source.Length, StringComparison.OrdinalIgnoreCase) == 0) return false;
  1188   1195   
  1189         -      switch(source.ToLower(CultureInfo.InvariantCulture))
  1190         -      {
  1191         -        case "yes":
  1192         -        case "y":
  1193         -        case "1":
  1194         -        case "on":
  1195         -          return true;
  1196         -        case "no":
  1197         -        case "n":
  1198         -        case "0":
  1199         -        case "off":
  1200         -          return false;
  1201         -        default:
  1202         -          throw new ArgumentException("source");
  1203         -      }
         1196  +        switch (source.ToLower(CultureInfo.InvariantCulture))
         1197  +        {
         1198  +            case "y":
         1199  +            case "yes":
         1200  +            case "on":
         1201  +            case "1":
         1202  +                return true;
         1203  +            case "n":
         1204  +            case "no":
         1205  +            case "off":
         1206  +            case "0":
         1207  +                return false;
         1208  +        }
         1209  +
         1210  +        throw new ArgumentException("source");
  1204   1211       }
  1205   1212   
  1206   1213       #region Type Conversions
  1207   1214       /// <summary>
  1208   1215       /// Converts a SQLiteType to a .NET Type object
  1209   1216       /// </summary>
  1210   1217       /// <param name="t">The SQLiteType to convert</param>

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

   520    520       {
   521    521           CheckDisposed();
   522    522           VerifyForGet();
   523    523   
   524    524           if (i >= PrivateVisibleFieldCount && _keyInfo != null)
   525    525               return _keyInfo.GetChars(i - PrivateVisibleFieldCount, fieldoffset, buffer, bufferoffset, length);
   526    526   
   527         -        VerifyType(i, DbType.String);
          527  +        if ((_flags & SQLiteConnectionFlags.NoVerifyTextAffinity) != SQLiteConnectionFlags.NoVerifyTextAffinity)
          528  +            VerifyType(i, DbType.String);
          529  +
   528    530           return _activeStatement._sql.GetChars(_activeStatement, i, (int)fieldoffset, buffer, bufferoffset, length);
   529    531       }
   530    532   
   531    533       /// <summary>
   532    534       /// Retrieves the name of the back-end datatype of the column
   533    535       /// </summary>
   534    536       /// <param name="i">The index of the column.</param>
................................................................................
  1230   1232       {
  1231   1233           CheckDisposed();
  1232   1234           VerifyForGet();
  1233   1235   
  1234   1236           if (i >= PrivateVisibleFieldCount && _keyInfo != null)
  1235   1237               return _keyInfo.GetString(i - PrivateVisibleFieldCount);
  1236   1238   
  1237         -        VerifyType(i, DbType.String);
         1239  +        if ((_flags & SQLiteConnectionFlags.NoVerifyTextAffinity) != SQLiteConnectionFlags.NoVerifyTextAffinity)
         1240  +            VerifyType(i, DbType.String);
         1241  +
  1238   1242           return _activeStatement._sql.GetText(_activeStatement, i);
  1239   1243       }
  1240   1244   
  1241   1245       /// <summary>
  1242   1246       /// Retrieves the column as an object corresponding to the underlying datatype of the column
  1243   1247       /// </summary>
  1244   1248       /// <param name="i">The index of the column.</param>

Added Tests/tkt-dbd65441a5.eagle.

            1  +###############################################################################
            2  +#
            3  +# tkt-dbd65441a5.eagle --
            4  +#
            5  +# Written by Joe Mistachkin.
            6  +# Released to the public domain, use at your own risk!
            7  +#
            8  +###############################################################################
            9  +
           10  +package require Eagle
           11  +package require Eagle.Library
           12  +package require Eagle.Test
           13  +
           14  +runTestPrologue
           15  +
           16  +###############################################################################
           17  +
           18  +package require System.Data.SQLite.Test
           19  +runSQLiteTestPrologue
           20  +
           21  +###############################################################################
           22  +
           23  +runTest {test tkt-dbd65441a5-1.1 {BOOLEAN with 't' and 'f', etc} -setup {
           24  +  setupDb [set fileName tkt-dbd65441a5-1.1.db] "" "" "" NoVerifyTextAffinity
           25  +} -body {
           26  +  sql execute $db {
           27  +    CREATE TABLE t1(x BOOLEAN);
           28  +    INSERT INTO t1 (x) VALUES('true');
           29  +    INSERT INTO t1 (x) VALUES('tru');
           30  +    INSERT INTO t1 (x) VALUES('tr');
           31  +    INSERT INTO t1 (x) VALUES('t');
           32  +    INSERT INTO t1 (x) VALUES('false');
           33  +    INSERT INTO t1 (x) VALUES('fals');
           34  +    INSERT INTO t1 (x) VALUES('fal');
           35  +    INSERT INTO t1 (x) VALUES('fa');
           36  +    INSERT INTO t1 (x) VALUES('f');
           37  +    INSERT INTO t1 (x) VALUES('-0');
           38  +    INSERT INTO t1 (x) VALUES('-1');
           39  +    INSERT INTO t1 (x) VALUES('-2');
           40  +    INSERT INTO t1 (x) VALUES('-3');
           41  +    INSERT INTO t1 (x) VALUES('0');
           42  +    INSERT INTO t1 (x) VALUES('1');
           43  +    INSERT INTO t1 (x) VALUES('2');
           44  +    INSERT INTO t1 (x) VALUES('3');
           45  +  }
           46  +
           47  +  set dataReader [sql execute -execute reader -format datareader \
           48  +      -alias $db "SELECT x FROM t1 ORDER BY x;"]
           49  +
           50  +  set results [list]
           51  +
           52  +  while {[$dataReader Read]} {
           53  +    catch {
           54  +      list [$dataReader GetString 0] [$dataReader GetValue 0]
           55  +    } result
           56  +
           57  +    lappend results $result
           58  +  }
           59  +
           60  +  set results
           61  +} -cleanup {
           62  +  unset -nocomplain dataReader
           63  +
           64  +  cleanupDb $fileName
           65  +
           66  +  unset -nocomplain result results db fileName
           67  +} -constraints {eagle command.object monoBug28 command.sql compile.DATA SQLite\
           68  +System.Data.SQLite} -result {{-3 True} {-2 True} {-1 True} {0 False} {0 False}\
           69  +{1 True} {2 True} {3 True} {f False} {fa False} {fal False} {fals False} {false\
           70  +False} {t True} {tr True} {tru True} {true True}}}
           71  +
           72  +###############################################################################
           73  +
           74  +runTest {test tkt-dbd65441a5-1.2 {BOOLEAN with 't' and 'f', etc} -setup {
           75  +  setupDb [set fileName tkt-dbd65441a5-1.1.db]
           76  +} -body {
           77  +  sql execute $db {
           78  +    CREATE TABLE t1(x BOOLEAN);
           79  +    INSERT INTO t1 (x) VALUES('true');
           80  +    INSERT INTO t1 (x) VALUES('tru');
           81  +    INSERT INTO t1 (x) VALUES('tr');
           82  +    INSERT INTO t1 (x) VALUES('t');
           83  +    INSERT INTO t1 (x) VALUES('false');
           84  +    INSERT INTO t1 (x) VALUES('fals');
           85  +    INSERT INTO t1 (x) VALUES('fal');
           86  +    INSERT INTO t1 (x) VALUES('fa');
           87  +    INSERT INTO t1 (x) VALUES('f');
           88  +    INSERT INTO t1 (x) VALUES('-0');
           89  +    INSERT INTO t1 (x) VALUES('-1');
           90  +    INSERT INTO t1 (x) VALUES('-2');
           91  +    INSERT INTO t1 (x) VALUES('-3');
           92  +    INSERT INTO t1 (x) VALUES('0');
           93  +    INSERT INTO t1 (x) VALUES('1');
           94  +    INSERT INTO t1 (x) VALUES('2');
           95  +    INSERT INTO t1 (x) VALUES('3');
           96  +  }
           97  +
           98  +  set dataReader [sql execute -execute reader -format datareader \
           99  +      -alias $db "SELECT x FROM t1 ORDER BY x;"]
          100  +
          101  +  set results [list]
          102  +
          103  +  while {[$dataReader Read]} {
          104  +    catch {
          105  +      list [$dataReader GetString 0] [$dataReader GetValue 0]
          106  +    } result
          107  +
          108  +    lappend results $result
          109  +  }
          110  +
          111  +  set results
          112  +} -cleanup {
          113  +  unset -nocomplain dataReader
          114  +
          115  +  cleanupDb $fileName
          116  +
          117  +  unset -nocomplain result results db fileName
          118  +} -constraints {eagle command.object monoBug28 command.sql compile.DATA SQLite\
          119  +System.Data.SQLite} -match glob -result {{* ---> System.InvalidCastException:\
          120  +*} {* ---> System.InvalidCastException: *} {* ---> System.InvalidCastException:\
          121  +*} {* ---> System.InvalidCastException: *} {* ---> System.InvalidCastException:\
          122  +*} {* ---> System.InvalidCastException: *} {* ---> System.InvalidCastException:\
          123  +*} {* ---> System.InvalidCastException: *} {f False} {fa False} {fal False}\
          124  +{fals False} {false False} {t True} {tr True} {tru True} {true True}}}
          125  +
          126  +###############################################################################
          127  +
          128  +runSQLiteTestEpilogue
          129  +runTestEpilogue

Changes to readme.htm.

   210    210   
   211    211   <p>
   212    212       <b>1.0.100.0 - February XX, 2016 <font color="red">(release scheduled)</font></b>
   213    213   </p>
   214    214   <ul>
   215    215       <li>Updated to <a href="https://www.sqlite.org/releaselog/3_10_0.html">SQLite 3.10.0</a>.</li>
   216    216       <li>Properly handle NULL values in the &quot;name&quot; column of the results returned by PRAGMA index_info(). Fix for [5251bd0878].</li>
          217  +    <li>For column types that resolve to boolean, recognize case-insensitive prefixes of &quot;True&quot; and &quot;False&quot;. Fix for [dbd65441a5].</li>
          218  +    <li>Add NoVerifyTextAffinity connection flag to skip type affinity checking when fetching a column value as a string. Pursuant to [dbd65441a5].</li>
   217    219   </ul>
   218    220   <p>
   219    221       <b>1.0.99.0 - December 9, 2015</b>
   220    222   </p>
   221    223   <ul>
   222    224       <li>Updated to <a href="https://www.sqlite.org/releaselog/3_9_2.html">SQLite 3.9.2</a>.</li>
   223    225       <li>Add preliminary support for the .NET Framework 4.6.1.</li>

Changes to www/news.wiki.

     4      4   
     5      5   <p>
     6      6       <b>1.0.100.0 - February XX, 2016 <font color="red">(release scheduled)</font></b>
     7      7   </p>
     8      8   <ul>
     9      9       <li>Updated to <a href="https://www.sqlite.org/releaselog/3_10_0.html">SQLite 3.10.0</a>.</li>
    10     10       <li>Properly handle NULL values in the &quot;name&quot; column of the results returned by PRAGMA index_info(). Fix for [5251bd0878].</li>
           11  +    <li>For column types that resolve to boolean, recognize case-insensitive prefixes of &quot;True&quot; and &quot;False&quot;. Fix for [dbd65441a5].</li>
           12  +    <li>Add NoVerifyTextAffinity connection flag to skip type affinity checking when fetching a column value as a string. Pursuant to [dbd65441a5].</li>
    11     13   </ul>
    12     14   <p>
    13     15       <b>1.0.99.0 - December 9, 2015</b>
    14     16   </p>
    15     17   <ul>
    16     18       <li>Updated to [https://www.sqlite.org/releaselog/3_9_2.html|SQLite 3.9.2].</li>
    17     19       <li>Add preliminary support for the .NET Framework 4.6.1.</li>