This repository was archived by the owner on Dec 16, 2022. It is now read-only.
File tree 1 file changed +6
-3
lines changed
1 file changed +6
-3
lines changed Original file line number Diff line number Diff line change @@ -87,8 +87,9 @@ def _update_grammar(self):
87
87
ternary expression will refer to the start and end times.
88
88
"""
89
89
90
- # This will give us a shallow copy, but that's OK because everything
91
- # inside is immutable so we get a new copy of it.
90
+ # This will give us a shallow copy. We have to be careful here because the ``Grammar`` object
91
+ # contains ``Expression`` objects that have tuples containing the members of that expression.
92
+ # We have to create new sub-expression objects so that original grammar is not mutated.
92
93
new_grammar = copy (AtisWorld .sql_table_context .grammar )
93
94
94
95
numbers = self ._get_numeric_database_values ('number' )
@@ -154,7 +155,9 @@ def _update_grammar(self):
154
155
new_binary_expressions .extend ([month_binary_expression ,
155
156
day_binary_expression ])
156
157
157
- new_grammar ['biexpr' ].members = new_grammar ['biexpr' ].members + tuple (new_binary_expressions )
158
+ new_binary_expressions = new_binary_expressions + list (new_grammar ['biexpr' ].members )
159
+ new_grammar ['biexpr' ] = OneOf (* new_binary_expressions , name = 'biexpr' )
160
+ self ._update_expression_reference (new_grammar , 'condition' , 'biexpr' )
158
161
return new_grammar
159
162
160
163
def _get_numeric_database_values (self ,
You can’t perform that action at this time.
0 commit comments