diff options
author | Andi Albrecht <albrecht.andi@gmail.com> | 2016-09-14 18:42:22 +0200 |
---|---|---|
committer | Andi Albrecht <albrecht.andi@gmail.com> | 2016-09-14 18:42:22 +0200 |
commit | 4d05b441fcb801d320ac52ce90465b74d419ceac (patch) | |
tree | 0f18b1f401d1fce76be0d8403153e5616dbe573e /sqlparse/formatter.py | |
parent | 4430c5c163d8b6ffc89d83b506c8a478037d26ea (diff) | |
download | sqlparse-4d05b441fcb801d320ac52ce90465b74d419ceac.tar.gz |
Add formatter option for comma first notation (fixes #141).
Diffstat (limited to 'sqlparse/formatter.py')
-rw-r--r-- | sqlparse/formatter.py | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/sqlparse/formatter.py b/sqlparse/formatter.py index 72b50eb..a58d5af 100644 --- a/sqlparse/formatter.py +++ b/sqlparse/formatter.py @@ -97,6 +97,11 @@ def validate_options(options): raise SQLParseError('wrap_after requires a positive integer') options['wrap_after'] = wrap_after + comma_first = options.get('comma_first', False) + if comma_first not in [True, False]: + raise SQLParseError('comma_first requires a boolean value') + options['comma_first'] = comma_first + right_margin = options.get('right_margin') if right_margin is not None: try: @@ -148,7 +153,8 @@ def build_filter_stack(stack, options): stack.stmtprocess.append( filters.ReindentFilter(char=options['indent_char'], width=options['indent_width'], - wrap_after=options['wrap_after'])) + wrap_after=options['wrap_after'], + comma_first=options['comma_first'])) if options.get('reindent_aligned', False): stack.enable_grouping() |