diff --git a/django/db/backends/sqlite3/base.py b/django/db/backends/sqlite3/base.py index 39e3e43e47..7ec6466b1b 100644 --- a/django/db/backends/sqlite3/base.py +++ b/django/db/backends/sqlite3/base.py @@ -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