summaryrefslogtreecommitdiff
path: root/sqlparse/formatter.py
diff options
context:
space:
mode:
Diffstat (limited to 'sqlparse/formatter.py')
-rw-r--r--sqlparse/formatter.py9
1 files changed, 9 insertions, 0 deletions
diff --git a/sqlparse/formatter.py b/sqlparse/formatter.py
index 5af8743..0fa563c 100644
--- a/sqlparse/formatter.py
+++ b/sqlparse/formatter.py
@@ -30,6 +30,11 @@ def validate_options(options):
raise SQLParseError('Invalid value for strip_comments: %r'
% strip_comments)
+ use_space_around_operators = options.get('use_space_around_operators', False)
+ if use_space_around_operators not in [True, False]:
+ raise SQLParseError('Invalid value for use_space_around_operators: %r'
+ % use_space_around_operators)
+
strip_ws = options.get('strip_whitespace', False)
if strip_ws not in [True, False]:
raise SQLParseError('Invalid value for strip_whitespace: %r'
@@ -121,6 +126,10 @@ def build_filter_stack(stack, options):
stack.preprocess.append(filters.TruncateStringFilter(
width=options['truncate_strings'], char=options['truncate_char']))
+ if options.get('use_space_around_operators', False):
+ stack.enable_grouping()
+ stack.stmtprocess.append(filters.SpacesAroundOperatorsFilter())
+
# After grouping
if options.get('strip_comments'):
stack.enable_grouping()