SQL Parser/Extender
I have a situation where I need to extend some user defined SQL. For example, I have a query that may or may not have an OFFSET
and LIMIT
defined, but I need to add/override these values. I can't simply append this to the SQL because I won't know specifically how the SQL is structured so some parsing and analysis will need to be performed anyway. I could simply regex search for OFFSET
and LIMIT
, but I also need to allow for things like doing a count()
call on the query, which means I need to parse the SELECT
fields so that they can be replaced with something like SELECT count(*)
to return a row count.