Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix: copy all arg keys, including those set to None #3108

Merged
merged 1 commit into from
Mar 9, 2024

Conversation

georgesittas
Copy link
Collaborator

@georgesittas georgesittas commented Mar 9, 2024

The following behavior was observed after the latest __deepcopy__ changes:

>>> from sqlglot.optimizer.simplify import gen
>>> from sqlglot import parse_one
>>> q = parse_one("select x from t")
>>> gen(q)
'select _,_,_,x,_,from t,_,_'
>>> gen(q.copy())
'select x,from t'

The root issue here is that we don't copy over arg keys with None values anymore due to using the set method for leaf nodes, meaning that the original and the copied AST may now have different args dicts.

(The self.assertEqual(query, query.copy()) test passes in main - I added it to future-proof __deepcopy__, __eq__)

@tobymao tobymao merged commit fa84e2c into main Mar 9, 2024
5 checks passed
@tobymao tobymao deleted the jo/copy_none_args_too branch March 9, 2024 03:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants