System.Data.SQLite

Check-in [bba06f3a9f]
Login

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

Overview
Comment:Streamline the test case for ticket [ccfa69fc32] and make it more complete by not relying on sort ordering of the IDs.
Downloads: Tarball | ZIP archive
Timelines: family | ancestors | descendants | both | bug-ccfa69fc32
Files: files | file ages | folders
SHA1: bba06f3a9fb6ce973ca8fe53bda9992d3f8f40c3
User & Date: mistachkin 2011-09-12 19:34:39.763
Context
2011-09-12
20:43
Merge fix for ticket [ccfa69fc32] to trunk. check-in: 14a6302a28 user: mistachkin tags: trunk
19:34
Streamline the test case for ticket [ccfa69fc32] and make it more complete by not relying on sort ordering of the IDs. Closed-Leaf check-in: bba06f3a9f user: mistachkin tags: bug-ccfa69fc32
2011-09-11
17:43
Use an overload of the ObjectContext.SaveChanges method that does not require the SaveOptions enumerated type when not compiled against the .NET Framework 4.0. check-in: 34ca66ddcf user: mistachkin tags: bug-ccfa69fc32
Changes
Unified Diff Ignore Whitespace Patch
Changes to Tests/tkt-ccfa69fc32.eagle.
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
    }
  }

  set result
} -cleanup {
  unset -nocomplain code output error result add
} -constraints {eagle file_testlinq.exe file_northwindEF.db} -match glob \
-result {0 {} 0 {System.Data.UpdateException: * --->\
System.Data.SQLite.SQLiteException: Abort due to constraint violation
PRIMARY KEY must be unique
*} 0 {1 2 3 4 5 6 7 8 9 10}}}

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

unset -nocomplain testLinqExeFile northwindEfDbFile

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








|


|







64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
    }
  }

  set result
} -cleanup {
  unset -nocomplain code output error result add
} -constraints {eagle file_testlinq.exe file_northwindEF.db} -match glob \
-result {0 {1581 1730 1833 2116 2139} 0 {System.Data.UpdateException: * --->\
System.Data.SQLite.SQLiteException: Abort due to constraint violation
PRIMARY KEY must be unique
*} 0 {1 2 3 4 5 6 7 8 9 10 1576 1577 1578 1579 1580 1581 1730 1833 2116 2139}}}

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

unset -nocomplain testLinqExeFile northwindEfDbFile

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

Changes to testlinq/Program.cs.
202
203
204
205
206
207
208












209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
      }

      //
      // NOTE: Used to test the fix for ticket [ccfa69fc32].
      //
      private static int EFTransactionTest(bool add)
      {












          if (add)
          {
              using (northwindEFEntities db = new northwindEFEntities())
              {
                  using (TransactionScope scope = new TransactionScope())
                  {
                      //
                      // NOTE: *REQUIRED* This is required so that the
                      //       Entity Framework is prevented from opening
                      //       multiple connections to the underlying SQLite
                      //       database (i.e. which would result in multiple
                      //       IMMEDIATE transactions, thereby failing [later
                      //       on] with locking errors).
                      //
                      db.Connection.Open();

                      for (int index = 0; index < 5; index++)
                      {
                          int id = (index % 10) + 1;

                          Territories territories = new Territories();

                          territories.TerritoryID = id;
                          territories.TerritoryDescription = String.Format(
                              "Test #{0}", id);
                          territories.Regions = db.Regions.First();

                          db.AddObject("Territories", territories);
                      }

                      //
                      // NOTE: These territories already exist and should cause
                      //       an exception to be thrown when we try to INSERT
                      //       them.
                      //
                      int[] territoryIds = new int[] {
                          1581, 1730, 1833, 2116, 2139
                      };

                      foreach (int id in territoryIds)
                      {
                          Territories territories = new Territories();

                          territories.TerritoryID = id;
                          territories.TerritoryDescription = String.Format(
                              "Test Territory #{0}", id);
                          territories.Regions = db.Regions.First();

                          db.AddObject("Territories", territories);
                      }

                      for (int index = 5; index < 10; index++)
                      {
                          int id = (index % 10) + 1;

                          Territories territories = new Territories();

                          territories.TerritoryID = id;
                          territories.TerritoryDescription = String.Format(
                              "Test Territory #{0}", id);
                          territories.Regions = db.Regions.First();








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
















<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<


<
<
<
<
<
<
<
<
<
<
<
<
<
<







202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236























237
238














239
240
241
242
243
244
245
      }

      //
      // NOTE: Used to test the fix for ticket [ccfa69fc32].
      //
      private static int EFTransactionTest(bool add)
      {
          //
          // NOTE: Some of these territories already exist and should cause
          //       an exception to be thrown when we try to INSERT them.
          //
          long[] territoryIds = new long[] {
                 1,    2,    3,    4,    5, // NOTE: Success
                 6,    7,    8,    9,   10, // NOTE: Success
              1576, 1577, 1578, 1579, 1580, // NOTE: Success
              1581, 1730, 1833, 2116, 2139, // NOTE: Fail (1581)
              2140, 2141                    // NOTE: Skipped
          };

          if (add)
          {
              using (northwindEFEntities db = new northwindEFEntities())
              {
                  using (TransactionScope scope = new TransactionScope())
                  {
                      //
                      // NOTE: *REQUIRED* This is required so that the
                      //       Entity Framework is prevented from opening
                      //       multiple connections to the underlying SQLite
                      //       database (i.e. which would result in multiple
                      //       IMMEDIATE transactions, thereby failing [later
                      //       on] with locking errors).
                      //
                      db.Connection.Open();
























                      foreach (int id in territoryIds)
                      {














                          Territories territories = new Territories();

                          territories.TerritoryID = id;
                          territories.TerritoryDescription = String.Format(
                              "Test Territory #{0}", id);
                          territories.Regions = db.Regions.First();

293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
          }
          else
          {
              using (northwindEFEntities db = new northwindEFEntities())
              {
                  bool once = false;
                  var query = from t in db.Territories
                              where t.TerritoryID.CompareTo(11) < 0
                              orderby t.TerritoryID
                              select t;

                  foreach (Territories territories in query)
                  {
                      if (once)
                          Console.Write(' ');

                      Console.Write(territories.TerritoryID);







|
|
|







268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
          }
          else
          {
              using (northwindEFEntities db = new northwindEFEntities())
              {
                  bool once = false;
                  var query = from t in db.Territories
                    where territoryIds.AsQueryable<long>().Contains<long>(t.TerritoryID)
                    orderby t.TerritoryID
                    select t;

                  foreach (Territories territories in query)
                  {
                      if (once)
                          Console.Write(' ');

                      Console.Write(territories.TerritoryID);