Skip to content

Change to all-parametrised queries #81

@grigi

Description

@grigi

Is your feature request related to a problem? Please describe.
Two actually:

  1. Security as in SQL excaping issues. Until we are 100% parametrised, we have limited defence against SQL injection attacks.
  2. We can't handle non-text representative fields for updates or filtering until we change over to parametrised, as those fields don't parse well as text.

Describe the solution you'd like
Update PyPika to allow parametrised queries.

Describe alternatives you've considered
There isn't really. Build our own is too much work for negative gain.

Additional context
We can't guarantee that parameters will be presented in the SQL query in the order we specify, so I feel the simplest solution might be to send the parameters as per usual, but then have a to_parametrised_query() method that returns (str, query parameter objects) so we can use parametrised queries, and PyPika is then in charge of managing order.

Then we need to update our code to use the parameters.

Done:

  • Add parameter support to PyPika
  • Use parameters for Inserts
  • Use parameters for Deletes
  • Use parameters for Updates
  • Add BinaryField
  • Have an escaping strategy for filters using LIKE
  • Use parameters for Queryset Updates
  • Use parameters for Queryset Filters
  • Use parameters for Related matching

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions