System.Data.SQLite

Check-in [e8e6cb1409]
Login

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

Overview
Comment:Corrections to the test cases for tickets [41aea496e0] and [9d353b0bd8].
Downloads: Tarball | ZIP archive
Timelines: family | ancestors | descendants | both | tkt-41aea496e0
Files: files | file ages | folders
SHA1: e8e6cb14091c735996cb14b658246caaf57b88bb
User & Date: mistachkin 2015-08-19 04:23:31.845
Context
2015-08-19
04:31
Refactor INSERT/UPDATE handling (in the LINQ assembly) so it can handle composite and non-integer primary keys. Fix for [41aea496e0]. check-in: c1baff799b user: mistachkin tags: preRelease
04:23
Corrections to the test cases for tickets [41aea496e0] and [9d353b0bd8]. Closed-Leaf check-in: e8e6cb1409 user: mistachkin tags: tkt-41aea496e0
02:30
Work in progress on fixing ticket [41aea496e0]. check-in: 8ea5fcd6b9 user: mistachkin tags: tkt-41aea496e0
Changes
Unified Diff Ignore Whitespace Patch
Changes to Tests/tkt-41aea496e0.eagle.
51
52
53
54
55
56
57
58

59
60
61
62
63
64
  }

  set result
} -cleanup {
  unset -nocomplain code output error result
} -constraints {eagle monoToDo SQLite file_System.Data.SQLite.dll testExec\
file_System.Data.SQLite.Linq.dll file_testlinq.exe file_northwindEF.db} \
-result {}}


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

runSQLiteTestFilesEpilogue
runSQLiteTestEpilogue
runTestEpilogue







|
>






51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
  }

  set result
} -cleanup {
  unset -nocomplain code output error result
} -constraints {eagle monoToDo SQLite file_System.Data.SQLite.dll testExec\
file_System.Data.SQLite.Linq.dll file_testlinq.exe file_northwindEF.db} \
-result {0 {inserted 2
updated 2}}}

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

runSQLiteTestFilesEpilogue
runSQLiteTestEpilogue
runTestEpilogue
Changes to Tests/tkt-9d353b0bd8.eagle.
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
    lappend result [string trim $error]
  }

  set result
} -cleanup {
  unset -nocomplain code output error result
} -constraints {eagle monoToDo SQLite file_System.Data.SQLite.dll testExec\
file_System.Data.SQLite.Linq.dll file_testlinq.exe file_northwindEF.db\
System.Data.SQLite.dll_v4.0.30319} -result {0 {inserted 1}}}

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

runSQLiteTestFilesEpilogue
runSQLiteTestEpilogue
runTestEpilogue







|
|






50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
    lappend result [string trim $error]
  }

  set result
} -cleanup {
  unset -nocomplain code output error result
} -constraints {eagle monoToDo SQLite file_System.Data.SQLite.dll testExec\
file_System.Data.SQLite.Linq.dll file_testlinq.exe file_northwindEF.db} \
-result {0 {inserted 1}}}

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

runSQLiteTestFilesEpilogue
runSQLiteTestEpilogue
runTestEpilogue
Changes to testlinq/Program.cs.
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163

                              return 1;
                          }
                      }

                      return EFTransactionTest(value);
                  }
#if NET_40 || NET_45 || NET_451 || NET_46
              case "insert":
                  {
                      return InsertTest();
                  }
#endif
              case "update":
                  {
                      return UpdateTest();
                  }
              case "binaryguid":
                  {
                      bool value = false;







<




<







144
145
146
147
148
149
150

151
152
153
154

155
156
157
158
159
160
161

                              return 1;
                          }
                      }

                      return EFTransactionTest(value);
                  }

              case "insert":
                  {
                      return InsertTest();
                  }

              case "update":
                  {
                      return UpdateTest();
                  }
              case "binaryguid":
                  {
                      bool value = false;
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576


577
578
579
580
581
582
583
584
585
586
587
588








589
590
591
592
593
594
595








596
597
598
599
600
601
602
#endif
              }
          }

          return 0;
      }

#if NET_40 || NET_45 || NET_451 || NET_46
      //
      // NOTE: Used to test the INSERT fix (i.e. an extra semi-colon in
      //       the SQL statement after the actual INSERT statement in
      //       the follow-up SELECT statement).
      //
      private static int InsertTest()
      {
          using (northwindEFEntities db = new northwindEFEntities())
          {


              int[] counts = { 0 };

              //
              // 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();









              OrderDetails newOrderDetails = new OrderDetails();

              newOrderDetails.OrderID = 10248;
              newOrderDetails.ProductID = 1;
              newOrderDetails.UnitPrice = (decimal)1.23;
              newOrderDetails.Quantity = 1;
              newOrderDetails.Discount = 0.0f;









              db.AddObject("OrderDetails", newOrderDetails);

              try
              {
                  db.SaveChanges();
                  counts[0]++;







<









>
>












>
>
>
>
>
>
>
>


|
|



>
>
>
>
>
>
>
>







558
559
560
561
562
563
564

565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
#endif
              }
          }

          return 0;
      }


      //
      // NOTE: Used to test the INSERT fix (i.e. an extra semi-colon in
      //       the SQL statement after the actual INSERT statement in
      //       the follow-up SELECT statement).
      //
      private static int InsertTest()
      {
          using (northwindEFEntities db = new northwindEFEntities())
          {
              long orderId = 10248;
              long productId = 1;
              int[] counts = { 0 };

              //
              // 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();

              KeyValuePair<string, object> orderIdPair =
                  new KeyValuePair<string, object>("OrderID", orderId);

              KeyValuePair<string, object> productIdPair =
                  new KeyValuePair<string, object>("ProductID", productId);

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

              OrderDetails newOrderDetails = new OrderDetails();

              newOrderDetails.OrderID = orderId;
              newOrderDetails.ProductID = productId;
              newOrderDetails.UnitPrice = (decimal)1.23;
              newOrderDetails.Quantity = 1;
              newOrderDetails.Discount = 0.0f;

              newOrderDetails.OrdersReference.EntityKey = new EntityKey(
                  "northwindEFEntities.Orders",
                  new KeyValuePair<string, object>[] { orderIdPair });

              newOrderDetails.ProductsReference.EntityKey = new EntityKey(
                  "northwindEFEntities.Products",
                  new KeyValuePair<string, object>[] { productIdPair });

              db.AddObject("OrderDetails", newOrderDetails);

              try
              {
                  db.SaveChanges();
                  counts[0]++;
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
              }

              Console.WriteLine("inserted {0}", counts[0]);
          }

          return 0;
      }
#endif

      //
      // NOTE: Used to test the UPDATE fix (i.e. the missing semi-colon
      //       in the SQL statement between the actual UPDATE statement
      //       and the follow-up SELECT statement).
      //
      private static int UpdateTest()







<







626
627
628
629
630
631
632

633
634
635
636
637
638
639
              }

              Console.WriteLine("inserted {0}", counts[0]);
          }

          return 0;
      }


      //
      // NOTE: Used to test the UPDATE fix (i.e. the missing semi-colon
      //       in the SQL statement between the actual UPDATE statement
      //       and the follow-up SELECT statement).
      //
      private static int UpdateTest()
759
760
761
762
763
764
765
766
767
768
769


770
771
772
773
774
775
776
777
778
779
780
781
782
783
784


785
786

787
788
789
790
791
792
793
794
795
796








797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812







813

814

815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836







837

838

839
840
841
842
843
844
845

          return 0;
      }
#endif

      private static int ComplexPrimaryKeyTest()
      {
          Environment.SetEnvironmentVariable("SQLite_ForceLogPrepare", "1");

          using (northwindEFEntities db = new northwindEFEntities())
          {


              int[] counts = { 0, 0 };

              //
              // 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();

              EntityKey entityKey = new EntityKey("northwindEFEntities.OrderDetails",
                  new KeyValuePair<string, object>[] {
                  new KeyValuePair<string, object>("OrderID", (long)10248),


                  new KeyValuePair<string, object>("ProductID", (long)1)
              });


              OrderDetails newOrderDetails = new OrderDetails();

              newOrderDetails.EntityKey = entityKey;
              newOrderDetails.OrderID = 10248;
              newOrderDetails.ProductID = 1;
              newOrderDetails.UnitPrice = (decimal)1.23;
              newOrderDetails.Quantity = 1;
              newOrderDetails.Discount = 0.0f;









              db.Attach(newOrderDetails);

              try
              {
                  db.SaveChanges();
                  counts[0]++;
              }
              catch (Exception e)
              {
                  Console.WriteLine(e);
              }
              finally
              {
                  db.AcceptAllChanges();
              }








              Console.WriteLine("inserted {0}", counts[0]);

              db.Refresh(RefreshMode.StoreWins, newOrderDetails);


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

              newOrderDetails.EntityKey = entityKey;
              newOrderDetails.UnitPrice = (decimal)2.34;
              newOrderDetails.Quantity = 2;
              newOrderDetails.Discount = 0.1f;

              try
              {
                  db.SaveChanges();
                  counts[1]++;
              }
              catch (Exception e)
              {
                  Console.WriteLine(e);
              }
              finally
              {
                  db.AcceptAllChanges();
              }








              Console.WriteLine("updated {0}", counts[1]);

              db.Refresh(RefreshMode.StoreWins, newOrderDetails);

          }

          return 0;
      }

      private static int DateTimeTest()
      {







<
<


>
>












<
|
|
>
>
|
|
>



<
|
|




>
>
>
>
>
>
>
>
|















>
>
>
>
>
>
>
|
>
|
>



<


















>
>
>
>
>
>
>
|
>
|
>







773
774
775
776
777
778
779


780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795

796
797
798
799
800
801
802
803
804
805

806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849

850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885

          return 0;
      }
#endif

      private static int ComplexPrimaryKeyTest()
      {


          using (northwindEFEntities db = new northwindEFEntities())
          {
              long orderId = 10248;
              long productId = 1;
              int[] counts = { 0, 0 };

              //
              // 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();


              KeyValuePair<string, object> orderIdPair =
                  new KeyValuePair<string, object>("OrderID", orderId);

              KeyValuePair<string, object> productIdPair =
                  new KeyValuePair<string, object>("ProductID", productId);

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

              OrderDetails newOrderDetails = new OrderDetails();


              newOrderDetails.OrderID = orderId;
              newOrderDetails.ProductID = productId;
              newOrderDetails.UnitPrice = (decimal)1.23;
              newOrderDetails.Quantity = 1;
              newOrderDetails.Discount = 0.0f;

              newOrderDetails.OrdersReference.EntityKey = new EntityKey(
                  "northwindEFEntities.Orders",
                  new KeyValuePair<string, object>[] { orderIdPair });

              newOrderDetails.ProductsReference.EntityKey = new EntityKey(
                  "northwindEFEntities.Products",
                  new KeyValuePair<string, object>[] { productIdPair });

              db.AddObject("OrderDetails", newOrderDetails);

              try
              {
                  db.SaveChanges();
                  counts[0]++;
              }
              catch (Exception e)
              {
                  Console.WriteLine(e);
              }
              finally
              {
                  db.AcceptAllChanges();
              }

              try
              {
                  db.Refresh(RefreshMode.StoreWins, newOrderDetails);
                  counts[0]++;
              }
              catch (Exception e)
              {
                  Console.WriteLine(e);
              }

              Console.WriteLine("inserted {0}", counts[0]);

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


              newOrderDetails.UnitPrice = (decimal)2.34;
              newOrderDetails.Quantity = 2;
              newOrderDetails.Discount = 0.1f;

              try
              {
                  db.SaveChanges();
                  counts[1]++;
              }
              catch (Exception e)
              {
                  Console.WriteLine(e);
              }
              finally
              {
                  db.AcceptAllChanges();
              }

              try
              {
                  db.Refresh(RefreshMode.StoreWins, newOrderDetails);
                  counts[1]++;
              }
              catch (Exception e)
              {
                  Console.WriteLine(e);
              }

              Console.WriteLine("updated {0}", counts[1]);
          }

          return 0;
      }

      private static int DateTimeTest()
      {