Beispiel #1
0
 def test_explicit_sequence(self):
     t = self._fixture()
     self._test(
         t.insert().values(
             id=func.next_value(Sequence('t_id_seq')), data='data', x=5),
         (1, 'data', 5)
     )
Beispiel #2
0
def parse_function(d):
    fname = get_or_403(d, "function")

    operand_struc = get_or_403(d, "operands")
    if isinstance(operand_struc, list):
        operands = list(map(parse_expression, operand_struc))
    else:
        if (
            isinstance(operand_struc, dict)
            and operand_struc.get("type", None) == "grouping"
        ):
            operands = parse_expression(operand_struc)
        else:
            operands = [parse_expression(operand_struc)]

    if fname == "+":
        if len(operands) != 2:
            raise APIError(
                "Wrong number of arguments for function %s. Expected 2. Got %d"
                % (fname, len(operands))
            )
        x, y = operands
        return x + y
    else:
        if fname == "nextval":
            return func.next_value(*operands)
        else:
            function = getattr(func, fname)
            return function(*operands)
Beispiel #3
0
def parse_function(d):
    fname = get_or_403(d, 'function')

    operand_struc = get_or_403(d, 'operands')
    if isinstance(operand_struc, list):
        operands = list(map(parse_expression, operand_struc))
    else:
        if isinstance(operand_struc, dict) and operand_struc.get(
                'type', None) == 'grouping':
            operands = parse_expression(operand_struc)
        else:
            operands = [parse_expression(operand_struc)]

    if fname == '+':
        if len(operands) != 2:
            raise APIError(
                'Wrong number of arguments for function %s. Expected 2. Got %d'
                % (fname, len(operands)))
        x, y = operands
        return x + y
    else:
        if fname == 'nextval':
            return func.next_value(*operands)
        else:
            function = getattr(func, fname)
            return function(*operands)
Beispiel #4
0
 def test_explicit_sequence(self):
     t = self._fixture()
     self._test(
         t.insert().values(id=func.next_value(Sequence("t_id_seq")),
                           data="data",
                           x=5),
         (1, "data", 5),
     )
 def test_explicit_sequence(self):
     t = self._fixture()
     self._test(
         t.insert().values(
             id=func.next_value(Sequence("t_id_seq")), data="data", x=5
         ),
         (testing.db.dialect.default_sequence_base, "data", 5),
     )
 def test_explicit_sequence(self):
     t = self._fixture()
     self._test(
         t.insert().values(
             id=func.next_value(Sequence("t_id_seq")), data="data", x=5
         ),
         (1, "data", 5),
     )
Beispiel #7
0
 def test_explicit_sequence(self):
     t = self._fixture()
     self._test(
         t.insert().values(id=func.next_value(Sequence('t_id_seq')),
                           data='data',
                           x=5), (1, 'data', 5))