Skip to content

adds support for other paramstyles, disables logging by default when Flask not running #73

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

Merged
merged 19 commits into from
Jul 1, 2019

Conversation

dmalan
Copy link
Member

@dmalan dmalan commented Feb 18, 2019

Previously, we only supported a paramstyle of named, https://www.python.org/dev/peps/pep-0249/#paramstyle. This adds support for all other paramstyle values as well as multiple calling conventions:

db.execute("SELECT * FROM Employee WHERE FirstName = ?", "' OR 1 = 1")

db.execute("SELECT * FROM Employee WHERE FirstName IN (?)", "Andrew")
db.execute("SELECT * FROM Employee WHERE FirstName IN (?)", ["Andrew"])
db.execute("SELECT * FROM Employee WHERE FirstName IN (?)", ("Andrew",))
db.execute("SELECT * FROM Employee WHERE FirstName IN (?)", ["Andrew", "Nancy"])
db.execute("SELECT * FROM Employee WHERE FirstName IN (?)", ("Andrew", "Nancy"))

db.execute("SELECT * FROM Employee WHERE FirstName = ? AND LastName = ?", "Andrew", "Adams")
db.execute("SELECT * FROM Employee WHERE FirstName = ? AND LastName = ?", ["Andrew", "Adams"])
db.execute("SELECT * FROM Employee WHERE FirstName = ? AND LastName = ?", ("Andrew", "Adams"))

db.execute("SELECT * FROM Employee WHERE FirstName = :1 AND LastName = :2", "Andrew", "Adams")
db.execute("SELECT * FROM Employee WHERE FirstName = :1 AND LastName = :2", ["Andrew", "Adams"])
db.execute("SELECT * FROM Employee WHERE FirstName = :1 AND LastName = :2", ("Andrew", "Adams"))

db.execute("SELECT * FROM Employee WHERE FirstName = :first AND LastName = :last", first="Andrew", last="Adams")
db.execute("SELECT * FROM Employee WHERE FirstName = :first AND LastName = :last", {"first": "Andrew", "last": "Adams"})

db.execute("SELECT * FROM Employee WHERE FirstName = %s AND LastName = %s", "Andrew", "Adams")
db.execute("SELECT * FROM Employee WHERE FirstName = %s AND LastName = %s", ["Andrew", "Adams"])
db.execute("SELECT * FROM Employee WHERE FirstName = %s AND LastName = %s", ("Andrew", "Adams"))

db.execute("SELECT * FROM Employee WHERE FirstName = %(first)s AND LastName = %(last)s", first="Andrew", last="Adams")
db.execute("SELECT * FROM Employee WHERE FirstName = %(first)s AND LastName = %(last)s", {"first": "Andrew", "last": "Adams"})

Copy link
Member

@kzidane kzidane left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also added some test cases for qmark, named, and numeric on SQLite.

@dmalan
Copy link
Member Author

dmalan commented Feb 22, 2019

@kzidane just added some checks to require that no passed-in values can go unused, whether using positional placeholders or named ones if you'd like to try this out before we ship.

@kzidane
Copy link
Member

kzidane commented Feb 22, 2019

@dmalan just uncommented my test cases. Should be good if all green.

@kzidane
Copy link
Member

kzidane commented Feb 22, 2019

@dmalan looks like it passed.

@dmalan dmalan merged commit 12747c7 into develop Jul 1, 2019
@dmalan dmalan deleted the 3.2 branch July 1, 2019 11:45
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.

3 participants