Пример #1
0
    def _sql_message(self, as_unicode):
        from sqlalchemy.sql import util

        details = [self._message(as_unicode=as_unicode)]
        if self.statement:
            if not as_unicode and not compat.py3k:
                stmt_detail = "[SQL: %s]" % compat.safe_bytestring(
                    self.statement
                )
            else:
                stmt_detail = "[SQL: %s]" % self.statement
            details.append(stmt_detail)
            if self.params:
                if self.hide_parameters:
                    details.append(
                        "[SQL parameters hidden due to hide_parameters=True]"
                    )
                else:
                    params_repr = util._repr_params(
                        self.params, 10, ismulti=self.ismulti
                    )
                    details.append("[parameters: %r]" % params_repr)
        code_str = self._code_str()
        if code_str:
            details.append(code_str)
        return "\n".join(["(%s)" % det for det in self.detail] + details)
Пример #2
0
 def test_repr_params_positional_array(self):
     eq_(
         repr(
             sql_util._repr_params([[1, 2, 3], 5],
                                   batches=10,
                                   ismulti=False)),
         "[[1, 2, 3], 5]",
     )
Пример #3
0
    def __str__(self):
        from sqlalchemy.sql import util
        params_repr = util._repr_params(self.params, 10)

        return ' '.join(["(%s)" % det for det in self.detail] + [
            SQLAlchemyError.__str__(self),
            repr(self.statement),
            repr(params_repr)
        ])
Пример #4
0
    def __str__(self):
        from sqlalchemy.sql import util

        params_repr = util._repr_params(self.params, 10)

        return " ".join(
            ["(%s)" % det for det in self.detail]
            + [SQLAlchemyError.__str__(self), repr(self.statement), repr(params_repr)]
        )
Пример #5
0
    def __str__(self):
        from sqlalchemy.sql import util

        details = [SQLAlchemyError.__str__(self)]
        if self.statement:
            details.append("[SQL: %r]" % self.statement)
            if self.params:
                params_repr = util._repr_params(self.params, 10)
                details.append("[parameters: %r]" % params_repr)
        return ' '.join(["(%s)" % det for det in self.detail] + details)
Пример #6
0
    def __str__(self):
        from sqlalchemy.sql import util

        details = [SQLAlchemyError.__str__(self)]
        if self.statement:
            details.append("[SQL: %r]" % self.statement)
            if self.params:
                params_repr = util._repr_params(self.params, 10)
                details.append("[parameters: %r]" % params_repr)
        return ' '.join([
            "(%s)" % det for det in self.detail
        ] + details)
Пример #7
0
 def test_repr_params_named_dict(self):
     # given non-multi-params in a list.   repr params with
     # per-element truncation, mostly does the exact same thing
     params = {"key_%s" % i: i for i in range(10)}
     eq_(
         repr(
             sql_util._repr_params(params,
                                   batches=10,
                                   max_chars=80,
                                   ismulti=False)),
         repr(params),
     )
Пример #8
0
 def test_repr_params_unknown_list(self):
     # not known if given multiparams or not.   repr params with
     # straight truncation
     eq_(
         repr(
             sql_util._repr_params([[i for i in range(300)], 5],
                                   batches=10,
                                   max_chars=80)),
         "[[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11,  ... "
         "(1315 characters truncated) ... , 293, 294, 295, 296, "
         "297, 298, 299], 5]",
     )
Пример #9
0
    def _sql_message(self, as_unicode):
        from sqlalchemy.sql import util

        details = [self._message(as_unicode=as_unicode)]
        if self.statement:
            details.append("[SQL: %r]" % self.statement)
            if self.params:
                params_repr = util._repr_params(self.params, 10)
                details.append("[parameters: %r]" % params_repr)
        code_str = self._code_str()
        if code_str:
            details.append(code_str)
        return " ".join(["(%s)" % det for det in self.detail] + details)
Пример #10
0
    def _sql_message(self, as_unicode):
        from sqlalchemy.sql import util

        details = [self._message(as_unicode=as_unicode)]
        if self.statement:
            details.append("[SQL: %r]" % self.statement)
            if self.params:
                params_repr = util._repr_params(self.params, 10)
                details.append("[parameters: %r]" % params_repr)
        code_str = self._code_str()
        if code_str:
            details.append(code_str)
        return " ".join(["(%s)" % det for det in self.detail] + details)
Пример #11
0
 def test_repr_params_large_list_of_dict(self):
     eq_(
         repr(
             sql_util._repr_params(
                 [{"data": str(i)} for i in range(100)],
                 batches=10,
                 ismulti=True,
             )
         ),
         "[{'data': '0'}, {'data': '1'}, {'data': '2'}, {'data': '3'}, "
         "{'data': '4'}, {'data': '5'}, {'data': '6'}, {'data': '7'}"
         "  ... displaying 10 of 100 total bound "
         "parameter sets ...  {'data': '98'}, {'data': '99'}]",
     )
Пример #12
0
 def test_repr_params_positional_list(self):
     # given non-multi-params in a list.   repr params with
     # per-element truncation, mostly does the exact same thing
     eq_(
         repr(
             sql_util._repr_params(
                 [[i for i in range(300)], 5],
                 batches=10,
                 max_chars=80,
                 ismulti=False,
             )),
         "[[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 1 ... "
         "(1310 characters truncated) ...  "
         "292, 293, 294, 295, 296, 297, 298, 299], 5]",
     )
Пример #13
0
 def test_repr_params_ismulti_named_dict(self):
     # given non-multi-params in a list.   repr params with
     # per-element truncation, mostly does the exact same thing
     param = {"key_%s" % i: i for i in range(10)}
     eq_(
         repr(
             sql_util._repr_params(
                 [param for j in range(50)],
                 batches=5,
                 max_chars=80,
                 ismulti=True,
             )),
         "[%(param)r, %(param)r, %(param)r  ... "
         "displaying 5 of 50 total bound parameter sets ...  "
         "%(param)r, %(param)r]" % {"param": param},
     )
Пример #14
0
    def _sql_message(self, as_unicode):
        from sqlalchemy.sql import util

        details = [self._message(as_unicode=as_unicode)]
        if self.statement:
            if not as_unicode and not compat.py3k:
                stmt_detail = "[SQL: %s]" % compat.safe_bytestring(
                    self.statement
                )
            else:
                stmt_detail = "[SQL: %s]" % self.statement
            details.append(stmt_detail)
            if self.params:
                params_repr = util._repr_params(self.params, 10)
                details.append("[parameters: %r]" % params_repr)
        code_str = self._code_str()
        if code_str:
            details.append(code_str)
        return "\n".join(["(%s)" % det for det in self.detail] + details)
Пример #15
0
 def __str__(self):
     from sqlalchemy.sql import util
     params_repr = util._repr_params(self.params, 10)
     return ' '.join((SQLAlchemyError.__str__(self),
                      repr(self.statement), repr(params_repr)))
Пример #16
0
 def __str__(self):
     params_repr = util._repr_params(self.params, 10)
     return ' '.join((SQLAlchemyError.__str__(self),
                      repr(self.statement), repr(params_repr)))