System.Data.SQLite
Check-in [6c53fbe92c]
Not logged in

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

Overview
Comment:Add experimental test for ticket [343d392b51] (so far, no exception is raised).
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | tkt-343d392b51
Files: files | file ages | folders
SHA1: 6c53fbe92c3348234517f6fe0fa249b3280ca720
User & Date: mistachkin 2011-09-29 04:45:17
Context
2011-10-06
05:28
Merge with trunk. check-in: 3ab8344ffc user: mistachkin tags: tkt-343d392b51
2011-09-29
04:45
Add experimental test for ticket [343d392b51] (so far, no exception is raised). check-in: 6c53fbe92c user: mistachkin tags: tkt-343d392b51
04:43
Allow the various binary file delete/copy/load operations to be skipped during the test prologue (for the System.Data.SQLite related binaries). check-in: d2e601c947 user: mistachkin tags: trunk
Changes
Hide Diffs Side-by-Side Diffs Ignore Whitespace Patch

Added Tests/tkt-343d392b51.eagle.

            1  +###############################################################################
            2  +#
            3  +# tkt-343d392b51.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 EagleLibrary
           12  +package require EagleTest
           13  +
           14  +runTestPrologue
           15  +
           16  +###############################################################################
           17  +
           18  +package require System.Data.SQLite.Test
           19  +runSQLiteTestPrologue
           20  +
           21  +###############################################################################
           22  +
           23  +runTest {test tkt-343d392b51-1.1 {SQLiteDataAdapter batch updates} -setup {
           24  +  setupDb [set fileName tkt-343d392b51-1.1.db]
           25  +  set otherFileName tkt-343d392b51-1.1-otherDb.db
           26  +} -body {
           27  +  set id [object invoke Interpreter.GetActive NextId]
           28  +  set dataSource [file join [getTemporaryPath] $fileName]
           29  +  set otherDataSource [file join [getTemporaryPath] $otherFileName]
           30  +  set otherDbName otherDb
           31  +  set table [appendArgs $otherDbName .t1]
           32  +
           33  +  set sql(1) [subst { \
           34  +    ATTACH DATABASE '${otherDataSource}' AS ${otherDbName}; \
           35  +    CREATE TABLE ${table}(x INTEGER PRIMARY KEY, y); \
           36  +    [for {set i 1} {$i < 200} {incr i} {
           37  +      append sql(inserts) \
           38  +          "INSERT INTO ${table} (x, y) VALUES($i, '$i'); "
           39  +    }; return [expr {[info exists sql(inserts)] ? $sql(inserts) : ""}]] \
           40  +  }]
           41  +
           42  +  set sql(2) [subst { \
           43  +    SELECT x, y FROM ${table} ORDER BY x; \
           44  +  }]
           45  +
           46  +  unset -nocomplain results errors
           47  +
           48  +  set code [compileCSharpWith [subst {
           49  +    using System.Data;
           50  +    using System.Data.SQLite;
           51  +
           52  +    namespace _Dynamic${id}
           53  +    {
           54  +      public class Test${id}
           55  +      {
           56  +        public static void Main()
           57  +        {
           58  +          using (SQLiteConnection connection = new SQLiteConnection(
           59  +              "Data Source=${dataSource};"))
           60  +          {
           61  +            connection.Open();
           62  +
           63  +            using (SQLiteCommand command = connection.CreateCommand())
           64  +            {
           65  +              command.CommandText = "${sql(1)}";
           66  +              command.ExecuteNonQuery();
           67  +            }
           68  +
           69  +            using (SQLiteDataAdapter dataAdapter = new SQLiteDataAdapter(
           70  +                "${sql(2)}", connection))
           71  +            {
           72  +              using (DataSet dataSet = new DataSet())
           73  +              {
           74  +                dataAdapter.Fill(dataSet, "${table}");
           75  +
           76  +                DataTable dataTable = dataSet.Tables\["${table}"\];
           77  +
           78  +                dataTable.Columns\["x"\].Unique = true;
           79  +                dataTable.PrimaryKey = new DataColumn\[\] {
           80  +                  dataTable.Columns\["x"\]
           81  +                };
           82  +
           83  +                SQLiteCommandBuilder commandBuilder =
           84  +                    new SQLiteCommandBuilder(dataAdapter);
           85  +
           86  +                foreach (DataRow dataRow in dataTable.Rows)
           87  +                {
           88  +                  //
           89  +                  // NOTE: Update even rows and delete odd rows.
           90  +                  //
           91  +                  if ((long)dataRow\["x"\] % 2 == 0)
           92  +                    dataRow\["y"\] = "zero";
           93  +                  else
           94  +                    dataRow.Delete();
           95  +                }
           96  +
           97  +                dataAdapter.Update(dataTable); // DBConcurrencyException (?)
           98  +              }
           99  +            }
          100  +          }
          101  +        }
          102  +      }
          103  +    }
          104  +  }] results errors System.Data.SQLite.dll]
          105  +
          106  +  list $code $results \
          107  +      [expr {[info exists errors] ? $errors : ""}] \
          108  +      [expr {$code eq "Ok" ? [catch {
          109  +        object invoke _Dynamic${id}.Test${id} Main
          110  +      } result] : [set result ""]}] $result
          111  +} -cleanup {
          112  +  cleanupDb $otherFileName
          113  +  cleanupDb $fileName
          114  +
          115  +  unset -nocomplain result code results errors i sql table otherDbName \
          116  +      otherDataSource dataSource id db otherFileName fileName
          117  +} -constraints \
          118  +{eagle monoBug28 command.sql compile.DATA System.Data.SQLite} -match regexp \
          119  +-result {^Ok System#CodeDom#Compiler#CompilerResults#\d+ \{\} 0 \{\}$}}
          120  +
          121  +###############################################################################
          122  +
          123  +runSQLiteTestEpilogue
          124  +runTestEpilogue