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

Rename .escape() to .quote() #217

Closed
simonw opened this issue Jan 2, 2021 · 2 comments
Closed

Rename .escape() to .quote() #217

simonw opened this issue Jan 2, 2021 · 2 comments

Comments

@simonw
Copy link
Owner

simonw commented Jan 2, 2021

.quote() is a better name because it reflects that the method adds quotes around the value.

This method has never been documented so I'm going to rename it without a major version bump.

@simonw
Copy link
Owner Author

simonw commented Jan 2, 2021

def escape(self, value):
# Normally we would use .execute(sql, [params]) for escaping, but
# occasionally that isn't available - most notable when we need
# to include a "... DEFAULT 'value'" in a column definition.
return self.execute(
# Use SQLite itself to correctly escape this string:
"SELECT quote(:value)",
{"value": value},
).fetchone()[0]

@simonw simonw closed this as completed in 3d041d3 Jan 3, 2021
@simonw
Copy link
Owner Author

simonw commented Jan 3, 2021

simonw added a commit that referenced this issue Jan 3, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant