Index: Doc/Extra/Provider/version.html
==================================================================
--- Doc/Extra/Provider/version.html
+++ Doc/Extra/Provider/version.html
@@ -45,10 +45,12 @@
Version History
1.0.100.0 - February XX, 2016 (release scheduled)
- Updated to SQLite 3.10.0.
- Properly handle NULL values in the "name" column of the results returned by PRAGMA index_info(). Fix for [5251bd0878].
+ - 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].
1.0.99.0 - December 9, 2015
- Updated to SQLite 3.9.2.
- Add preliminary support for the .NET Framework 4.6.1.
Index: System.Data.SQLite/SQLiteBase.cs
==================================================================
--- System.Data.SQLite/SQLiteBase.cs
+++ System.Data.SQLite/SQLiteBase.cs
@@ -1147,10 +1147,16 @@
/// Attempt to unbind all functions provided by other managed assemblies
/// when closing the connection.
///
UnbindFunctionsOnClose = 0x100000000,
+ ///
+ /// When returning column values as a , skip
+ /// verifying their affinity.
+ ///
+ NoVerifyTextAffinity = 0x200000000,
+
///
/// 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).
///
Index: System.Data.SQLite/SQLiteConvert.cs
==================================================================
--- System.Data.SQLite/SQLiteConvert.cs
+++ System.Data.SQLite/SQLiteConvert.cs
@@ -1171,38 +1171,45 @@
return ToBoolean(ToStringWithProvider(
source, CultureInfo.InvariantCulture));
}
///
- /// Convert a string to true or false.
+ /// Attempts to convert a into a .
///
- /// A string representing true or false
- ///
+ ///
+ /// The to convert, cannot be null.
+ ///
+ ///
+ /// The converted value.
+ ///
///
- /// "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
+ /// and . All strings are treated in a
+ /// case-insensitive manner.
///
public static bool ToBoolean(string source)
{
- if (String.Compare(source, bool.TrueString, StringComparison.OrdinalIgnoreCase) == 0) return true;
- else if (String.Compare(source, bool.FalseString, 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");
- }
+ if (source == null) throw new ArgumentNullException("source");
+ 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 "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
///
/// Converts a SQLiteType to a .NET Type object
Index: System.Data.SQLite/SQLiteDataReader.cs
==================================================================
--- System.Data.SQLite/SQLiteDataReader.cs
+++ System.Data.SQLite/SQLiteDataReader.cs
@@ -522,11 +522,13 @@
VerifyForGet();
if (i >= PrivateVisibleFieldCount && _keyInfo != null)
return _keyInfo.GetChars(i - PrivateVisibleFieldCount, fieldoffset, buffer, bufferoffset, length);
- VerifyType(i, DbType.String);
+ if ((_flags & SQLiteConnectionFlags.NoVerifyTextAffinity) != SQLiteConnectionFlags.NoVerifyTextAffinity)
+ VerifyType(i, DbType.String);
+
return _activeStatement._sql.GetChars(_activeStatement, i, (int)fieldoffset, buffer, bufferoffset, length);
}
///
/// Retrieves the name of the back-end datatype of the column
@@ -1232,11 +1234,13 @@
VerifyForGet();
if (i >= PrivateVisibleFieldCount && _keyInfo != null)
return _keyInfo.GetString(i - PrivateVisibleFieldCount);
- VerifyType(i, DbType.String);
+ if ((_flags & SQLiteConnectionFlags.NoVerifyTextAffinity) != SQLiteConnectionFlags.NoVerifyTextAffinity)
+ VerifyType(i, DbType.String);
+
return _activeStatement._sql.GetText(_activeStatement, i);
}
///
/// Retrieves the column as an object corresponding to the underlying datatype of the column
ADDED Tests/tkt-dbd65441a5.eagle
Index: Tests/tkt-dbd65441a5.eagle
==================================================================
--- /dev/null
+++ Tests/tkt-dbd65441a5.eagle
@@ -0,0 +1,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
Index: readme.htm
==================================================================
--- readme.htm
+++ readme.htm
@@ -212,10 +212,12 @@
1.0.100.0 - February XX, 2016 (release scheduled)
- Updated to SQLite 3.10.0.
- Properly handle NULL values in the "name" column of the results returned by PRAGMA index_info(). Fix for [5251bd0878].
+ - 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].
1.0.99.0 - December 9, 2015
Index: www/news.wiki
==================================================================
--- www/news.wiki
+++ www/news.wiki
@@ -6,10 +6,12 @@
1.0.100.0 - February XX, 2016 (release scheduled)
- Updated to SQLite 3.10.0.
- Properly handle NULL values in the "name" column of the results returned by PRAGMA index_info(). Fix for [5251bd0878].
+ - 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].
1.0.99.0 - December 9, 2015