andialbrecht / sqlparse

A non-validating SQL parser module for Python
BSD 3-Clause "New" or "Revised" License
3.73k stars 695 forks source link

Method to identify if exists where clauses #336

Open rafaelreuber opened 7 years ago

rafaelreuber commented 7 years ago

Hi,

I think could be useful a method that returns True the query statement have at least one where clause.

Ex:

stmt = sqlparse.parse("select 1 from dual where 1 = 1")[0]
stmt.has_where() #Returns True

stmt = sqlparse.parse("select 1 from dual")[0]
stmt.has_where() #Returns False

I can send you a PR

andialbrecht commented 7 years ago

As a reference, see also the discussion in #256