Skip to content
This repository
Browse code

Fixing bad references to self.quote in mysql

  • Loading branch information...
commit ee39365fe0bb18ddfeb73eb787b7c70c6bc77f87 1 parent f4aae76
Charles Leifer authored October 16, 2012

Showing 1 changed file with 6 additions and 5 deletions. Show diff stats Hide diff stats

  1. 11  peewee.py
11  peewee.py
@@ -1731,6 +1731,7 @@ def _connect(self, database, **kwargs):
1731 1731
         return mysql.connect(db=database, **conn_kwargs)
1732 1732
 
1733 1733
     def create_foreign_key(self, model_class, field):
  1734
+        compiler = self.get_compiler()
1734 1735
         framing = """
1735 1736
             ALTER TABLE %(table)s ADD CONSTRAINT %(constraint)s
1736 1737
             FOREIGN KEY (%(field)s) REFERENCES %(to)s(%(to_field)s)%(cascade)s;
@@ -1743,11 +1744,11 @@ def create_foreign_key(self, model_class, field):
1743 1744
         )
1744 1745
 
1745 1746
         query = framing % {
1746  
-            'table': self.quote(db_table),
1747  
-            'constraint': self.quote(constraint),
1748  
-            'field': self.quote(field.db_column),
1749  
-            'to': self.quote(field.rel_model._meta.db_table),
1750  
-            'to_field': self.quote(field.rel_model._meta.primary_key.db_column),
  1747
+            'table': compiler.quote(db_table),
  1748
+            'constraint': compiler.quote(constraint),
  1749
+            'field': compiler.quote(field.db_column),
  1750
+            'to': compiler.quote(field.rel_model._meta.db_table),
  1751
+            'to_field': compiler.quote(field.rel_model._meta.primary_key.db_column),
1751 1752
             'cascade': ' ON DELETE CASCADE' if field.cascade else '',
1752 1753
         }
1753 1754
 

0 notes on commit ee39365

Please sign in to comment.
Something went wrong with that request. Please try again.