System.Data.SQLite

Check-in [369779a300]
Login

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

Overview
Comment:Honor the second argument to Math.Round when using LINQ.
Downloads: Tarball | ZIP archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: 369779a30009d32d42bee0e3b8369b8ffe78f7b4
User & Date: mistachkin 2015-07-29 22:03:59.632
Context
2015-07-30
00:15
Update SQLite core library to the 3.8.11.1 release. check-in: e2757bd694 user: mistachkin tags: trunk
2015-07-29
22:03
Honor the second argument to Math.Round when using LINQ. check-in: 369779a300 user: mistachkin tags: trunk
02:57
Enhancements to the stress test. check-in: d8612b51e0 user: mistachkin tags: trunk
Changes
Unified Diff Ignore Whitespace Patch
Changes to Doc/Extra/Provider/version.html.
44
45
46
47
48
49
50

51
52
53
54
55
56
57
    <div id="mainBody">
    <h1 class="heading">Version History</h1>
    <p><b>1.0.98.0 - August XX, 2015 <font color="red">(release scheduled)</font></b></p>
    <ul>
      <li>Updated to <a href="https://www.sqlite.org/releaselog/3_8_11.html">SQLite 3.8.11</a>.</li>
      <li>Add full support for Visual Studio 2015 and the .NET Framework 4.6.</li>
      <li>Implement the Substring method for LINQ using the &quot;substr&quot; core SQL function.&nbsp;<b>** Potentially Incompatible Change **</b></li>

      <li>Honor the pre-existing flags for connections during the Open method. Fix for <a href="https://system.data.sqlite.org/index.html/info/964063da16">[964063da16]</a>.&nbsp;<b>** Potentially Incompatible Change **</b></li>
      <li>Remove errant semi-colons from the SQL used by LINQ to INSERT and then SELECT rows with composite primary keys. Fix for <a href="https://system.data.sqlite.org/index.html/info/9d353b0bd8">[9d353b0bd8]</a>.</li>
      <li>Change the base type for the SQLiteConnectionFlags enumeration to long integer.&nbsp;<b>** Potentially Incompatible Change **</b></li>
      <li>Add extended return codes to the SQLiteErrorCode enumeration. Pursuant to <a href="https://system.data.sqlite.org/index.html/info/71bedaca19">[71bedaca19]</a>.&nbsp;<b>** Potentially Incompatible Change **</b></li>
      <li>Improve exception handling in all native callbacks implemented in the SQLiteConnection class.</li>
      <li>Add Progress event and ProgressOps connection string property to enable raising progress events during long-running queries.</li>
      <li>Add &quot;Recursive Triggers&quot; connection string property to enable or disable the recursive trigger capability. Pursuant to <a href="https://system.data.sqlite.org/index.html/info/3a82ee635b">[3a82ee635b]</a>.</li>







>







44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
    <div id="mainBody">
    <h1 class="heading">Version History</h1>
    <p><b>1.0.98.0 - August XX, 2015 <font color="red">(release scheduled)</font></b></p>
    <ul>
      <li>Updated to <a href="https://www.sqlite.org/releaselog/3_8_11.html">SQLite 3.8.11</a>.</li>
      <li>Add full support for Visual Studio 2015 and the .NET Framework 4.6.</li>
      <li>Implement the Substring method for LINQ using the &quot;substr&quot; core SQL function.&nbsp;<b>** Potentially Incompatible Change **</b></li>
      <li>Honor the second argument to Math.Round when using LINQ.&nbsp;<b>** Potentially Incompatible Change **</b></li>
      <li>Honor the pre-existing flags for connections during the Open method. Fix for <a href="https://system.data.sqlite.org/index.html/info/964063da16">[964063da16]</a>.&nbsp;<b>** Potentially Incompatible Change **</b></li>
      <li>Remove errant semi-colons from the SQL used by LINQ to INSERT and then SELECT rows with composite primary keys. Fix for <a href="https://system.data.sqlite.org/index.html/info/9d353b0bd8">[9d353b0bd8]</a>.</li>
      <li>Change the base type for the SQLiteConnectionFlags enumeration to long integer.&nbsp;<b>** Potentially Incompatible Change **</b></li>
      <li>Add extended return codes to the SQLiteErrorCode enumeration. Pursuant to <a href="https://system.data.sqlite.org/index.html/info/71bedaca19">[71bedaca19]</a>.&nbsp;<b>** Potentially Incompatible Change **</b></li>
      <li>Improve exception handling in all native callbacks implemented in the SQLiteConnection class.</li>
      <li>Add Progress event and ProgressOps connection string property to enable raising progress events during long-running queries.</li>
      <li>Add &quot;Recursive Triggers&quot; connection string property to enable or disable the recursive trigger capability. Pursuant to <a href="https://system.data.sqlite.org/index.html/info/3a82ee635b">[3a82ee635b]</a>.</li>
Changes to System.Data.SQLite.Linq/SQL Generation/SqlGenerator.cs.
2957
2958
2959
2960
2961
2962
2963

2964
2965
2966
2967
2968
2969
2970
2971
2972
2973
2974
2975
2976








2977

2978
2979
2980
2981
2982
2983
2984
      //result.Append(" + '.') - LEN('.')");

      return result;
    }

    /// <summary>
    /// Round(numericExpression) -> Round(numericExpression, 0);

    /// </summary>
    /// <param name="sqlgen"></param>
    /// <param name="e"></param>
    /// <returns></returns>
    private static ISqlFragment HandleCanonicalFunctionRound(SqlGenerator sqlgen, DbFunctionExpression e)
    {
      SqlBuilder result = new SqlBuilder();

      result.Append("ROUND(");

      Debug.Assert(e.Arguments.Count == 1, "Round should have one argument");
      result.Append(e.Arguments[0].Accept(sqlgen));









      result.Append(", 0)");


      return result;
    }

    /// <summary>
    /// TRIM(string) -> LTRIM(RTRIM(string))
    /// </summary>







>










|


>
>
>
>
>
>
>
>
|
>







2957
2958
2959
2960
2961
2962
2963
2964
2965
2966
2967
2968
2969
2970
2971
2972
2973
2974
2975
2976
2977
2978
2979
2980
2981
2982
2983
2984
2985
2986
2987
2988
2989
2990
2991
2992
2993
2994
      //result.Append(" + '.') - LEN('.')");

      return result;
    }

    /// <summary>
    /// Round(numericExpression) -> Round(numericExpression, 0);
    /// Round(numericExpression, N) -> Round(numericExpression, N);
    /// </summary>
    /// <param name="sqlgen"></param>
    /// <param name="e"></param>
    /// <returns></returns>
    private static ISqlFragment HandleCanonicalFunctionRound(SqlGenerator sqlgen, DbFunctionExpression e)
    {
      SqlBuilder result = new SqlBuilder();

      result.Append("ROUND(");

      Debug.Assert(e.Arguments.Count == 1 || e.Arguments.Count == 2, "Round should have one or two arguments");
      result.Append(e.Arguments[0].Accept(sqlgen));

      if (e.Arguments.Count == 2)
      {
        result.Append(", ");
        result.Append(e.Arguments[1].Accept(sqlgen));
        result.Append(")");
      }
      else
      {
        result.Append(", 0)");
      }

      return result;
    }

    /// <summary>
    /// TRIM(string) -> LTRIM(RTRIM(string))
    /// </summary>
Changes to Tests/linq.eagle.
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 {0 {inserted 1 updated 1}}}









































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

runSQLiteTestFilesEpilogue
runSQLiteTestEpilogue
runTestEpilogue







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






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

  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 updated 1}}}

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

runTest {test linq-1.2 {ROUND function with two arguments} -body {
  #
  # NOTE: Re-copy the reference database file used for this unit test to the
  #       build directory in case it has been changed by a previous test run.
  #
  file copy -force $northwindEfDbFile \
      [file join [getBuildDirectory] [file tail $northwindEfDbFile]]

  set result [list]
  set output ""

  set code [catch {
    testClrExec $testLinqExeFile [list -eventflags Wait -directory \
        [file dirname $testLinqExeFile] -nocarriagereturns -stdout output \
        -success 0] -round
  } error]

  tlog "---- BEGIN STDOUT OUTPUT\n"
  tlog $output
  tlog "\n---- END STDOUT OUTPUT\n"

  lappend result $code

  if {$code == 0} then {
    lappend result [string trim $output]
  } else {
    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 {{ NewUnitPrice = 21.0 } { NewUnitPrice = 21.1 } { NewUnitPrice =\
21.05 } { NewUnitPrice = 23.0 } { NewUnitPrice = 23.3 } { NewUnitPrice = 23.25\
} { NewUnitPrice = 21.0 } { NewUnitPrice = 21.4 } { NewUnitPrice = 21.35 }}}}

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

runSQLiteTestFilesEpilogue
runSQLiteTestEpilogue
runTestEpilogue
Changes to readme.htm.
211
212
213
214
215
216
217

218
219
220
221
222
223
224
<p>
    <b>1.0.98.0 - August XX, 2015 <font color="red">(release scheduled)</font></b>
</p>
<ul>
    <li>Updated to <a href="https://www.sqlite.org/releaselog/3_8_11.html">SQLite 3.8.11</a>.</li>
    <li>Add full support for Visual Studio 2015 and the .NET Framework 4.6.</li>
    <li>Implement the Substring method for LINQ using the &quot;substr&quot; core SQL function.&nbsp;<b>** Potentially Incompatible Change **</b></li>

    <li>Honor the pre-existing flags for connections during the Open method. Fix for [964063da16].&nbsp;<b>** Potentially Incompatible Change **</b></li>
    <li>Remove errant semi-colons from the SQL used by LINQ to INSERT and then SELECT rows with composite primary keys. Fix for [9d353b0bd8].</li>
    <li>Change the base type for the SQLiteConnectionFlags enumeration to long integer.&nbsp;<b>** Potentially Incompatible Change **</b></li>
    <li>Add extended return codes to the SQLiteErrorCode enumeration. Pursuant to [71bedaca19].&nbsp;<b>** Potentially Incompatible Change **</b></li>
    <li>Improve exception handling in all native callbacks implemented in the SQLiteConnection class.</li>
    <li>Add Progress event and ProgressOps connection string property to enable raising progress events during long-running queries.</li>
    <li>Add &quot;Recursive Triggers&quot; connection string property to enable or disable the recursive trigger capability. Pursuant to [3a82ee635b].</li>







>







211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
<p>
    <b>1.0.98.0 - August XX, 2015 <font color="red">(release scheduled)</font></b>
</p>
<ul>
    <li>Updated to <a href="https://www.sqlite.org/releaselog/3_8_11.html">SQLite 3.8.11</a>.</li>
    <li>Add full support for Visual Studio 2015 and the .NET Framework 4.6.</li>
    <li>Implement the Substring method for LINQ using the &quot;substr&quot; core SQL function.&nbsp;<b>** Potentially Incompatible Change **</b></li>
    <li>Honor the second argument to Math.Round when using LINQ.&nbsp;<b>** Potentially Incompatible Change **</b></li>
    <li>Honor the pre-existing flags for connections during the Open method. Fix for [964063da16].&nbsp;<b>** Potentially Incompatible Change **</b></li>
    <li>Remove errant semi-colons from the SQL used by LINQ to INSERT and then SELECT rows with composite primary keys. Fix for [9d353b0bd8].</li>
    <li>Change the base type for the SQLiteConnectionFlags enumeration to long integer.&nbsp;<b>** Potentially Incompatible Change **</b></li>
    <li>Add extended return codes to the SQLiteErrorCode enumeration. Pursuant to [71bedaca19].&nbsp;<b>** Potentially Incompatible Change **</b></li>
    <li>Improve exception handling in all native callbacks implemented in the SQLiteConnection class.</li>
    <li>Add Progress event and ProgressOps connection string property to enable raising progress events during long-running queries.</li>
    <li>Add &quot;Recursive Triggers&quot; connection string property to enable or disable the recursive trigger capability. Pursuant to [3a82ee635b].</li>
Changes to testlinq/Program.cs.
185
186
187
188
189
190
191






192
193
194
195
196
197
198

                              return 1;
                          }
                      }

                      return BinaryGuidTest2(value);
                  }






#endif
              default:
                  {
                      Console.WriteLine("unknown test \"{0}\"", arg);
                      return 1;
                  }
          }







>
>
>
>
>
>







185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204

                              return 1;
                          }
                      }

                      return BinaryGuidTest2(value);
                  }
#endif
#if NET_40 || NET_45 || NET_451 || NET_46
              case "round":
                  {
                      return RoundTest();
                  }
#endif
              default:
                  {
                      Console.WriteLine("unknown test \"{0}\"", arg);
                      return 1;
                  }
          }
784
785
786
787
788
789
790











































791
792
793
794
795
796
797
                  "AppendManifestToken_SQLiteProviderManifest",
                  null);
          }

          Environment.SetEnvironmentVariable("SQLite_ForceLogPrepare", null);
          Trace.Listeners.Remove(listener);
      }












































    private static int OldTests()
    {
      using (northwindEFEntities db = new northwindEFEntities())
      {
        {
          string entitySQL = "SELECT VALUE o FROM Orders AS o WHERE SQLite.DatePart('yyyy', o.OrderDate) = 1997 ORDER BY o.OrderID;";







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







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
                  "AppendManifestToken_SQLiteProviderManifest",
                  null);
          }

          Environment.SetEnvironmentVariable("SQLite_ForceLogPrepare", null);
          Trace.Listeners.Remove(listener);
      }

#if NET_40 || NET_45 || NET_451 || NET_46
      //
      // NOTE: Used to test the ROUND fix (i.e. being able to properly handle
      //       the two argument form).
      //
      private static int RoundTest()
      {
            using (northwindEFEntities db = new northwindEFEntities())
            {
                bool once = false;

                foreach (int[] i in new int[][] {
                        new int[] { 10503, 65 },
                        new int[] { 10503, 14 },
                        new int[] { 10635, 5 }
                    })
                {
                    for (int j = 0; j < 3; j++)
                    {
                        int oid = i[0];
                        int pid = i[1];

                        var query = from o in db.OrderDetails
                                    where o.OrderID == oid && o.ProductID == pid
                                    select new { NewUnitPrice = Math.Round(o.UnitPrice, j) };

                        foreach (object o in query)
                        {
                            if (once)
                                Console.Write(' ');

                            Console.Write("{0}", o);

                            once = true;
                        }
                    }
                }
            }

            return 0;
      }
#endif

    private static int OldTests()
    {
      using (northwindEFEntities db = new northwindEFEntities())
      {
        {
          string entitySQL = "SELECT VALUE o FROM Orders AS o WHERE SQLite.DatePart('yyyy', o.OrderDate) = 1997 ORDER BY o.OrderID;";
Changes to www/news.wiki.
1
2
3
4
5
6
7
8
9
10
11

12
13
14
15
16
17
18
<title>News</title>

<b>Version History</b>

<p>
    <b>1.0.98.0 - August XX, 2015 <font color="red">(release scheduled)</font></b>
</p>
<ul>
    <li>Updated to [https://www.sqlite.org/releaselog/3_8_11.html|SQLite 3.8.11].</li>
    <li>Add full support for Visual Studio 2015 and the .NET Framework 4.6.</li>
    <li>Implement the Substring method for LINQ using the &quot;substr&quot; core SQL function.&nbsp;<b>** Potentially Incompatible Change **</b></li>

    <li>Honor the pre-existing flags for connections during the Open method. Fix for [964063da16].&nbsp;<b>** Potentially Incompatible Change **</b></li>
    <li>Remove errant semi-colons from the SQL used by LINQ to INSERT and then SELECT rows with composite primary keys. Fix for [9d353b0bd8].</li>
    <li>Change the base type for the SQLiteConnectionFlags enumeration to long integer.&nbsp;<b>** Potentially Incompatible Change **</b></li>
    <li>Add extended return codes to the SQLiteErrorCode enumeration. Pursuant to [71bedaca19].&nbsp;<b>** Potentially Incompatible Change **</b></li>
    <li>Improve exception handling in all native callbacks implemented in the SQLiteConnection class.</li>
    <li>Add Progress event and ProgressOps connection string property to enable raising progress events during long-running queries.</li>
    <li>Add &quot;Recursive Triggers&quot; connection string property to enable or disable the recursive trigger capability. Pursuant to [3a82ee635b].</li>











>







1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
<title>News</title>

<b>Version History</b>

<p>
    <b>1.0.98.0 - August XX, 2015 <font color="red">(release scheduled)</font></b>
</p>
<ul>
    <li>Updated to [https://www.sqlite.org/releaselog/3_8_11.html|SQLite 3.8.11].</li>
    <li>Add full support for Visual Studio 2015 and the .NET Framework 4.6.</li>
    <li>Implement the Substring method for LINQ using the &quot;substr&quot; core SQL function.&nbsp;<b>** Potentially Incompatible Change **</b></li>
    <li>Honor the second argument to Math.Round when using LINQ.&nbsp;<b>** Potentially Incompatible Change **</b></li>
    <li>Honor the pre-existing flags for connections during the Open method. Fix for [964063da16].&nbsp;<b>** Potentially Incompatible Change **</b></li>
    <li>Remove errant semi-colons from the SQL used by LINQ to INSERT and then SELECT rows with composite primary keys. Fix for [9d353b0bd8].</li>
    <li>Change the base type for the SQLiteConnectionFlags enumeration to long integer.&nbsp;<b>** Potentially Incompatible Change **</b></li>
    <li>Add extended return codes to the SQLiteErrorCode enumeration. Pursuant to [71bedaca19].&nbsp;<b>** Potentially Incompatible Change **</b></li>
    <li>Improve exception handling in all native callbacks implemented in the SQLiteConnection class.</li>
    <li>Add Progress event and ProgressOps connection string property to enable raising progress events during long-running queries.</li>
    <li>Add &quot;Recursive Triggers&quot; connection string property to enable or disable the recursive trigger capability. Pursuant to [3a82ee635b].</li>