Changeset 842 for trunk/pgdb.py


Ignore:
Timestamp:
Feb 8, 2016, 4:02:10 PM (4 years ago)
Author:
cito
Message:

Treat percent signs in SQL strings always the same

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/pgdb.py

    r841 r842  
    796796
    797797        This function works for both mappings and sequences.
     798
     799        The function should be used even when there are no parameters,
     800        so that we have a consistent behavior regarding percent signs.
    798801        """
    799         if isinstance(parameters, dict):
    800             parameters = _quotedict(parameters)
    801             parameters.quote = self._quote
    802         else:
    803             parameters = tuple(map(self._quote, parameters))
     802        if parameters:
     803            if isinstance(parameters, dict):
     804                parameters = _quotedict(parameters)
     805                parameters.quote = self._quote
     806            else:
     807                parameters = tuple(map(self._quote, parameters))
     808        else:
     809            parameters = {}
    804810        return string % parameters
    805811
     
    885891            for parameters in seq_of_parameters:
    886892                sql = operation
    887                 if parameters:
    888                     sql = self._quoteparams(sql, parameters)
     893                sql = self._quoteparams(sql, parameters)
    889894                rows = self._src.execute(sql)
    890895                if rows:  # true if not DML
Note: See TracChangeset for help on using the changeset viewer.