[CalendarServer-changes] [8653] CalendarServer/branches/users/glyph/table-alias
source_changes at macosforge.org
source_changes at macosforge.org
Mon Feb 13 10:03:31 PST 2012
Revision: 8653
http://trac.macosforge.org/projects/calendarserver/changeset/8653
Author: glyph at apple.com
Date: 2012-02-13 10:03:31 -0800 (Mon, 13 Feb 2012)
Log Message:
-----------
tests for table aliasing.
Modified Paths:
--------------
CalendarServer/branches/users/glyph/table-alias/twext/enterprise/dal/test/test_sqlsyntax.py
Property Changed:
----------------
CalendarServer/branches/users/glyph/table-alias/
Modified: CalendarServer/branches/users/glyph/table-alias/twext/enterprise/dal/test/test_sqlsyntax.py
===================================================================
--- CalendarServer/branches/users/glyph/table-alias/twext/enterprise/dal/test/test_sqlsyntax.py 2012-02-13 18:03:28 UTC (rev 8652)
+++ CalendarServer/branches/users/glyph/table-alias/twext/enterprise/dal/test/test_sqlsyntax.py 2012-02-13 18:03:31 UTC (rev 8653)
@@ -345,6 +345,31 @@
)
+ def test_tableAliasing(self):
+ """
+ Tables may be given aliases, in order to facilitate self-joins.
+ """
+ sfoo = self.schema.FOO
+ sfoo2 = sfoo.alias()
+ self.assertEqual(
+ Select(From=self.schema.FOO.join(sfoo2)).toSQL(),
+ SQLFragment("select * from FOO cross join FOO alias1")
+ )
+
+
+ def test_aliasedTableColumns(self):
+ """
+ The columns of aliased tables will always be prefixed with their alias
+ in the generated SQL.
+ """
+ sfoo = self.schema.FOO
+ sfoo2 = sfoo.alias()
+ self.assertEquals(
+ Select([sfoo2.BAR], From=sfoo2).toSQL(),
+ SQLFragment("select alias1.BAR from alias1")
+ )
+
+
def test_columnSelection(self):
"""
If a column is specified by the argument to L{Select}, those will be
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/calendarserver-changes/attachments/20120213/69f8feff/attachment.html>
More information about the calendarserver-changes
mailing list