Giraphne / sqlvis

Python package to visualise SQL queries as graphs
MIT License
38 stars 7 forks source link

Problem with single-quote strings #1

Open mrigger opened 2 years ago

mrigger commented 2 years ago

Thanks for the project, installing and using it worked out of the box! I noticed a minor issue when executing the code below:

from sqlvis import vis
import sqlite3

conn = sqlite3.connect(':memory:')
conn.execute('CREATE TABLE names(name TEXT)');
schema = vis.schema_from_conn(conn)
query = '''
SELECT name
FROM names
WHERE name = 'manuel'
'''
vis.visualize(query, schema)

When clicking on the name node, the string manuel is not visible and no green box is shown, which is unexpected.

Note that manuel is written in single quotes, not in double quotes. Strings in SQL are typically written using single quotes, while double quotes are reserved for identifiers (e.g., see https://stackoverflow.com/a/25141338/404483). When using double quotes like below, a green box with manuel is shown as expected:

from sqlvis import vis
import sqlite3

conn = sqlite3.connect(':memory:')
conn.execute('CREATE TABLE names(name TEXT)');
schema = vis.schema_from_conn(conn)
query = '''
SELECT name
FROM names
WHERE name = "manuel"
'''
vis.visualize(query, schema)

I'm not sure if you are actively maintaining the project and whether this issue is worth addressing, but since I just played with the project, I thought I should report it. :)