示例#1
0
 def test_placeholderColumnInterface(self):
     """
     Test that a column from a placeholder provides L{IColumn}.
     """
     value = 0
     p = Placeholder(PlaceholderTestItem)
     a = p.attr
     self.failUnless(IColumn.providedBy(a))
示例#2
0
文件: attributes.py 项目: bne/squeal
    def __init__(self, attribute, container, negate):
        self.attribute = attribute
        self.container = container
        self.negate = negate

        if IColumn.providedBy(container):
            self.containerClause = self._columnContainer
            self.getArgs = self._columnArgs
        elif IQuery.providedBy(container):
            self.containerClause = self._queryContainer
            self.getArgs = self._queryArgs
        else:
            self.containerClause = self._sequenceContainer
            self.getArgs = self._sequenceArgs
示例#3
0
    def __init__(self, attribute, container, negate):
        self.attribute = attribute
        self.container = container
        self.negate = negate

        if IColumn.providedBy(container):
            self.containerClause = self._columnContainer
            self.getArgs = self._columnArgs
        elif IQuery.providedBy(container):
            self.containerClause = self._queryContainer
            self.getArgs = self._queryArgs
        else:
            self.containerClause = self._sequenceContainer
            self.getArgs = self._sequenceArgs
示例#4
0
文件: attributes.py 项目: bne/squeal
def compare(left, right, op):
    # interim: maybe we want objects later?  right now strings should be fine
    if IColumn.providedBy(right):
        return TwoAttributeComparison(left, op, right)
    elif right is None:
        if op == '=':
            negate = False
        elif op == '!=':
            negate = True
        else:
            raise TypeError(
                "None/NULL does not work with %s comparison" % (op,))
        return NullComparison(left, negate)
    else:
        # convert to constant usable in the database
        return AttributeValueComparison(left, op, right)
示例#5
0
def compare(left, right, op):
    # interim: maybe we want objects later?  right now strings should be fine
    if IColumn.providedBy(right):
        return TwoAttributeComparison(left, op, right)
    elif right is None:
        if op == '=':
            negate = False
        elif op == '!=':
            negate = True
        else:
            raise TypeError(
                "None/NULL does not work with %s comparison" % (op,))
        return NullComparison(left, negate)
    else:
        # convert to constant usable in the database
        return AttributeValueComparison(left, op, right)
示例#6
0
文件: attributes.py 项目: bne/squeal
    def _like(self, negate, firstOther, *others):
        others = (firstOther,) + others
        likeParts = []

        allValues = True
        for other in others:
            if IColumn.providedBy(other):
                likeParts.append(LikeColumn(other))
                allValues = False
            elif other is None:
                # LIKE NULL is a silly condition, but it's allowed.
                likeParts.append(LikeNull())
                allValues = False
            else:
                likeParts.append(LikeValue(other))

        if allValues:
            likeParts = [LikeValue(''.join(others))]

        return LikeComparison(self, negate, likeParts)
示例#7
0
    def _like(self, negate, firstOther, *others):
        others = (firstOther, ) + others
        likeParts = []

        allValues = True
        for other in others:
            if IColumn.providedBy(other):
                likeParts.append(LikeColumn(other))
                allValues = False
            elif other is None:
                # LIKE NULL is a silly condition, but it's allowed.
                likeParts.append(LikeNull())
                allValues = False
            else:
                likeParts.append(LikeValue(other))

        if allValues:
            likeParts = [LikeValue(''.join(others))]

        return LikeComparison(self, negate, likeParts)