System.Data.SQLite

Check-in [ecf9a72b79]
Login

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
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: ecf9a72b79755c26e4c2f717bb71cb94464db463
User & Date: mistachkin 2016-01-13 00:06:54.090
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
Side-by-Side Diff Ignore Whitespace Patch
Changes to Doc/Extra/Provider/version.html.
43
44
45
46
47
48
49


50
51
52
53
54
55
56
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58







+
+







    <div id="mainSection">
    <div id="mainBody">
    <h1 class="heading">Version History</h1>
    <p><b>1.0.100.0 - February XX, 2016 <font color="red">(release scheduled)</font></b></p>
    <ul>
      <li>Updated to <a href="https://www.sqlite.org/releaselog/3_10_0.html">SQLite 3.10.0</a>.</li>
      <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>
      <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>
      <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>
    </ul>
    <p><b>1.0.99.0 - December 9, 2015</b></p>
    <ul>
      <li>Updated to <a href="https://www.sqlite.org/releaselog/3_9_2.html">SQLite 3.9.2</a>.</li>
      <li>Add preliminary support for the .NET Framework 4.6.1.</li>
      <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>
      <li>Update and improve documentation comments for the native virtual table methods.</li>
Changes to System.Data.SQLite/SQLiteBase.cs.
1145
1146
1147
1148
1149
1150
1151






1152
1153
1154
1155
1156
1157
1158
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164







+
+
+
+
+
+








      /// <summary>
      /// Attempt to unbind all functions provided by other managed assemblies
      /// when closing the connection.
      /// </summary>
      UnbindFunctionsOnClose = 0x100000000,

      /// <summary>
      /// When returning column values as a <see cref="String" />, skip
      /// verifying their affinity.
      /// </summary>
      NoVerifyTextAffinity = 0x200000000,

      /// <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,

Changes to System.Data.SQLite/SQLiteConvert.cs.
1169
1170
1171
1172
1173
1174
1175
1176

1177
1178
1179






1180
1181
1182




1183
1184
1185

1186
1187


1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202















1203
1204
1205
1206
1207
1208
1209
1210
1169
1170
1171
1172
1173
1174
1175

1176
1177


1178
1179
1180
1181
1182
1183
1184


1185
1186
1187
1188
1189
1190
1191
1192


1193
1194
1195














1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210

1211
1212
1213
1214
1215
1216
1217







-
+

-
-
+
+
+
+
+
+

-
-
+
+
+
+



+
-
-
+
+

-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-







      if (source is bool) return (bool)source;

      return ToBoolean(ToStringWithProvider(
          source, CultureInfo.InvariantCulture));
    }

    /// <summary>
    /// Convert a string to true or false.
    /// Attempts to convert a <see cref="String" /> into a <see cref="Boolean" />.
    /// </summary>
    /// <param name="source">A string representing true or false</param>
    /// <returns></returns>
    /// <param name="source">
    /// The <see cref="String" /> to convert, cannot be null.
    /// </param>
    /// <returns>
    /// The converted <see cref="Boolean" /> value.
    /// </returns>
    /// <remarks>
    /// "yes", "no", "y", "n", "0", "1", "on", "off" as well as Boolean.FalseString and Boolean.TrueString will all be
    /// converted to a proper boolean value.
    /// The supported strings are "yes", "no", "y", "n", "on", "off", "0", "1",
    /// as well as any prefix of the strings <see cref="Boolean.FalseString" />
    /// and <see cref="Boolean.TrueString" />.  All strings are treated in a
    /// case-insensitive manner.
    /// </remarks>
    public static bool ToBoolean(string source)
    {
        if (source == null) throw new ArgumentNullException("source");
      if (String.Compare(source, bool.TrueString, StringComparison.OrdinalIgnoreCase) == 0) return true;
      else if (String.Compare(source, bool.FalseString, StringComparison.OrdinalIgnoreCase) == 0) return false;
        if (String.Compare(source, 0, bool.TrueString, 0, source.Length, StringComparison.OrdinalIgnoreCase) == 0) return true;
        else if (String.Compare(source, 0, bool.FalseString, 0, source.Length, StringComparison.OrdinalIgnoreCase) == 0) return false;

      switch(source.ToLower(CultureInfo.InvariantCulture))
      {
        case "yes":
        case "y":
        case "1":
        case "on":
          return true;
        case "no":
        case "n":
        case "0":
        case "off":
          return false;
        default:
          throw new ArgumentException("source");
        switch (source.ToLower(CultureInfo.InvariantCulture))
        {
            case "y":
            case "yes":
            case "on":
            case "1":
                return true;
            case "n":
            case "no":
            case "off":
            case "0":
                return false;
        }

        throw new ArgumentException("source");
      }
    }

    #region Type Conversions
    /// <summary>
    /// Converts a SQLiteType to a .NET Type object
    /// </summary>
    /// <param name="t">The SQLiteType to convert</param>
Changes to System.Data.SQLite/SQLiteDataReader.cs.
520
521
522
523
524
525
526

527


528
529
530
531
532
533
534
520
521
522
523
524
525
526
527

528
529
530
531
532
533
534
535
536







+
-
+
+







    {
        CheckDisposed();
        VerifyForGet();

        if (i >= PrivateVisibleFieldCount && _keyInfo != null)
            return _keyInfo.GetChars(i - PrivateVisibleFieldCount, fieldoffset, buffer, bufferoffset, length);

        if ((_flags & SQLiteConnectionFlags.NoVerifyTextAffinity) != SQLiteConnectionFlags.NoVerifyTextAffinity)
        VerifyType(i, DbType.String);
            VerifyType(i, DbType.String);

        return _activeStatement._sql.GetChars(_activeStatement, i, (int)fieldoffset, buffer, bufferoffset, length);
    }

    /// <summary>
    /// Retrieves the name of the back-end datatype of the column
    /// </summary>
    /// <param name="i">The index of the column.</param>
1230
1231
1232
1233
1234
1235
1236

1237


1238
1239
1240
1241
1242
1243
1244
1232
1233
1234
1235
1236
1237
1238
1239

1240
1241
1242
1243
1244
1245
1246
1247
1248







+
-
+
+







    {
        CheckDisposed();
        VerifyForGet();

        if (i >= PrivateVisibleFieldCount && _keyInfo != null)
            return _keyInfo.GetString(i - PrivateVisibleFieldCount);

        if ((_flags & SQLiteConnectionFlags.NoVerifyTextAffinity) != SQLiteConnectionFlags.NoVerifyTextAffinity)
        VerifyType(i, DbType.String);
            VerifyType(i, DbType.String);

        return _activeStatement._sql.GetText(_activeStatement, i);
    }

    /// <summary>
    /// Retrieves the column as an object corresponding to the underlying datatype of the column
    /// </summary>
    /// <param name="i">The index of the column.</param>
Added Tests/tkt-dbd65441a5.eagle.

































































































































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
###############################################################################
#
# tkt-dbd65441a5.eagle --
#
# Written by Joe Mistachkin.
# Released to the public domain, use at your own risk!
#
###############################################################################

package require Eagle
package require Eagle.Library
package require Eagle.Test

runTestPrologue

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

package require System.Data.SQLite.Test
runSQLiteTestPrologue

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

runTest {test tkt-dbd65441a5-1.1 {BOOLEAN with 't' and 'f', etc} -setup {
  setupDb [set fileName tkt-dbd65441a5-1.1.db] "" "" "" NoVerifyTextAffinity
} -body {
  sql execute $db {
    CREATE TABLE t1(x BOOLEAN);
    INSERT INTO t1 (x) VALUES('true');
    INSERT INTO t1 (x) VALUES('tru');
    INSERT INTO t1 (x) VALUES('tr');
    INSERT INTO t1 (x) VALUES('t');
    INSERT INTO t1 (x) VALUES('false');
    INSERT INTO t1 (x) VALUES('fals');
    INSERT INTO t1 (x) VALUES('fal');
    INSERT INTO t1 (x) VALUES('fa');
    INSERT INTO t1 (x) VALUES('f');
    INSERT INTO t1 (x) VALUES('-0');
    INSERT INTO t1 (x) VALUES('-1');
    INSERT INTO t1 (x) VALUES('-2');
    INSERT INTO t1 (x) VALUES('-3');
    INSERT INTO t1 (x) VALUES('0');
    INSERT INTO t1 (x) VALUES('1');
    INSERT INTO t1 (x) VALUES('2');
    INSERT INTO t1 (x) VALUES('3');
  }

  set dataReader [sql execute -execute reader -format datareader \
      -alias $db "SELECT x FROM t1 ORDER BY x;"]

  set results [list]

  while {[$dataReader Read]} {
    catch {
      list [$dataReader GetString 0] [$dataReader GetValue 0]
    } result

    lappend results $result
  }

  set results
} -cleanup {
  unset -nocomplain dataReader

  cleanupDb $fileName

  unset -nocomplain result results db fileName
} -constraints {eagle command.object monoBug28 command.sql compile.DATA SQLite\
System.Data.SQLite} -result {{-3 True} {-2 True} {-1 True} {0 False} {0 False}\
{1 True} {2 True} {3 True} {f False} {fa False} {fal False} {fals False} {false\
False} {t True} {tr True} {tru True} {true True}}}

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

runTest {test tkt-dbd65441a5-1.2 {BOOLEAN with 't' and 'f', etc} -setup {
  setupDb [set fileName tkt-dbd65441a5-1.1.db]
} -body {
  sql execute $db {
    CREATE TABLE t1(x BOOLEAN);
    INSERT INTO t1 (x) VALUES('true');
    INSERT INTO t1 (x) VALUES('tru');
    INSERT INTO t1 (x) VALUES('tr');
    INSERT INTO t1 (x) VALUES('t');
    INSERT INTO t1 (x) VALUES('false');
    INSERT INTO t1 (x) VALUES('fals');
    INSERT INTO t1 (x) VALUES('fal');
    INSERT INTO t1 (x) VALUES('fa');
    INSERT INTO t1 (x) VALUES('f');
    INSERT INTO t1 (x) VALUES('-0');
    INSERT INTO t1 (x) VALUES('-1');
    INSERT INTO t1 (x) VALUES('-2');
    INSERT INTO t1 (x) VALUES('-3');
    INSERT INTO t1 (x) VALUES('0');
    INSERT INTO t1 (x) VALUES('1');
    INSERT INTO t1 (x) VALUES('2');
    INSERT INTO t1 (x) VALUES('3');
  }

  set dataReader [sql execute -execute reader -format datareader \
      -alias $db "SELECT x FROM t1 ORDER BY x;"]

  set results [list]

  while {[$dataReader Read]} {
    catch {
      list [$dataReader GetString 0] [$dataReader GetValue 0]
    } result

    lappend results $result
  }

  set results
} -cleanup {
  unset -nocomplain dataReader

  cleanupDb $fileName

  unset -nocomplain result results db fileName
} -constraints {eagle command.object monoBug28 command.sql compile.DATA SQLite\
System.Data.SQLite} -match glob -result {{* ---> System.InvalidCastException:\
*} {* ---> System.InvalidCastException: *} {* ---> System.InvalidCastException:\
*} {* ---> System.InvalidCastException: *} {* ---> System.InvalidCastException:\
*} {* ---> System.InvalidCastException: *} {* ---> System.InvalidCastException:\
*} {* ---> System.InvalidCastException: *} {f False} {fa False} {fal False}\
{fals False} {false False} {t True} {tr True} {tru True} {true True}}}

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

runSQLiteTestEpilogue
runTestEpilogue
Changes to readme.htm.
210
211
212
213
214
215
216


217
218
219
220
221
222
223
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225







+
+








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


11
12
13
14
15
16
17
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19










+
+







<title>News</title>

<b>Version History</b>

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