Added :paramref:`.selectinload.chunksize` parameter to :func`.selectinload`
allowing users to configure the number of primary keys sent per IN clause
- when loading reltaionships. Pull request courtesy bekapono.
+ when loading relationships. Pull request courtesy bekapono.
--- /dev/null
+.. change::
+ :tags: postgresql, usecase
+ :tickets: 13268
+
+ Changed the default backslash escape value in the PostgreSQL dialect to
+ ``False`` to align it with the default value of
+ ``standard_conforming_strings=on``. This change should not affect most users
+ since the value is set at driver initialization on first connect.
reflection_options = ("postgresql_ignore_search_path",)
- _backslash_escapes = True
+ _backslash_escapes = False
_supports_create_index_concurrently = True
_supports_drop_index_concurrently = True
_supports_jsonb_subscripting = True
dialect = postgresql.dialect()
self.assert_compile(
sql.column("foo").ilike("bar", escape="\\"),
- "foo ILIKE %(foo_1)s::VARCHAR ESCAPE '\\\\'",
+ "foo ILIKE %(foo_1)s::VARCHAR ESCAPE '\\'",
)
self.assert_compile(
self.assert_compile(
sql.column("foo").notilike("bar", escape="\\"),
- "foo NOT ILIKE %(foo_1)s::VARCHAR ESCAPE '\\\\'",
+ "foo NOT ILIKE %(foo_1)s::VARCHAR ESCAPE '\\'",
)
self.assert_compile(
def test_backslash_escapes_detection(self, explicit_setting, expected):
engine = engines.testing_engine()
- if explicit_setting is not None:
-
- @event.listens_for(engine, "connect", insert=True)
- @event.listens_for(engine, "first_connect", insert=True)
- def connect(dbapi_connection, connection_record):
- cursor = dbapi_connection.cursor()
- cursor.execute(
- "SET SESSION standard_conforming_strings = %s"
- % ("off" if not explicit_setting else "on")
- )
- dbapi_connection.commit()
+ # check the default value before connect
+ eq_(engine.dialect._backslash_escapes, False)
+
+ @event.listens_for(engine, "connect", insert=True)
+ @event.listens_for(engine, "first_connect", insert=True)
+ def connect(dbapi_connection, connection_record):
+ cursor = dbapi_connection.cursor()
+ cursor.execute(
+ "SET SESSION standard_conforming_strings = %s"
+ % ("off" if not explicit_setting else "on")
+ )
+ dbapi_connection.commit()
with engine.connect():
eq_(engine.dialect._backslash_escapes, expected)
def test_like_7(self):
self.assert_compile(
self.table1.c.myid.ilike("somstr", escape="\\"),
- "mytable.myid ILIKE %(myid_1)s::VARCHAR ESCAPE '\\\\'",
+ "mytable.myid ILIKE %(myid_1)s::VARCHAR ESCAPE '\\'",
dialect=postgresql.dialect(),
)
def test_like_8(self):
self.assert_compile(
~self.table1.c.myid.ilike("somstr", escape="\\"),
- "mytable.myid NOT ILIKE %(myid_1)s::VARCHAR ESCAPE '\\\\'",
+ "mytable.myid NOT ILIKE %(myid_1)s::VARCHAR ESCAPE '\\'",
dialect=postgresql.dialect(),
)