prompt: You will be provided with a partial code base and an issue statement explaining a problem to resolve.
  <issue>
  migrations fail for database name containing "-"
  **Describe the bug**
    Applying memory.0007_use_trigram...Traceback (most recent call last):
    File "/usr/lib/python3.6/site-packages/django/db/backends/utils.py", line 84, in _execute
      return self.cursor.execute(sql, params)
  psycopg2.errors.SyntaxError: syntax error at or near "-"
  LINE 1: ALTER DATABASE weblate-staging SET pg_trgm.similarity_thresh...
                                ^
  **To Reproduce**
  Set the database name to "weblate-staging"
  
  I worked around this by changing of
  ALTER DATABASE {} SET
  to
  ALTER DATABASE \"{}\" SET
  in 0007_use_trigram.py and 0008_adjust_similarity.py.
  
  weblate-4.1.1
  
  </issue>
  <code>
  [start of weblate/memory/migrations/0008_adjust_similarity.py]
  1 # Generated by Django 3.0.5 on 2020-05-12 11:44
  2 
  3 from django.db import migrations
  4 
  5 
  6 def update_index(apps, schema_editor):
  7     if schema_editor.connection.vendor != "postgresql":
  8         return
  9     # This ensures that extensions are loaded into the session. Without that
  10     # the next ALTER database fails unless we're running as superuser (which
  11     # is allowed to set non existing parameters, so missing extension doesn't
  12     # matter)
  13     # See https://www.postgresql.org/message-id/6376.1533675236%40sss.pgh.pa.us
  14     schema_editor.execute("SELECT show_limit()")
  15 
  16     schema_editor.execute(
  17         "ALTER ROLE {} SET pg_trgm.similarity_threshold = 0.5".format(
  18             schema_editor.connection.settings_dict["USER"]
  19         )
  20     )
  21 
  22 
  23 class Migration(migrations.Migration):
  24 
  25     dependencies = [
  26         ("memory", "0007_use_trigram"),
  27     ]
  28 
  29     operations = [
  30         migrations.RunPython(
  31             update_index, migrations.RunPython.noop, elidable=False, atomic=False
  32         )
  33     ]
  34
  [end of weblate/memory/migrations/0008_adjust_similarity.py]
  </code>
  
  I need you to solve this issue by generating a single patch file that I can apply directly to this repository using git apply. Please respond with a single patch file in the following format.
  <patch>
  diff --git a/file.py b/file.py
  --- a/file.py
  +++ b/file.py
  @@ -1,27 +1,35 @@
   def euclidean(a, b):
  -    while b:
  -        a, b = b, a % b
  -    return a
  +    if b == 0:
  +        return a
  +    return euclidean(b, a % b)
   
   
   def bresenham(x0, y0, x1, y1):
       points = []
       dx = abs(x1 - x0)
       dy = abs(y1 - y0)
  -    sx = 1 if x0 < x1 else -1
  -    sy = 1 if y0 < y1 else -1
  -    err = dx - dy
  +    x, y = x0, y0
  +    sx = -1 if x0 > x1 else 1
  +    sy = -1 if y0 > y1 else 1
   
  -    while True:
  -        points.append((x0, y0))
  -        if x0 == x1 and y0 == y1:
  -            break
  -        e2 = 2 * err
  -        if e2 > -dy:
  -            err -= dy
  -            x0 += sx
  -        if e2 < dx:
  -            err += dx
  -            y0 += sy
  +    if dx > dy:
  +        err = dx / 2.0
  +        while x != x1:
  +            points.append((x, y))
  +            err -= dy
  +            if err < 0:
  +                y += sy
  +                err += dx
  +            x += sx
  +    else:
  +        err = dy / 2.0
  +        while y != y1:
  +            points.append((x, y))
  +            err -= dx
  +            if err < 0:
  +                x += sx
  +                err += dy
  +            y += sy
  +
  +    points.append((x, y))
       return points
  
  </patch>
golden_diff: diff --git a/weblate/memory/migrations/0008_adjust_similarity.py b/weblate/memory/migrations/0008_adjust_similarity.py
  --- a/weblate/memory/migrations/0008_adjust_similarity.py
  +++ b/weblate/memory/migrations/0008_adjust_similarity.py
  @@ -15,7 +15,7 @@
   
       schema_editor.execute(
           "ALTER ROLE {} SET pg_trgm.similarity_threshold = 0.5".format(
  -            schema_editor.connection.settings_dict["USER"]
  +            schema_editor.quote_name(schema_editor.connection.settings_dict["USER"])
           )
       )
  
verification_info: {"golden_diff": "diff --git a/weblate/memory/migrations/0008_adjust_similarity.py b/weblate/memory/migrations/0008_adjust_similarity.py\n--- a/weblate/memory/migrations/0008_adjust_similarity.py\n+++ b/weblate/memory/migrations/0008_adjust_similarity.py\n@@ -15,7 +15,7 @@\n \n     schema_editor.execute(\n         \"ALTER ROLE {} SET pg_trgm.similarity_threshold = 0.5\".format(\n-            schema_editor.connection.settings_dict[\"USER\"]\n+            schema_editor.quote_name(schema_editor.connection.settings_dict[\"USER\"])\n         )\n     )\n", "issue": "migrations fail for database name containing \"-\"\n**Describe the bug**\r\n  Applying memory.0007_use_trigram...Traceback (most recent call last):\r\n  File \"/usr/lib/python3.6/site-packages/django/db/backends/utils.py\", line 84, in _execute\r\n    return self.cursor.execute(sql, params)\r\npsycopg2.errors.SyntaxError: syntax error at or near \"-\"\r\nLINE 1: ALTER DATABASE weblate-staging SET pg_trgm.similarity_thresh...\r\n                              ^\r\n**To Reproduce**\r\nSet the database name to \"weblate-staging\"\r\n\r\nI worked around this by changing of\r\nALTER DATABASE {} SET\r\nto\r\nALTER DATABASE \\\"{}\\\" SET\r\nin 0007_use_trigram.py and 0008_adjust_similarity.py.\r\n\r\nweblate-4.1.1\n", "before_files": [{"content": "# Generated by Django 3.0.5 on 2020-05-12 11:44\n\nfrom django.db import migrations\n\n\ndef update_index(apps, schema_editor):\n    if schema_editor.connection.vendor != \"postgresql\":\n        return\n    # This ensures that extensions are loaded into the session. Without that\n    # the next ALTER database fails unless we're running as superuser (which\n    # is allowed to set non existing parameters, so missing extension doesn't\n    # matter)\n    # See https://www.postgresql.org/message-id/6376.1533675236%40sss.pgh.pa.us\n    schema_editor.execute(\"SELECT show_limit()\")\n\n    schema_editor.execute(\n        \"ALTER ROLE {} SET pg_trgm.similarity_threshold = 0.5\".format(\n            schema_editor.connection.settings_dict[\"USER\"]\n        )\n    )\n\n\nclass Migration(migrations.Migration):\n\n    dependencies = [\n        (\"memory\", \"0007_use_trigram\"),\n    ]\n\n    operations = [\n        migrations.RunPython(\n            update_index, migrations.RunPython.noop, elidable=False, atomic=False\n        )\n    ]\n", "path": "weblate/memory/migrations/0008_adjust_similarity.py"}]}