def triples(self, (subject, predicate, obj), context=None):
        """
        A generator over all the triples matching pattern. Pattern can
        be any objects for comparing against nodes in the store, for
        example, RegExLiteral, Date? DateRange?

        quoted table:                <id>_quoted_statements
        asserted rdf:type table:     <id>_type_statements
        asserted non rdf:type table: <id>_asserted_statements

        triple columns: subject,predicate,object,context,termComb,objLanguage,objDatatype
        class membership columns: member,klass,context termComb

        FIXME:  These union all selects *may* be further optimized by joins

        """
        quoted_table = self._internedId % "%s_quoted_statements"
        asserted_table = "%s_asserted_statements" % self._internedId
        asserted_type_table = "%s_type_statements" % self._internedId
        literal_table = "%s_literal_statements" % self._internedId
        c = self._db.cursor()


        parameters = []

        if predicate == RDF.type:
            # Select from asserted rdf:type partition and quoted table (if a
            # context is specified)
            clauseString, params = self.buildClause(
                'typeTable', subject, RDF.type, obj, context, True)
            parameters.extend(params)
            selects = [
                (
                  asserted_type_table,
                  'typeTable',
                  clauseString,
                  ASSERTED_TYPE_PARTITION
                ),
            ]


        elif isinstance(predicate, REGEXTerm) \
            and predicate.compiledExpr.match(RDF.type) \
            or not predicate:
            # Select from quoted partition (if context is specified), literal
            # partition if (obj is Literal or None) and asserted non rdf:type
            # partition (if obj is URIRef or None)
            selects = []
            if not self.STRONGLY_TYPED_TERMS \
                or isinstance(obj, Literal) \
                or not obj \
                or (self.STRONGLY_TYPED_TERMS and isinstance(obj, REGEXTerm)):
                clauseString,params = self.buildClause(
                    'literal', subject, predicate, obj, context)
                parameters.extend(params)
                selects.append((
                  literal_table,
                  'literal',
                  clauseString,
                  ASSERTED_LITERAL_PARTITION
                ))
            if not isinstance(obj,Literal) \
                and not (isinstance(obj, REGEXTerm) \
                and self.STRONGLY_TYPED_TERMS) \
                or not obj:
                clauseString,params = self.buildClause(
                    'asserted', subject, predicate, obj, context)
                parameters.extend(params)
                selects.append((
                  asserted_table,
                  'asserted',
                  clauseString,
                  ASSERTED_NON_TYPE_PARTITION
                ))


            clauseString,params = self.buildClause(
                'typeTable', subject, RDF.type, obj, context, True)
            parameters.extend(params)
            selects.append(
                (
                  asserted_type_table,
                  'typeTable',
                  clauseString,
                  ASSERTED_TYPE_PARTITION
                )
            )


        elif predicate:
            # Select from asserted non rdf:type partition (optionally), quoted
            # partition (if context is speciied), and literal partition
            # (optionally)
            selects = []
            if not self.STRONGLY_TYPED_TERMS \
                or isinstance(obj, Literal) \
                or not obj \
                or (self.STRONGLY_TYPED_TERMS and isinstance(obj, REGEXTerm)):
                clauseString,params = self.buildClause(
                    'literal', subject, predicate, obj, context)
                parameters.extend(params)
                selects.append((
                  literal_table,
                  'literal',
                  clauseString,
                  ASSERTED_LITERAL_PARTITION
                ))
            if not isinstance(obj, Literal) \
                and not (isinstance(obj, REGEXTerm) \
                and self.STRONGLY_TYPED_TERMS) \
                or not obj:
                clauseString,params = self.buildClause(
                    'asserted', subject, predicate, obj, context)
                parameters.extend(params)
                selects.append((
                  asserted_table,
                  'asserted',
                  clauseString,
                  ASSERTED_NON_TYPE_PARTITION
                ))

        if context is not None:
            clauseString,params = self.buildClause(
                'quoted', subject, predicate, obj, context)
            parameters.extend(params)
            selects.append(
                (
                  quoted_table,
                  'quoted',
                  clauseString,
                  QUOTED_PARTITION
                )
            )



        q = self._normalizeSQLCmd(unionSELECT(selects))
        self.executeSQL(c, q, parameters)
        rt = c.fetchone()
        while rt:
            s, p, o, (graphKlass, idKlass, graphId) = extractTriple(rt, self, context)
            currentContext=graphKlass(self, idKlass(graphId))
            contexts = [currentContext]
            rt = next = c.fetchone()
            sameTriple = next and extractTriple(next, self,context)[:3] == (s, p, o)
            while sameTriple:
                s2, p2, o2, (graphKlass, idKlass, graphId) = extractTriple(next, self, context)
                c2 = graphKlass(self, idKlass(graphId))
                contexts.append(c2)
                rt = next = c.fetchone()
                sameTriple = next and extractTriple(next,self,context)[:3] == (s, p, o)

            yield (s, p, o), (c for c in contexts)
dataset/ETHPy150Open RDFLib/rdfextras/rdfextras/store/AbstractSQLStore.py/AbstractSQLStore.triples/swapped operands of `%`