Exemplo n.º 1
0
def test_join_space1():
    query = ' SELECT   *  FROM   MOVIES   INNERJOIN  RATING  ON    MOVIEs.MOVIEID =  RATING.MOVIEID WHERE MOVIE.ACTION  > 1'
    q_res = Parse().parseQuery(query=query)
    assert q_res.fromtable == 'movies'
    assert q_res.onop == '='
    assert q_res.onlval == 'movies.movieid'
    assert q_res.onrval == 'rating.movieid'
    assert q_res.whereop == '>'
    assert q_res.wherelval == 'movie.action'
    assert q_res.whererval == '1'
Exemplo n.º 2
0
def test_join_normal():
    query = 'SELECT * FROM ZIPCODE INNERJOIN USER ON ZIPCODE.ZIP = USER.ZIP WHERE ZIPCODE.CITY = PILANI'
    q_res = Parse().parseQuery(query=query)
    assert q_res.fromtable == 'zipcode'
    assert q_res.onop == '='
    assert q_res.onlval == 'zipcode.zip'
    assert q_res.onrval == 'user.zip'
    assert q_res.whereop == '='
    assert q_res.wherelval == 'zipcode.city'
    assert q_res.whererval == 'PILANI'
Exemplo n.º 3
0
def test_join_case3_F():
    query = 'SELECT * FROM USER INNERJOIN ZIPCODE ON ZIPCODE.ZIP = USER.ZIP WHERE ZIPCODE.CITY == PILANI'
    q_res = Parse().parseQuery(query=query)
    assert q_res.fromtable == 'user'
    assert q_res.onop == '='
    assert q_res.onlval == 'zipcode.zip'
    assert q_res.onrval == 'user.zip'
    assert q_res.whereop == '='
    assert q_res.wherelval != 'user.city'
    assert q_res.whererval == 'PILANI'
Exemplo n.º 4
0
def test_join_wherespace():
    query = 'SELECT * FROM USERS INNERJOIN ZIPCODES ON USERS.ZIPCODE = ZIPCODES.ZIPCODE WHERE ZIPCODES.CITY = NEW YORK'
    q_res = Parse().parseQuery(query=query)
    assert q_res.fromtable == 'users'
    assert q_res.onop == '='
    assert q_res.onlval == 'users.zipcode'
    assert q_res.onrval == 'zipcodes.zipcode'
    assert q_res.whereop != '>'
    assert q_res.wherelval == 'zipcodes.city'
    assert q_res.whererval == 'NEW YORK'