0
0
mirror of https://github.com/django/django.git synced 2024-12-01 15:42:04 +01:00

Refs #33355 -- Optimized LPad() database function on SQLite.

Co-Authored-By: Nick Pope <nick@nickpope.me.uk>
This commit is contained in:
Adam Johnson 2021-12-23 06:54:06 +01:00 committed by Mariusz Felisiak
parent ca04659b4b
commit fa4b2c15f2

View File

@ -615,9 +615,10 @@ def _sqlite_regexp(re_pattern, re_string):
@none_guard
def _sqlite_lpad(text, length, fill_text):
if len(text) >= length:
delta = length - len(text)
if delta <= 0:
return text[:length]
return (fill_text * length)[:length - len(text)] + text
return (fill_text * length)[:delta] + text
@none_guard