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

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

Overview
Comment:Make GetValue work for boolean columns with textual 'True' and 'False' values. Fix for [7714b60d61].
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: ed832982578bddf3d063b698b7098a507ee87934
User & Date: mistachkin 2015-09-25 21:16:18
References
2015-09-25
21:17 Closed ticket [7714b60d61]: Boolean Always shows as false plus 5 other changes artifact: ffad375f27 user: mistachkin
Context
2015-09-28
17:45
Update the SQLite core library to the latest trunk code. check-in: a0f27df53f user: mistachkin tags: trunk
2015-09-25
21:16
Make GetValue work for boolean columns with textual 'True' and 'False' values. Fix for [7714b60d61]. check-in: ed83298257 user: mistachkin tags: trunk
20:56
Another minor cleanup tweak to test case 'data-1.75'. check-in: b0625cacb9 user: mistachkin tags: trunk
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

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

42
43
44
45
46
47
48

49
50
51
52
53
54
55
    </div>
    <div id="mainSection">
    <div id="mainBody">
    <h1 class="heading">Version History</h1>
    <p><b>1.0.99.0 - December XX, 2015 <font color="red">(release scheduled)</font></b></p>
    <ul>
      <li>Updated to <a href="https://www.sqlite.org/draft/releaselog/3_8_12.html">SQLite 3.8.12</a>.</li>

      <li>Add Reset method to the SQLiteCommand class.</li>
      <li>Add FileName property to the SQLiteConnection class.</li>
      <li>Add experimental support for the native json1 extension.</li>
    </ul>
    <p><b>1.0.98.0 - August 19, 2015</b></p>
    <ul>
      <li>Updated to <a href="https://www.sqlite.org/releaselog/3_8_11_1.html">SQLite 3.8.11.1</a>.</li>







>







42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
    </div>
    <div id="mainSection">
    <div id="mainBody">
    <h1 class="heading">Version History</h1>
    <p><b>1.0.99.0 - December XX, 2015 <font color="red">(release scheduled)</font></b></p>
    <ul>
      <li>Updated to <a href="https://www.sqlite.org/draft/releaselog/3_8_12.html">SQLite 3.8.12</a>.</li>
      <li>Make GetValue work for boolean columns with textual &quot;True&quot; and &quot;False&quot; values. Fix for <a href="https://system.data.sqlite.org/index.html/info/7714b60d61">[7714b60d61]</a>.</li>
      <li>Add Reset method to the SQLiteCommand class.</li>
      <li>Add FileName property to the SQLiteConnection class.</li>
      <li>Add experimental support for the native json1 extension.</li>
    </ul>
    <p><b>1.0.98.0 - August 19, 2015</b></p>
    <ul>
      <li>Updated to <a href="https://www.sqlite.org/releaselog/3_8_11_1.html">SQLite 3.8.11.1</a>.</li>

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

2020
2021
2022
2023
2024
2025
2026







































2027
2028
2029
2030
2031
2032
2033
2034
2035
2036
2037
2038
2039





2040
2041
2042
2043
2044
2045
2046
....
3079
3080
3081
3082
3083
3084
3085

3086
3087
3088
3089
3090
3091

3092
3093
3094
3095
3096
3097
3098
      dataType = UTF8ToString(dataTypePtr, dtLen);
      collateSequence = UTF8ToString(collSeqPtr, csLen);

      notNull = (nnotNull == 1);
      primaryKey = (nprimaryKey == 1);
      autoIncrement = (nautoInc == 1);
    }








































    internal override double GetDouble(SQLiteStatement stmt, int index)
    {
#if !PLATFORM_COMPACTFRAMEWORK
      return UnsafeNativeMethods.sqlite3_column_double(stmt._sqlite_stmt, index);
#elif !SQLITE_STANDARD
      double value = 0.0;
      UnsafeNativeMethods.sqlite3_column_double_interop(stmt._sqlite_stmt, index, ref value);
      return value;
#else
      throw new NotImplementedException();
#endif
    }






    internal override sbyte GetSByte(SQLiteStatement stmt, int index)
    {
      return unchecked((sbyte)(GetInt32(stmt, index) & byte.MaxValue));
    }

    internal override byte GetByte(SQLiteStatement stmt, int index)
................................................................................
        case TypeAffinity.DateTime:
          return GetDateTime(stmt, index);
        case TypeAffinity.Double:
          if (t == null) return GetDouble(stmt, index);
          return Convert.ChangeType(GetDouble(stmt, index), t, null);
        case TypeAffinity.Int64:
          if (t == null) return GetInt64(stmt, index);

          if (t == typeof(SByte)) return GetSByte(stmt, index);
          if (t == typeof(Byte)) return GetByte(stmt, index);
          if (t == typeof(Int16)) return GetInt16(stmt, index);
          if (t == typeof(UInt16)) return GetUInt16(stmt, index);
          if (t == typeof(Int32)) return GetInt32(stmt, index);
          if (t == typeof(UInt32)) return GetUInt32(stmt, index);

          if (t == typeof(UInt64)) return GetUInt64(stmt, index);
          return Convert.ChangeType(GetInt64(stmt, index), t, null);
        default:
          return GetText(stmt, index);
      }
    }








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













>
>
>
>
>







 







>






>







2020
2021
2022
2023
2024
2025
2026
2027
2028
2029
2030
2031
2032
2033
2034
2035
2036
2037
2038
2039
2040
2041
2042
2043
2044
2045
2046
2047
2048
2049
2050
2051
2052
2053
2054
2055
2056
2057
2058
2059
2060
2061
2062
2063
2064
2065
2066
2067
2068
2069
2070
2071
2072
2073
2074
2075
2076
2077
2078
2079
2080
2081
2082
2083
2084
2085
2086
2087
2088
2089
2090
....
3123
3124
3125
3126
3127
3128
3129
3130
3131
3132
3133
3134
3135
3136
3137
3138
3139
3140
3141
3142
3143
3144
      dataType = UTF8ToString(dataTypePtr, dtLen);
      collateSequence = UTF8ToString(collSeqPtr, csLen);

      notNull = (nnotNull == 1);
      primaryKey = (nprimaryKey == 1);
      autoIncrement = (nautoInc == 1);
    }

    internal override object GetObject(SQLiteStatement stmt, int index)
    {
        switch (ColumnAffinity(stmt, index))
        {
            case TypeAffinity.Int64:
                {
                    return GetInt64(stmt, index);
                }
            case TypeAffinity.Double:
                {
                    return GetDouble(stmt, index);
                }
            case TypeAffinity.Text:
                {
                    return GetText(stmt, index);
                }
            case TypeAffinity.Blob:
                {
                    long size = GetBytes(stmt, index, 0, null, 0, 0);

                    if ((size > 0) && (size <= int.MaxValue))
                    {
                        byte[] bytes = new byte[(int)size];

                        GetBytes(stmt, index, 0, bytes, 0, (int)size);

                        return bytes;
                    }
                    break;
                }
            case TypeAffinity.Null:
                {
                    return DBNull.Value;
                }
        }

        throw new NotImplementedException();
    }

    internal override double GetDouble(SQLiteStatement stmt, int index)
    {
#if !PLATFORM_COMPACTFRAMEWORK
      return UnsafeNativeMethods.sqlite3_column_double(stmt._sqlite_stmt, index);
#elif !SQLITE_STANDARD
      double value = 0.0;
      UnsafeNativeMethods.sqlite3_column_double_interop(stmt._sqlite_stmt, index, ref value);
      return value;
#else
      throw new NotImplementedException();
#endif
    }

    internal override bool GetBoolean(SQLiteStatement stmt, int index)
    {
      return ToBoolean(GetObject(stmt, index), CultureInfo.InvariantCulture, false);
    }

    internal override sbyte GetSByte(SQLiteStatement stmt, int index)
    {
      return unchecked((sbyte)(GetInt32(stmt, index) & byte.MaxValue));
    }

    internal override byte GetByte(SQLiteStatement stmt, int index)
................................................................................
        case TypeAffinity.DateTime:
          return GetDateTime(stmt, index);
        case TypeAffinity.Double:
          if (t == null) return GetDouble(stmt, index);
          return Convert.ChangeType(GetDouble(stmt, index), t, null);
        case TypeAffinity.Int64:
          if (t == null) return GetInt64(stmt, index);
          if (t == typeof(Boolean)) return GetBoolean(stmt, index);
          if (t == typeof(SByte)) return GetSByte(stmt, index);
          if (t == typeof(Byte)) return GetByte(stmt, index);
          if (t == typeof(Int16)) return GetInt16(stmt, index);
          if (t == typeof(UInt16)) return GetUInt16(stmt, index);
          if (t == typeof(Int32)) return GetInt32(stmt, index);
          if (t == typeof(UInt32)) return GetUInt32(stmt, index);
          if (t == typeof(Int64)) return GetInt64(stmt, index);
          if (t == typeof(UInt64)) return GetUInt64(stmt, index);
          return Convert.ChangeType(GetInt64(stmt, index), t, null);
        default:
          return GetText(stmt, index);
      }
    }

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

249
250
251
252
253
254
255

256

257
258
259
260
261
262
263
    internal abstract int ColumnIndex(SQLiteStatement stmt, string columnName);
    internal abstract string ColumnOriginalName(SQLiteStatement stmt, int index);
    internal abstract string ColumnDatabaseName(SQLiteStatement stmt, int index);
    internal abstract string ColumnTableName(SQLiteStatement stmt, int index);
    internal abstract void ColumnMetaData(string dataBase, string table, string column, ref string dataType, ref string collateSequence, ref bool notNull, ref bool primaryKey, ref bool autoIncrement);
    internal abstract void GetIndexColumnExtendedInfo(string database, string index, string column, ref int sortMode, ref int onError, ref string collationSequence);


    internal abstract double GetDouble(SQLiteStatement stmt, int index);

    internal abstract SByte GetSByte(SQLiteStatement stmt, int index);
    internal abstract Byte GetByte(SQLiteStatement stmt, int index);
    internal abstract Int16 GetInt16(SQLiteStatement stmt, int index);
    internal abstract UInt16 GetUInt16(SQLiteStatement stmt, int index);
    internal abstract Int32 GetInt32(SQLiteStatement stmt, int index);
    internal abstract UInt32 GetUInt32(SQLiteStatement stmt, int index);
    internal abstract Int64 GetInt64(SQLiteStatement stmt, int index);







>

>







249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
    internal abstract int ColumnIndex(SQLiteStatement stmt, string columnName);
    internal abstract string ColumnOriginalName(SQLiteStatement stmt, int index);
    internal abstract string ColumnDatabaseName(SQLiteStatement stmt, int index);
    internal abstract string ColumnTableName(SQLiteStatement stmt, int index);
    internal abstract void ColumnMetaData(string dataBase, string table, string column, ref string dataType, ref string collateSequence, ref bool notNull, ref bool primaryKey, ref bool autoIncrement);
    internal abstract void GetIndexColumnExtendedInfo(string database, string index, string column, ref int sortMode, ref int onError, ref string collationSequence);

    internal abstract object GetObject(SQLiteStatement stmt, int index);
    internal abstract double GetDouble(SQLiteStatement stmt, int index);
    internal abstract Boolean GetBoolean(SQLiteStatement stmt, int index);
    internal abstract SByte GetSByte(SQLiteStatement stmt, int index);
    internal abstract Byte GetByte(SQLiteStatement stmt, int index);
    internal abstract Int16 GetInt16(SQLiteStatement stmt, int index);
    internal abstract UInt16 GetUInt16(SQLiteStatement stmt, int index);
    internal abstract Int32 GetInt32(SQLiteStatement stmt, int index);
    internal abstract UInt32 GetUInt32(SQLiteStatement stmt, int index);
    internal abstract Int64 GetInt64(SQLiteStatement stmt, int index);

Added Tests/tkt-7714b60d61.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
###############################################################################
#
# tkt-7714b60d61.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-7714b60d61-1.1 {SQLite3.GetValue with BOOLEAN} -setup {
  setupDb [set fileName tkt-7714b60d61-1.1.db]
} -body {
  set connection [getDbConnection]

  sql execute $db {
    CREATE TABLE t1 (x INTEGER PRIMARY KEY, y BOOLEAN);
    INSERT INTO t1 (x, y) VALUES(1, NULL);
    INSERT INTO t1 (x, y) VALUES(2, 0);
    INSERT INTO t1 (x, y) VALUES(3, 1);
    INSERT INTO t1 (x, y) VALUES(4, 0.0);
    INSERT INTO t1 (x, y) VALUES(5, 1.0);
    INSERT INTO t1 (x, y) VALUES(6, '0');
    INSERT INTO t1 (x, y) VALUES(7, '1');
    INSERT INTO t1 (x, y) VALUES(8, 'False');
    INSERT INTO t1 (x, y) VALUES(9, 'True');
  }

  set command [$connection -alias CreateCommand]
  $command CommandText {SELECT x, y FROM t1 ORDER BY x;}

  set dataAdapter [object create -alias \
      System.Data.SQLite.SQLiteDataAdapter $command]

  set dataTable [object create -alias System.Data.DataTable]

  $dataAdapter Fill $dataTable; getRowsFromDataTable $dataTable
} -cleanup {
  unset -nocomplain dataTable dataAdapter command

  freeDbConnection

  cleanupDb $fileName

  unset -nocomplain connection db fileName
} -constraints {eagle command.object monoBug28 command.sql compile.DATA SQLite\
System.Data.SQLite} -result {{{x 1} y} {{x 2} {y False}} {{x 3} {y True}} {{x\
4} {y False}} {{x 5} {y True}} {{x 6} {y False}} {{x 7} {y True}} {{x 8} {y\
False}} {{x 9} {y True}}}}

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

runSQLiteTestEpilogue
runTestEpilogue

Changes to readme.htm.

209
210
211
212
213
214
215

216
217
218
219
220
221
222
<h2><b>Version History</b></h2>

<p>
    <b>1.0.99.0 - December XX, 2015 <font color="red">(release scheduled)</font></b>
</p>
<ul>
    <li>Updated to <a href="https://www.sqlite.org/draft/releaselog/3_8_12.html">SQLite 3.8.12</a>.</li>

    <li>Add Reset method to the SQLiteCommand class.</li>
    <li>Add FileName property to the SQLiteConnection class.</li>
    <li>Add experimental support for the native json1 extension.</li>
</ul>
<p>
    <b>1.0.98.0 - August 19, 2015</b>
</p>







>







209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
<h2><b>Version History</b></h2>

<p>
    <b>1.0.99.0 - December XX, 2015 <font color="red">(release scheduled)</font></b>
</p>
<ul>
    <li>Updated to <a href="https://www.sqlite.org/draft/releaselog/3_8_12.html">SQLite 3.8.12</a>.</li>
    <li>Make GetValue work for boolean columns with textual &quot;True&quot; and &quot;False&quot; values. Fix for [7714b60d61].</li>
    <li>Add Reset method to the SQLiteCommand class.</li>
    <li>Add FileName property to the SQLiteConnection class.</li>
    <li>Add experimental support for the native json1 extension.</li>
</ul>
<p>
    <b>1.0.98.0 - August 19, 2015</b>
</p>

Changes to www/news.wiki.

3
4
5
6
7
8
9

10
11
12
13
14
15
16
<b>Version History</b>

<p>
    <b>1.0.99.0 - December XX, 2015 <font color="red">(release scheduled)</font></b>
</p>
<ul>
    <li>Updated to [https://www.sqlite.org/draft/releaselog/3_8_12.html|SQLite 3.8.12].</li>

    <li>Add Reset method to the SQLiteCommand class.</li>
    <li>Add FileName property to the SQLiteConnection class.</li>
    <li>Add experimental support for the native json1 extension.</li>
</ul>
<p>
    <b>1.0.98.0 - August 19, 2015</b>
</p>







>







3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
<b>Version History</b>

<p>
    <b>1.0.99.0 - December XX, 2015 <font color="red">(release scheduled)</font></b>
</p>
<ul>
    <li>Updated to [https://www.sqlite.org/draft/releaselog/3_8_12.html|SQLite 3.8.12].</li>
    <li>Make GetValue work for boolean columns with textual &quot;True&quot; and &quot;False&quot; values. Fix for [7714b60d61].</li>
    <li>Add Reset method to the SQLiteCommand class.</li>
    <li>Add FileName property to the SQLiteConnection class.</li>
    <li>Add experimental support for the native json1 extension.</li>
</ul>
<p>
    <b>1.0.98.0 - August 19, 2015</b>
</p>