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

Parser.columns has bug #507

Open
AliM1988 opened this issue Jul 5, 2024 · 0 comments
Open

Parser.columns has bug #507

AliM1988 opened this issue Jul 5, 2024 · 0 comments
Assignees
Labels

Comments

@AliM1988
Copy link

AliM1988 commented Jul 5, 2024

Bug that I see, it cant detect some columns:

from sql_metadata import Parser

def extract_columns_from_schema(schema_string):
    # Initialize the parser with the schema string
    parser = Parser(schema_string)

    # Extract columns using sql_metadata
    columns = parser.columns

    return columns

# Example usage:
schema_string = """
CREATE TABLE accounts (
            id INTEGER,     /* comment */
            username TEXT UNIQUE,
            status TEXT,
            online_at INTEGER,
            hash TEXT UNIQUE,
            uid TEXT UNIQUE,
            test INTEGER,
            usage INTEGER,
            
            PRIMARY KEY (id)
        )
"""

extracted_columns = extract_columns_from_schema(schema_string)
print(extracted_columns)

column username cant be detect because previous line has comment.
columns hash uid usage cant be detect because they are keyword, while SQLite create these column correctly.

It is stranger different response in ubuntu and Google Colab. In my ubuntu hashis detected .
In both, sql_metadata==2.12.0 is installed

I checked via parser.tokens:
ubuntu: value=hash,is_keyword=False
Google Colab= value=hash,is_keyword=True

@macbre macbre added the bug label Jul 6, 2024
@macbre macbre self-assigned this Jul 6, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants