You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@struts.apache.org by hu...@apache.org on 2005/10/13 23:03:02 UTC

svn commit: r320917 - in /struts/sandbox/trunk/overdrive/PhoneBook: Core/App.cs Test/Commands/SelectAllTest.cs Test/Resources/Catalog.xml Test/Resources/Queries.xml Web/Resources/Queries.xml

Author: husted
Date: Thu Oct 13 14:02:54 2005
New Revision: 320917

URL: http://svn.apache.org/viewcvs?rev=320917&view=rev
Log:
OVR-19
* Add test for using limit and offset in a query, as the first step toward supporting paged queries.

Modified:
    struts/sandbox/trunk/overdrive/PhoneBook/Core/App.cs
    struts/sandbox/trunk/overdrive/PhoneBook/Test/Commands/SelectAllTest.cs
    struts/sandbox/trunk/overdrive/PhoneBook/Test/Resources/Catalog.xml
    struts/sandbox/trunk/overdrive/PhoneBook/Test/Resources/Queries.xml
    struts/sandbox/trunk/overdrive/PhoneBook/Web/Resources/Queries.xml

Modified: struts/sandbox/trunk/overdrive/PhoneBook/Core/App.cs
URL: http://svn.apache.org/viewcvs/struts/sandbox/trunk/overdrive/PhoneBook/Core/App.cs?rev=320917&r1=320916&r2=320917&view=diff
==============================================================================
--- struts/sandbox/trunk/overdrive/PhoneBook/Core/App.cs (original)
+++ struts/sandbox/trunk/overdrive/PhoneBook/Core/App.cs Thu Oct 13 14:02:54 2005
@@ -82,6 +82,18 @@
 		#region Commands
 
 		/// <summary>
+		/// Token for SQL LIMIT clause.
+		/// </summary>
+		/// 
+		public const string QUERY_LIMIT = "query_limit";
+
+		/// <summary>
+		/// Token for SQL OFFSET clause.
+		/// </summary>
+		/// 
+		public const string QUERY_OFFSET = "query_offset";
+
+		/// <summary>
 		/// Token for select one command.
 		/// </summary>
 		/// 

Modified: struts/sandbox/trunk/overdrive/PhoneBook/Test/Commands/SelectAllTest.cs
URL: http://svn.apache.org/viewcvs/struts/sandbox/trunk/overdrive/PhoneBook/Test/Commands/SelectAllTest.cs?rev=320917&r1=320916&r2=320917&view=diff
==============================================================================
--- struts/sandbox/trunk/overdrive/PhoneBook/Test/Commands/SelectAllTest.cs (original)
+++ struts/sandbox/trunk/overdrive/PhoneBook/Test/Commands/SelectAllTest.cs Thu Oct 13 14:02:54 2005
@@ -76,7 +76,27 @@
 			string extension = row.extension;
 			Assert.IsNotNull(extension, "Expected each row to have an extension.");
 			Assert.IsTrue(extension.Length > "1234567890".Length, extension + ": Expected formatted extension.");
+		}
 
+		[Test]
+		public void SelectAll_Offset()
+		{
+			IViewHelper helper = catalog.GetHelperFor(App.ENTRY_LIST);
+			helper.Criteria[App.QUERY_LIMIT] = 2;
+			helper.Criteria[App.QUERY_OFFSET] = 4;
+			helper.Execute();
+			if (!helper.IsNominal) Assert.Fail(helper.ErrorsText);
+			IList list = helper.Outcome;
+			Assert.IsTrue(list.Count==2);
+			AppEntry entry = list[0] as AppEntry;
+			helper.Criteria[App.QUERY_LIMIT] = 2;
+			helper.Criteria[App.QUERY_OFFSET] = 2;
+			helper.Execute();
+			IList list2 = helper.Outcome;
+			AppEntry entry2 = list2[0] as AppEntry;
+			Assert.IsFalse(entry.entry_key.Equals(entry2.entry_key));
 		}
+
+
 	}
 }

Modified: struts/sandbox/trunk/overdrive/PhoneBook/Test/Resources/Catalog.xml
URL: http://svn.apache.org/viewcvs/struts/sandbox/trunk/overdrive/PhoneBook/Test/Resources/Catalog.xml?rev=320917&r1=320916&r2=320917&view=diff
==============================================================================
--- struts/sandbox/trunk/overdrive/PhoneBook/Test/Resources/Catalog.xml (original)
+++ struts/sandbox/trunk/overdrive/PhoneBook/Test/Resources/Catalog.xml Thu Oct 13 14:02:54 2005
@@ -19,6 +19,8 @@
 				<value>hired</value>
 				<value>hours</value>
 				<value>editor</value>
+				<value>query_offset</value>
+				<value>query_limit</value>
 			</list>
 		</property>
   </object>

Modified: struts/sandbox/trunk/overdrive/PhoneBook/Test/Resources/Queries.xml
URL: http://svn.apache.org/viewcvs/struts/sandbox/trunk/overdrive/PhoneBook/Test/Resources/Queries.xml?rev=320917&r1=320916&r2=320917&view=diff
==============================================================================
--- struts/sandbox/trunk/overdrive/PhoneBook/Test/Resources/Queries.xml (original)
+++ struts/sandbox/trunk/overdrive/PhoneBook/Test/Resources/Queries.xml Thu Oct 13 14:02:54 2005
@@ -101,6 +101,11 @@
 					pk_entry=#entry_key#
 				</isNotNull>
 			</dynamic>			
+			<dynamic>
+			   <isNotNull property="query_limit">
+					LIMIT #query_limit# OFFSET #query_offset# 
+			   </isNotNull>			
+			</dynamic>	
 		</select>
 
 		<insert id="entry_insert" parameterMap="entry_save_param">

Modified: struts/sandbox/trunk/overdrive/PhoneBook/Web/Resources/Queries.xml
URL: http://svn.apache.org/viewcvs/struts/sandbox/trunk/overdrive/PhoneBook/Web/Resources/Queries.xml?rev=320917&r1=320916&r2=320917&view=diff
==============================================================================
--- struts/sandbox/trunk/overdrive/PhoneBook/Web/Resources/Queries.xml (original)
+++ struts/sandbox/trunk/overdrive/PhoneBook/Web/Resources/Queries.xml Thu Oct 13 14:02:54 2005
@@ -101,6 +101,11 @@
 					pk_entry=#entry_key#
 				</isNotNull>
 			</dynamic>			
+			<dynamic>
+			   <isNotNull property="query_limit">
+					LIMIT #query_limit# OFFSET #query_offset# 
+			   </isNotNull>			
+			</dynamic>	
 		</select>
 
 		<insert id="entry_insert" parameterMap="entry_save_param">



---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@struts.apache.org
For additional commands, e-mail: dev-help@struts.apache.org