Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

get_query_tables get not only table names but sometimes column names as well #457

Open
horvatha opened this issue Dec 16, 2023 · 0 comments

Comments

@horvatha
Copy link

horvatha commented Dec 16, 2023

If I run get_query_tables with this string as an argument, I think only TABLE1 should be in the value it returns, and MTYPE shouldn't be there.

SELECT   *
FROM     TABLE1
WHERE
    SNAPSHOTDATE = (SELECT MAX(SNAPSHOTDATE) FROM TABLE1)
    AND (MTYPE NOT IN ('Item1', 'Item2'))

I would assume, that this function run without assertion error.

from sql_metadata.compat import get_query_tables

def test_get_query_tables():
    sql = """
SELECT   *
FROM     TABLE1
WHERE
    SNAPSHOTDATE = (SELECT MAX(SNAPSHOTDATE) FROM TABLE1)
    AND (MTYPE NOT IN ('Item1', 'Item2'))
    """
    assert 'MTYPE' not in get_query_tables(sql)

I've installed sql_metadata==2.10.0 with pip and tested it with Python 3.11.0rc1.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant