Beispiel #1
0
def test_build_set_prepared():
    gen = build_set(
        OrderedDict([
            ('custom_param', param('myparam')),
            ('auto_param', autoparam),
        ]))
    eq_(gen, '"custom_param"=%(myparam)s, "auto_param"=%(auto_param)s')
Beispiel #2
0
def test_select_param():
    gen = select('table', OrderedDict([
        ('custom_param', param('my_param')), ('auto_param', autoparam),
        ('using_alias', ___),
    ]))
    exp = (
        'SELECT * FROM "table" WHERE "custom_param" = %(my_param)s '
        'AND "auto_param" = %(auto_param)s AND "using_alias" = %(using_alias)s'
    )
    eq_(gen, exp)
Beispiel #3
0
def test_build_where_prepared():
    gen = build_where(
        OrderedDict([
            ('custom_param', param('my_param')),
            ('auto_param', autoparam),
            ('using_alias', ___),
        ]))
    exp = ('"custom_param" = %(my_param)s AND "auto_param" = %(auto_param)s '
           'AND "using_alias" = %(using_alias)s')
    eq_(gen, exp)
Beispiel #4
0
    def test_param_query(self):

        with self.db as cur:
            cur.execute(
                select(
                    'person',
                    {'person_id': param('person_id')}
                ),
                {'person_id': 'mosky'}
            )
            self.db._conn.rollback()
Beispiel #5
0
def test_select_param():
    gen = select(
        'table',
        OrderedDict([
            ('custom_param', param('my_param')),
            ('auto_param', autoparam),
            ('using_alias', ___),
        ]))
    exp = (
        'SELECT * FROM "table" WHERE "custom_param" = %(my_param)s '
        'AND "auto_param" = %(auto_param)s AND "using_alias" = %(using_alias)s'
    )
    eq_(gen, exp)
Beispiel #6
0
    def test_param_query(self):

        with self.db as cur:
            cur.execute(select("person", {"person_id": param("person_id")}), {"person_id": "mosky"})
            self.db._conn.rollback()
Beispiel #7
0
 def test_param_repr():
     eq_(repr(param('Mosky')), "param('Mosky')")
Beispiel #8
0
def test_build_set_prepared():
    gen = build_set(OrderedDict([("custom_param", param("myparam")), ("auto_param", autoparam)]))
    eq_(gen, '"custom_param"=%(myparam)s, "auto_param"=%(auto_param)s')
Beispiel #9
0
def test_build_where_prepared():
    gen = build_where(
        OrderedDict([("custom_param", param("my_param")), ("auto_param", autoparam), ("using_alias", ___)])
    )
    exp = '"custom_param" = %(my_param)s AND "auto_param" = %(auto_param)s ' 'AND "using_alias" = %(using_alias)s'
    eq_(gen, exp)
Beispiel #10
0
    def test_param_query(self):

        with self.db as cur:
            cur.execute(select('person', {'person_id': param('person_id')}),
                        {'person_id': 'mosky'})
            self.db._conn.rollback()
Beispiel #11
0
 def test_param_repr():
     eq_(repr(param('Mosky')), "param('Mosky')")