System.Data.SQLite
Check-in [4647779e7a]
Not logged in

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

Overview
Comment:Add test pursuant to ticket [e235a52c82].
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | tkt-e235a52c82
Files: files | file ages | folders
SHA1: 4647779e7a2b1f4af360bd9d470e0876cda78ecb
User & Date: mistachkin 2013-01-29 03:35:38
Context
2013-01-29
05:33
Enhance test case for ticket [e235a52c82] to demonstrate the effects that different default isolation levels have on created transactions. check-in: a354a124a5 user: mistachkin tags: tkt-e235a52c82
03:35
Add test pursuant to ticket [e235a52c82]. check-in: 4647779e7a user: mistachkin tags: tkt-e235a52c82
03:34
Remove superfluous 'using' statements from some tests. check-in: 0ca77b6031 user: mistachkin tags: trunk
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Added Tests/tkt-e235a52c82.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
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
###############################################################################
#
# tkt-e235a52c82.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-e235a52c82-1.1 {transient command disposal} -setup {
  set fileName tkt-e235a52c82-1.1.db
} -body {
  setupDb $fileName

  sql execute $db {
    CREATE TABLE t1(x);
    INSERT INTO t1 (x) VALUES('1');
    INSERT INTO t1 (x) VALUES('2');
  }

  cleanupDb $fileName db true false false

  set id [object invoke Interpreter.GetActive NextId]
  set dataSource [file join [getDatabaseDirectory] $fileName]

  set sql { \
    SELECT x FROM t1 ORDER BY x; \
  }

  unset -nocomplain results errors

  set code [compileCSharpWith [subst {
    using System;
    using System.Data;
    using System.Data.SQLite;

    namespace _Dynamic${id}
    {
      public sealed class Query${id}
      {
        private IDbConnection connection;
        private bool opened;

        ///////////////////////////////////////////////////////////////////////

        private void EnsureConnection()
        {
          if (connection == null)
            connection = new SQLiteConnection("Data Source=${dataSource};");

          if (connection.State == ConnectionState.Closed)
          {
            connection.Open();
            opened = true;

            using (IDbCommand command = CreateCommand("BEGIN IMMEDIATE;"))
            {
              command.ExecuteNonQuery();
            }
          }
        }

        ///////////////////////////////////////////////////////////////////////

        private void ReleaseConnection()
        {
          if (connection == null)
            throw new Exception("cannot release connection");

          if (opened)
          {
            connection.Close();
            opened = false;
          }
        }

        ///////////////////////////////////////////////////////////////////////

        private IDbCommand CreateCommand(
          string commandText
          )
        {
          if (connection == null)
            throw new Exception("cannot create command");

          IDbCommand command = connection.CreateCommand();
          command.CommandText = commandText;

          return command;
        }

        ///////////////////////////////////////////////////////////////////////

        public object ExecuteReader(
          string commandText
          )
        {
          object result;
          EnsureConnection();
          IDataReader reader = null;

          try
          {
            reader = CreateCommand(commandText).ExecuteReader();
          }
          catch
          {
            ReleaseConnection();
            throw;
          }

          /////////////////////////////////////////////////////////////////////

          try
          {
            result = reader.GetValue(0);
          }
          catch
          {
            reader.Dispose();
            ReleaseConnection();
            throw;
          }

          return result;
        }
      }

      /////////////////////////////////////////////////////////////////////////

      public static class Test${id}
      {
        public static string\[\] GetData()
        {
          return new string\[\] {
            new Query${id}().ExecuteReader("${sql}").ToString(),
            new Query${id}().ExecuteReader("${sql}").ToString()
          };
        }

        ///////////////////////////////////////////////////////////////////////

        public static void Main()
        {
          // do nothing.
        }
      }
    }
  }] true true true results errors System.Data.SQLite.dll]

  list $code $results \
      [expr {[info exists errors] ? $errors : ""}] \
      [expr {$code eq "Ok" ? [catch {
        object invoke _Dynamic${id}.Test${id} GetData
      } result] : [set result ""]}] $result
} -cleanup {
  cleanupDb $fileName

  unset -nocomplain result results errors code sql dataSource id db fileName
} -constraints \
{eagle monoBug28 command.sql compile.DATA SQLite System.Data.SQLite} \
-match regexp -result {^Ok System#CodeDom#Compiler#CompilerResults#\d+ \{\} 0\
\{1 1\}$}}

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

runSQLiteTestEpilogue
runTestEpilogue