andialbrecht/sqlparse

Add a lexer as an argument on public functions

YiuRULE opened this issue · 0 comments

An use case that I think about it when I work on a project who depends of sqlparse.

We can currently extend the lexer with using a singleton, as described on the documentation there: https://github.com/andialbrecht/sqlparse/blob/907fb496f90f2719095a1f01fe24db1e5c0e15a8/docs/source/extending.rst

I think the current behavior may be a problem on a project who use two different dependencies who depends of sqlparse. Project foo use two dependencies, A ask for the default configuration, B clear the entire lexer as written the configuration, the dependency A is likely to be broken due of an external dependencies as both A and B use the same singleton.

My suggestion is to be able to send a lexer parameter, if it's empty, we may use the default lexer who is the current singleton and if not, we use the lexer who was send as a parameter.

If needed I can contribute so let me know if my suggestion make sense.