Ticket #10070: svnpatch.diff

File svnpatch.diff, 1.3 KB (added by Matias Surdi, 16 years ago)

allow dict as parameters

  • django/db/backends/sqlite3/base.py

     
    186186    you'll need to use "%%s".
    187187    """
    188188    def execute(self, query, params=()):
    189         query = self.convert_query(query, len(params))
     189        query = self.convert_query(query, params)
    190190        return Database.Cursor.execute(self, query, params)
    191191
    192192    def executemany(self, query, param_list):
    193193        try:
    194           query = self.convert_query(query, len(param_list[0]))
     194          query = self.convert_query(query, param_list[0])
    195195          return Database.Cursor.executemany(self, query, param_list)
    196196        except (IndexError,TypeError):
    197197          # No parameter list provided
    198198          return None
    199199
    200     def convert_query(self, query, num_params):
    201         return query % tuple("?" * num_params)
     200    def convert_query(self, query, params):
     201        if type(params) == dict:
     202            new_query = query
     203            for param in params:
     204                new_query = new_query.replace("%("+param+")s",":"+param)
     205            return new_query
     206        else:
     207            return query % tuple("?" * len(params))
    202208
    203209def _sqlite_extract(lookup_type, dt):
    204210    if dt is None:
Back to Top