Giter VIP home page Giter VIP logo

Comments (5)

grigi avatar grigi commented on July 22, 2024

Started this at kayak/pypika#201

from tortoise-orm.

arlyon avatar arlyon commented on July 22, 2024

Just ran into a problem with the GIS work that this should solve.

Unless I am mistaken this will have the side-effect of allowing us to use pypika function objects in queries as well since pypika should properly handle converting them to raw sql. Practically everything in GIS is done via SQL functions and currently if you pass them in to the sql driver values list instead of having pypika "render" it properly it will wrap it in quotes / escape it.

Although re-running a query with a mixture of functions and raw sql parameters may cause problems because of the INSERT_CACHE on tortoise's end

from tortoise-orm.

grigi avatar grigi commented on July 22, 2024

Hmm, I think this will help for any non-text object. Pypika has a Function class in utils.py that you could subclass for SQL functions?
I think as long as you pass a value parameter for inserts only, I think it would work. But yes, for that to work PyPika and Tortoise would need to update.

I also think #72 and 'capabilities' would probably be needed to make the GIS implementation not feel hacky.

from tortoise-orm.

grigi avatar grigi commented on July 22, 2024

PyPika 0.22 is released with Parameter() syntax. we should update to use it where we can.
I had a look at filtering/updating, and it seems to require quite the refactor to do it.

from tortoise-orm.

grigi avatar grigi commented on July 22, 2024

v0.16.6 fixed some SQL injection issues for MySQL.
We should focus on parametrizing Queryset Updates as they are at least contained in the UpdateQuery.

from tortoise-orm.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.