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

quote order_by field in SQL #52

Merged
merged 1 commit into from
Jan 30, 2023
Merged

quote order_by field in SQL #52

merged 1 commit into from
Jan 30, 2023

Conversation

taobojlen
Copy link
Contributor

@taobojlen taobojlen commented Jan 30, 2023

Fix #51

This allows using an ordering field called order. Because order is a reserved keyword in SQL, this would cause errors previously.

I first reproduced the issue by changing the order field in the test Model. If you'd rather I create a new test model for this, let me know!

I only tested this with postgres locally, so I'm trusting your test suite for other databases. If I can do more to test these, again, please ask :)

@matthiask
Copy link
Member

Thanks! Changing existing models is fine. I wonder if we shouldn't use connection.ops.quote_name but let's see what the tests say :)

@taobojlen
Copy link
Contributor Author

looks like quote_name is the right approach! i'll give that a go.

i'm not sure what's going on with the 3.8 and 3.9 tests, though -- is that something you've seen before? if not i'll dig deeper!

matthiask added a commit that referenced this pull request Jan 30, 2023
@matthiask
Copy link
Member

The next Django version will drop support for 3.8/3.9. Maybe you could push again so that we can re-check if it works now?

@@ -279,6 +278,8 @@ def as_sql(self, *args, **kwargs):
if _ordered_by_integer(opts, params)
else self.CTE_MYSQL_WITH_TEXT_ORDERING
)
if params["order_by"]:
Copy link
Contributor Author

Choose a reason for hiding this comment

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

i'm not sure if order_by can actually be None, but i don't want to risk breaking things for any existing users in case it is.

@taobojlen
Copy link
Contributor Author

@matthiask yes! done, re-pushed :)

@matthiask matthiask merged commit 2fe8e8b into feincms:main Jan 30, 2023
@matthiask
Copy link
Member

Great, thanks!

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.

PostgreSQL syntax error when using with django-ordered-model
2 participants