def test_valid_where_condition(field, s):
    opt = random_operator(field)
    where = where_condition(field=field, value=s, operator=opt)[0]
    assume(where)
    sql = "SELECT {n} FROM tbl WHERE {w}".format(n=field.name, w=where)
    note('operator:{}'.format(opt))
    note('where condition: {}'.format(where))
    note('sql:{}'.format(sql))
    assert valid_sql(stmt=sql)
Example #2
0
def test_valid_where_condition(field, s):
    opt = random_operator(field)
    where = where_condition(field=field, value=s, operator=opt)[0]
    assume(where)
    sql = "SELECT {n} FROM tbl WHERE {w}".format(n=field.name, w=where)
    note('operator:{}'.format(opt))
    note('where condition: {}'.format(where))
    note('sql:{}'.format(sql))
    assert valid_sql(stmt=sql)
Example #3
0
def test_where_str_like(example_fields):
    where = where_condition(example_fields[0], value='Mark',
                            operator='Like')[0]
    assert where == "first_name LIKE '%Mark%'"
Example #4
0
def test_where_str_ends_with(example_fields):
    where = where_condition(example_fields[0],
                            value='Mark',
                            operator='Ends with')[0]
    assert where == "first_name LIKE '%Mark'"
Example #5
0
def test_where_date_same_day(example_fields):
    where = where_condition(example_fields[2],
                            value='2010-01-01',
                            operator='Same day')[0]
    assert where == "order_date < date('2010-01-01', '+1 day') " \
                    "AND order_date > date('2010-01-01', '-1 day')"
def test_where_str_ends_with(example_fields):
    where = where_condition(example_fields[0], value='Mark', operator='Ends with')[0]
    assert where == "first_name LIKE '%Mark'"
def test_where_date_same_day(example_fields):
    where = where_condition(example_fields[2], value='2010-01-01', operator='Same day')[0]
    assert where == "order_date < date('2010-01-01', '+1 day') " \
                    "AND order_date > date('2010-01-01', '-1 day')"
def test_where_str_like(example_fields):
    where = where_condition(example_fields[0], value='Mark', operator='Like')[0]
    assert where == "first_name LIKE '%Mark%'"