Skip to content

Commit f7cc9d0

Browse files
author
James William Pye
committed
Relocate the warning into the documentation.
It was already there, but wasn't as pronounced as it is now.
1 parent 9eb7d41 commit f7cc9d0

2 files changed

Lines changed: 11 additions & 14 deletions

File tree

postgresql/documentation/driver.txt

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,13 @@ For DB-API 2.0 users, the driver module is located at
1616
`postgresql.driver.dbapi20`. The DB-API 2.0 interface extends PG-API. All of the
1717
features discussed in this chapter are available on DB-API connections.
1818

19-
.. note::
19+
.. warning::
2020
PostgreSQL versions 8.1 and earlier do not support standard conforming
21-
strings. A warning will be raised whenever a connection is established to a
22-
server that does not support standard conforming strings.
21+
strings. In order to avoid subjective escape methods on connections,
22+
`postgresql.driver.pq3` enables the ``standard_conforming_strings`` setting
23+
by default. Greater care must be taken when working versions that do not
24+
support standard strings.
25+
**The majority of issues surrounding the interpolation of properly quoted literals can be easily avoided by using parameterized statements**.
2326

2427
The following identifiers are regularly used as shorthands for significant
2528
interface elements:

postgresql/driver/pq3.py

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1922,18 +1922,12 @@ def connect(self):
19221922
# Set standard_conforming_strings
19231923
scstr = self.settings.get('standard_conforming_strings')
19241924
if scstr is None or (self.version_info[0] == 8 and self.version_info[1] == 1):
1925-
# warn about non-standard strings
1926-
cm = element.ClientNotice(
1927-
message = 'standard conforming strings are not available',
1928-
severity = 'WARNING',
1929-
code = '01-00',
1930-
hint = 'Backend does not support "SET standard_conforming_strings TO ON"'
1931-
)
1932-
cm = self._convert_pq_message(cm)
1933-
cm.creator = self
1934-
cm.raise_message()
1925+
# There used to be a warning emitted here.
1926+
# It was noisy, and had little added value
1927+
# over a nice WARNING at the top of the driver documentation.
1928+
pass
19351929
elif scstr.lower() not in ('on','true','yes'):
1936-
self.settings['standard_conforming_strings'] = str(True)
1930+
self.settings['standard_conforming_strings'] = 'on'
19371931
super().connect()
19381932

19391933
def _pq_push(self, xact, controller = None):

0 commit comments

Comments
 (0)