-
-
Notifications
You must be signed in to change notification settings - Fork 32.6k
Refs #28643 -- Added Repeat database function. #9808
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
Conversation
37014cb
to
8653ab3
Compare
Failures on MySQL are not related with this PR, it returns wrong results also for other functions, e.g. |
It turns out that |
Looks good, pending the MySQL issue. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM. Just the one suggestion.
django/db/backends/sqlite3/base.py
Outdated
@@ -170,6 +170,7 @@ def get_new_connection(self, conn_params): | |||
conn.create_function("django_format_dtdelta", 3, _sqlite_format_dtdelta) | |||
conn.create_function("django_power", 2, _sqlite_power) | |||
conn.create_function('LPAD', 3, _sqlite_lpad) | |||
conn.create_function('REPEAT', 2, _sqlite_repeat) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd make this a lambda or use operator.mul
.
I added the separate ticket 29251 for the MySQL issue. |
tests/db_functions/test_repeat.py
Outdated
authors = Author.objects.annotate(repeated_text=function) | ||
self.assertQuerysetEqual(authors, [repeated_text], lambda a: a.repeated_text, ordered=False) | ||
|
||
def test_repeat_negative_number(self): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
chop "_repeat"
tests/db_functions/test_repeat.py
Outdated
|
||
|
||
class RepeatTests(TestCase): | ||
def test_repeat(self): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
test_basic
Thanks Tim Graham and Nick Pope for reviews.
@timgraham Thanks for the review. |
https://code.djangoproject.com/ticket/28643