Skip to content

Incorrect (Blank) Table Identification in SQL Queries for Update Operation #716

@emregeldegul

Description

@emregeldegul

I have encountered an issue with the tables_involved property of the SQLQuery model. Currently, this property only identifies tables involved in SELECT and JOIN operations. However, it fails to recognize tables involved in UPDATE operation.

The existing implementation:

class SQLQuery(models.Model):
    query = TextField()
    ...

    @property
    def tables_involved(self):
        ...
        for idx, component in enumerate(components):
            ...
            if component.lower() == 'from' or component.lower() == 'join' or component.lower() == 'as':
                ...
        return tables

As a result, it is not accurately capturing tables involved in UPDATE queries. This limits the utility of the tables_involved property for comprehensive SQL analysis.

I will create a pull request for this.

Honestly, is the UPDATE query useful for analysis? I'm not sure. However, it doesn't hurt to have the 'table name' field full when showing the UPDATE query.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions