Esempio n. 1
0
    def test_referenced_columns(self):
        # a = 1 AND b = 1
        conditions = [
            ['a', '=', '1'],
            ['b', '=', '1'],
        ]
        assert set(snuba.all_referenced_columns(conditions)) == set(['a', 'b'])

        # a = 1 AND (b = 1 OR c = 1)
        conditions = [
            ['a', '=', '1'],
            [
                ['b', '=', '1'],
                ['c', '=', '1'],
            ],
        ]
        assert set(snuba.all_referenced_columns(conditions)) == set(
            ['a', 'b', 'c'])

        # a = 1 AND (b = 1 OR foo(c) = 1)
        conditions = [
            ['a', '=', '1'],
            [
                ['b', '=', '1'],
                [['foo', ['c']], '=', '1'],
            ],
        ]
        assert set(snuba.all_referenced_columns(conditions)) == set(
            ['a', 'b', 'c'])

        # a = 1 AND (b = 1 OR foo(c, bar(d)) = 1)
        conditions = [
            ['a', '=', '1'],
            [
                ['b', '=', '1'],
                [['foo', ['c', ['bar', ['d']]]], '=', '1'],
            ],
        ]
        assert set(snuba.all_referenced_columns(conditions)) == set(
            ['a', 'b', 'c', 'd'])
Esempio n. 2
0
    def test_referenced_columns(self):
        # a = 1 AND b = 1
        conditions = [
            ['a', '=', '1'],
            ['b', '=', '1'],
        ]
        assert set(snuba.all_referenced_columns(conditions)) == set(['a', 'b'])

        # a = 1 AND (b = 1 OR c = 1)
        conditions = [
            ['a', '=', '1'],
            [
                ['b', '=', '1'],
                ['c', '=', '1'],
            ],
        ]
        assert set(snuba.all_referenced_columns(conditions)) == set(['a', 'b', 'c'])

        # a = 1 AND (b = 1 OR foo(c) = 1)
        conditions = [
            ['a', '=', '1'],
            [
                ['b', '=', '1'],
                [['foo', ['c']], '=', '1'],
            ],
        ]
        assert set(snuba.all_referenced_columns(conditions)) == set(['a', 'b', 'c'])

        # a = 1 AND (b = 1 OR foo(c, bar(d)) = 1)
        conditions = [
            ['a', '=', '1'],
            [
                ['b', '=', '1'],
                [['foo', ['c', ['bar', ['d']]]], '=', '1'],
            ],
        ]
        assert set(snuba.all_referenced_columns(conditions)) == set(['a', 'b', 'c', 'd'])