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

[IMP] Show examples of how to format objects names in SQL #44

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

ebirbe
Copy link

@ebirbe ebirbe commented Dec 6, 2019

When you need to build SQL quieres with, for example, dynamic table
names you should use the psycopg2 class AsIs in order to prevent
sql-injection, SQL syntax errors and also pylint errors related with
the SQL format.

/cc @moylop260

When you need to build SQL quieres with, for example, dynamic table
names you should use the `psycopg2` class `AsIs` in order to prevent
sql-injection, SQL syntax errors and also pylint errors related with
the SQL format.
Copy link

@moylop260 moylop260 left a comment

Choose a reason for hiding this comment

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

👍

@pedrobaeza
Copy link
Member

AsIs is a dirty trick. The best way to do it is through sql query builder. Look for example at https://github.com/OCA/OpenUpgrade/pull/2105/files

@moylop260
Copy link

@ebirbe
Sorry, @pedrobaeza is right!

Let me make depth tests for both concepts sql.Identifier and extensions.AsIs since that I didn't remember the rationale of the issue.

@yajo @odony
What do you prefer to use?

Regards!

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