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

analyze-tables should validate provide --column names #548

Closed
simonw opened this issue May 21, 2023 · 1 comment
Closed

analyze-tables should validate provide --column names #548

simonw opened this issue May 21, 2023 · 1 comment
Labels
bug Something isn't working

Comments

@simonw
Copy link
Owner

simonw commented May 21, 2023

Noticed this while testing:

If you pass a non-existent column to -c/--column you don't get an error message.

@simonw simonw added the bug Something isn't working label May 21, 2023
@simonw
Copy link
Owner Author

simonw commented May 21, 2023

Oh, I see why that is now:

def _analyze(db, tables, columns, save, common_limit=10, no_most=False, no_least=False):
if not tables:
tables = db.table_names()
todo = []
table_counts = {}
for table in tables:
table_counts[table] = db[table].count
for column in db[table].columns:
if not columns or column.name in columns:
todo.append((table, column.name))

This is because of the following command:

sqlite-utils analyze-tables table1 table2 --column x

Since you can pass multiple tables AND multiple columns, the tool currently assumes that the column(s) you specify may be available on a subset of the provided tables.

I'm going to change this so if the column is not on ANY of those tables you get an error.

@simonw simonw closed this as completed in e8c5b04 May 21, 2023
simonw added a commit that referenced this issue May 21, 2023
simonw added a commit that referenced this issue May 21, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant