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

Function signature parsing in drop statement fails if param name includes "default" #48

Open
olirice opened this issue May 24, 2021 · 0 comments

Comments

@olirice
Copy link
Owner

olirice commented May 24, 2021

parameters = [x[: len(x.lower().split("default")[0])] for x in parameters]

This breaks when when a parameter name includes the word "default"

e.g.

jsonb_array_elements(arr jsonb, default_arr jsonb = '[]')
from parse import parse
template = "{function_name}({parameters})"
result = parse(template, self.signature, case_sensitive=False)
function_name = result["function_name"]
parameters_str = result["parameters"].strip()
parameters: List[str] = parameters_str.split(",")

# HERE      
parameters = [x[: len(x.lower().split("default")[0])] for x in parameters]
# Output
# [['arr jsonb'], [' ', "_arr jsonb = '[]'"]] 
# Note: the leading space gets split into its own element
@olirice olirice changed the title Function signature parsing in drop statement Function signature parsing in drop statement fails if param name includes "default" May 24, 2021
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

No branches or pull requests

1 participant