Giter Site home page Giter Site logo

no such function: MONTH about ralph HOT 6 CLOSED

dccmx avatar dccmx commented on May 20, 2024
no such function: MONTH

from ralph.

Comments (6)

ambv avatar ambv commented on May 20, 2024

Thanks for your feedback. Currently the CMDB module works only on the MySQL backend, as described in http://ralph.allegrogroup.com/doc/cmdb.html#installation. We're planning to enable this feature for SQLite and PostgreSQL in a later version. Patches welcome :)

from ralph.

toudi avatar toudi commented on May 20, 2024

There is a raw SQL query in this file. i don't know how it managed to pass the code review, however, if you stick to standard django querysetting, you're good to go.

therefore, instead of:

MONTH(ch.time)=%s

use

from ralph.cmdb.models import CI

then query for the data:

now = datetime.now()
objects = CI.objects.filter( ... )
.filter(time__month = month).filter(time__month = now.year)

and agregate ( https://docs.djangoproject.com/en/dev/topics/db/aggregation/ )

unless you validate the type / kwargs['type'] argument which is defined as \w+ in urls.py, this query is vunerable for SQL injection.

from ralph.

deshipu avatar deshipu commented on May 20, 2024

The raw query is not pretty, and we will eventually replace it with something more integrated with the ORM (it's a little bit trickier than it looks), but you are mistaken about it being vulnerable to SQL injection, as cursor.execute() escapes the values that are passed into it, so don't panic.

from ralph.

toudi avatar toudi commented on May 20, 2024

indeed, i was mistaken by %s in the query and i automatically assumed there was % [params] somwhere further.

i noticed that you also use sqlalchemy, so even if django itself doesn't cut it for you, you can use sqlalchemy wrapper for django's models and do

model.sa.query()

and so on.

from ralph.

deshipu avatar deshipu commented on May 20, 2024

We will certainly get to that and come up with a solution that works on all supported database backends.

from ralph.

xor-xor avatar xor-xor commented on May 20, 2024

I'm closing this issue - there was no activity here for long enough and AFAIK, we are not going for db backends other than MySQL in the nearest future.

from ralph.

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.