[CalendarServer-changes] [6778] CalendarServer/branches/users/glyph/dal/txdav/base/datastore
source_changes at macosforge.org
source_changes at macosforge.org
Wed Jan 19 12:59:37 PST 2011
Revision: 6778
http://trac.macosforge.org/projects/calendarserver/changeset/6778
Author: glyph at apple.com
Date: 2011-01-19 12:59:37 -0800 (Wed, 19 Jan 2011)
Log Message:
-----------
make the test pass
Modified Paths:
--------------
CalendarServer/branches/users/glyph/dal/txdav/base/datastore/sqlparser.py
CalendarServer/branches/users/glyph/dal/txdav/base/datastore/sqlsyntax.py
CalendarServer/branches/users/glyph/dal/txdav/base/datastore/test/test_sqlsyntax.py
Modified: CalendarServer/branches/users/glyph/dal/txdav/base/datastore/sqlparser.py
===================================================================
--- CalendarServer/branches/users/glyph/dal/txdav/base/datastore/sqlparser.py 2011-01-19 20:59:26 UTC (rev 6777)
+++ CalendarServer/branches/users/glyph/dal/txdav/base/datastore/sqlparser.py 2011-01-19 20:59:37 UTC (rev 6778)
@@ -64,6 +64,7 @@
return schema
+
def addSQLToSchema(schema, schemaData):
parsed = parse(schemaData)
for stmt in parsed:
@@ -104,6 +105,7 @@
return schema
+
class _ColumnParser(object):
"""
Stateful parser for the things between commas.
Modified: CalendarServer/branches/users/glyph/dal/txdav/base/datastore/sqlsyntax.py
===================================================================
--- CalendarServer/branches/users/glyph/dal/txdav/base/datastore/sqlsyntax.py 2011-01-19 20:59:26 UTC (rev 6777)
+++ CalendarServer/branches/users/glyph/dal/txdav/base/datastore/sqlsyntax.py 2011-01-19 20:59:37 UTC (rev 6778)
@@ -55,6 +55,7 @@
def __getattr__(self, attr):
return TableSyntax(self.model.tableNamed(attr))
+
def __iter__(self):
for table in self.model.tables:
yield TableSyntax(table)
@@ -124,6 +125,7 @@
return __
+
class ColumnSyntax(Syntax):
"""
Syntactic convenience for L{Column}.
@@ -183,6 +185,7 @@
' '.join([self.a.model.name, self.op, self.b.model.name]), [])
+
class CompoundComparison(Comparison):
"""
A compound comparison; two or more constraints, joined by an operation
@@ -199,9 +202,12 @@
class _AllColumns(object):
+
def toSQL(self, placeholder, quote):
- return SQLStatement('*')
+ return SQLStatement(quote('*'))
+
+
ALL_COLUMNS = _AllColumns()
class Select(object):
@@ -209,7 +215,11 @@
'select' statement.
"""
- def __init__(self, columns=ALL_COLUMNS, Where=None, From=None):
+ def __init__(self, columns=None, Where=None, From=None):
+ if columns is None:
+ columns = ALL_COLUMNS
+ else:
+ columns = SQLStatement(', '.join([c.model.name for c in columns]))
self.columns = columns
self.From = From
self.Where = Where
@@ -219,7 +229,9 @@
"""
@return: a 2-tuple of (sql, args).
"""
- stmt = SQLStatement(quote("select * from "))
+ stmt = SQLStatement(quote("select "))
+ stmt.append(self.columns.toSQL(placeholder, quote))
+ stmt.text += quote(" from ")
stmt.append(self.From.toSQL(placeholder, quote))
if self.Where is not None:
wherestmt = self.Where.toSQL(placeholder, quote)
@@ -261,3 +273,9 @@
def __repr__(self):
return 'SQLStatement' + repr((self.text, self.parameters))
+
+
+ def toSQL(self, placeholder, quote):
+ return self
+
+
Modified: CalendarServer/branches/users/glyph/dal/txdav/base/datastore/test/test_sqlsyntax.py
===================================================================
--- CalendarServer/branches/users/glyph/dal/txdav/base/datastore/test/test_sqlsyntax.py 2011-01-19 20:59:26 UTC (rev 6777)
+++ CalendarServer/branches/users/glyph/dal/txdav/base/datastore/test/test_sqlsyntax.py 2011-01-19 20:59:37 UTC (rev 6778)
@@ -118,7 +118,7 @@
"""
self.assertEquals(
Select([self.schema.FOO.BAR],
- From=self.schema.FOO),
+ From=self.schema.FOO).toSQL(),
SQLStatement("select BAR from FOO")
)
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/calendarserver-changes/attachments/20110119/3d823130/attachment-0001.html>
More information about the calendarserver-changes
mailing list