1============= 21.3 Changelog 3============= 4 5.. changelog_imports:: 6 7 .. include:: changelog_12.rst 8 :start-line: 5 9 10 .. include:: changelog_11.rst 11 :start-line: 5 12 13.. changelog:: 14 :version: 1.3.25 15 :include_notes_from: unreleased_13 16 17.. changelog:: 18 :version: 1.3.24 19 :released: March 30, 2021 20 21 .. change:: 22 :tags: bug, schema 23 :tickets: 6152 24 25 Fixed bug first introduced in as some combination of :ticket:`2892`, 26 :ticket:`2919` nnd :ticket:`3832` where the attachment events for a 27 :class:`_types.TypeDecorator` would be doubled up against the "impl" class, 28 if the "impl" were also a :class:`_types.SchemaType`. The real-world case 29 is any :class:`_types.TypeDecorator` against :class:`_types.Enum` or 30 :class:`_types.Boolean` would get a doubled 31 :class:`_schema.CheckConstraint` when the ``create_constraint=True`` flag 32 is set. 33 34 35 .. change:: 36 :tags: bug, schema, sqlite 37 :tickets: 6007 38 :versions: 1.4.0 39 40 Fixed issue where the CHECK constraint generated by :class:`_types.Boolean` 41 or :class:`_types.Enum` would fail to render the naming convention 42 correctly after the first compilation, due to an unintended change of state 43 within the name given to the constraint. This issue was first introduced in 44 0.9 in the fix for issue #3067, and the fix revises the approach taken at 45 that time which appears to have been more involved than what was needed. 46 47 .. change:: 48 :tags: bug, orm 49 :tickets: 5983 50 :versions: 1.4.0 51 52 Removed very old warning that states that passive_deletes is not intended 53 for many-to-one relationships. While it is likely that in many cases 54 placing this parameter on a many-to-one relationship is not what was 55 intended, there are use cases where delete cascade may want to be 56 disallowed following from such a relationship. 57 58 59 60 .. change:: 61 :tags: bug, postgresql 62 :tickets: 5989 63 :versions: 1.4.0 64 65 Fixed issue where using :class:`_postgresql.aggregate_order_by` would 66 return ARRAY(NullType) under certain conditions, interfering with 67 the ability of the result object to return data correctly. 68 69 .. change:: 70 :tags: bug, schema 71 :tickets: 5919 72 :versions: 1.4.0 73 74 Repaired / implemented support for primary key constraint naming 75 conventions that use column names/keys/etc as part of the convention. In 76 particular, this includes that the :class:`.PrimaryKeyConstraint` object 77 that's automatically associated with a :class:`.schema.Table` will update 78 its name as new primary key :class:`_schema.Column` objects are added to 79 the table and then to the constraint. Internal failure modes related to 80 this constraint construction process including no columns present, no name 81 present or blank name present are now accommodated. 82 83 .. change:: 84 :tags: bug, schema 85 :tickets: 6071 86 :versions: 1.4.3 87 88 Adjusted the logic that emits DROP statements for :class:`_schema.Sequence` 89 objects among the dropping of multiple tables, such that all 90 :class:`_schema.Sequence` objects are dropped after all tables, even if the 91 given :class:`_schema.Sequence` is related only to a :class:`_schema.Table` 92 object and not directly to the overall :class:`_schema.MetaData` object. 93 The use case supports the same :class:`_schema.Sequence` being associated 94 with more than one :class:`_schema.Table` at a time. 95 96 .. change:: 97 :tags: bug, orm 98 :tickets: 5952 99 :versions: 1.4.0 100 101 Fixed issue where the process of joining two tables could fail if one of 102 the tables had an unrelated, unresolvable foreign key constraint which 103 would raise :class:`_exc.NoReferenceError` within the join process, which 104 nonetheless could be bypassed to allow the join to complete. The logic 105 which tested the exception for significance within the process would make 106 assumptions about the construct which would fail. 107 108 109 .. change:: 110 :tags: bug, postgresql, reflection 111 :tickets: 6161 112 :versions: 1.4.4 113 114 Fixed issue in PostgreSQL reflection where a column expressing "NOT NULL" 115 will supersede the nullability of a corresponding domain. 116 117 .. change:: 118 :tags: bug, engine 119 :tickets: 5929 120 :versions: 1.4.0 121 122 Fixed bug where the "schema_translate_map" feature failed to be taken into 123 account for the use case of direct execution of 124 :class:`_schema.DefaultGenerator` objects such as sequences, which included 125 the case where they were "pre-executed" in order to generate primary key 126 values when implicit_returning was disabled. 127 128 .. change:: 129 :tags: bug, orm 130 :tickets: 6001 131 :versions: 1.4.0 132 133 Fixed issue where the :class:`_mutable.MutableComposite` construct could be 134 placed into an invalid state when the parent object was already loaded, and 135 then covered by a subsequent query, due to the composite properties' 136 refresh handler replacing the object with a new one not handled by the 137 mutable extension. 138 139 140 .. change:: 141 :tags: bug, types, postgresql 142 :tickets: 6023 143 :versions: 1.4.3 144 145 Adjusted the psycopg2 dialect to emit an explicit PostgreSQL-style cast for 146 bound parameters that contain ARRAY elements. This allows the full range of 147 datatypes to function correctly within arrays. The asyncpg dialect already 148 generated these internal casts in the final statement. This also includes 149 support for array slice updates as well as the PostgreSQL-specific 150 :meth:`_postgresql.ARRAY.contains` method. 151 152 .. change:: 153 :tags: bug, mssql, reflection 154 :tickets: 5921 155 156 Fixed issue regarding SQL Server reflection for older SQL Server 2005 157 version, a call to sp_columns would not proceed correctly without being 158 prefixed with the EXEC keyword. This method is not used in current 1.4 159 series. 160 161 162.. changelog:: 163 :version: 1.3.23 164 :released: February 1, 2021 165 166 .. change:: 167 :tags: bug, ext 168 :tickets: 5836 169 170 Fixed issue where the stringification that is sometimes called when 171 attempting to generate the "key" for the ``.c`` collection on a selectable 172 would fail if the column were an unlabeled custom SQL construct using the 173 ``sqlalchemy.ext.compiler`` extension, and did not provide a default 174 compilation form; while this seems like an unusual case, it can get invoked 175 for some ORM scenarios such as when the expression is used in an "order by" 176 in combination with joined eager loading. The issue is that the lack of a 177 default compiler function was raising :class:`.CompileError` and not 178 :class:`.UnsupportedCompilationError`. 179 180 .. change:: 181 :tags: bug, postgresql 182 :tickets: 5645 183 184 For SQLAlchemy 1.3 only, setup.py pins pg8000 to a version lower than 185 1.16.6. Version 1.16.6 and above is supported by SQLAlchemy 1.4. Pull 186 request courtesy Giuseppe Lumia. 187 188 .. change:: 189 :tags: bug, postgresql 190 :tickets: 5850 191 192 Fixed issue where using :meth:`_schema.Table.to_metadata` (called 193 :meth:`_schema.Table.tometadata` in 1.3) in conjunction with a PostgreSQL 194 :class:`_postgresql.ExcludeConstraint` that made use of ad-hoc column 195 expressions would fail to copy correctly. 196 197 .. change:: 198 :tags: bug, sql 199 :tickets: 5816 200 201 Fixed bug where making use of the :meth:`.TypeEngine.with_variant` method 202 on a :class:`.TypeDecorator` type would fail to take into account the 203 dialect-specific mappings in use, due to a rule in :class:`.TypeDecorator` 204 that was instead attempting to check for chains of :class:`.TypeDecorator` 205 instances. 206 207 208 .. change:: 209 :tags: bug, mysql, reflection 210 :tickets: 5860 211 212 Fixed bug where MySQL server default reflection would fail for numeric 213 values with a negation symbol present. 214 215 216 .. change:: 217 :tags: bug, oracle 218 :tickets: 5813 219 220 Fixed regression in Oracle dialect introduced by :ticket:`4894` in 221 SQLAlchemy 1.3.11 where use of a SQL expression in RETURNING for an UPDATE 222 would fail to compile, due to a check for "server_default" when an 223 arbitrary SQL expression is not a column. 224 225 226 .. change:: 227 :tags: usecase, mysql 228 :tickets: 5808 229 230 Casting to ``FLOAT`` is now supported in MySQL >= (8, 0, 17) and 231 MariaDb >= (10, 4, 5). 232 233 .. change:: 234 :tags: bug, mysql 235 :tickets: 5898 236 237 Fixed long-lived bug in MySQL dialect where the maximum identifier length 238 of 255 was too long for names of all types of constraints, not just 239 indexes, all of which have a size limit of 64. As metadata naming 240 conventions can create too-long names in this area, apply the limit to the 241 identifier generator within the DDL compiler. 242 243 .. change:: 244 :tags: bug, oracle 245 :tickets: 5812 246 247 Fixed bug in Oracle dialect where retrieving a CLOB/BLOB column via 248 :meth:`_dml.Insert.returning` would fail as the LOB value would need to be 249 read when returned; additionally, repaired support for retrieval of Unicode 250 values via RETURNING under Python 2. 251 252 .. change:: 253 :tags: bug, mysql 254 :tickets: 5821 255 256 Fixed deprecation warnings that arose as a result of the release of PyMySQL 257 1.0, including deprecation warnings for the "db" and "passwd" parameters 258 now replaced with "database" and "password". 259 260 261 .. change:: 262 :tags: bug, mysql 263 :tickets: 5800 264 265 Fixed regression from SQLAlchemy 1.3.20 caused by the fix for 266 :ticket:`5462` which adds double-parenthesis for MySQL functional 267 expressions in indexes, as is required by the backend, this inadvertently 268 extended to include arbitrary :func:`_sql.text` expressions as well as 269 Alembic's internal textual component, which are required by Alembic for 270 arbitrary index expressions which don't imply double parenthesis. The 271 check has been narrowed to include only binary/ unary/functional 272 expressions directly. 273 274.. changelog:: 275 :version: 1.3.22 276 :released: December 18, 2020 277 278 .. change:: 279 :tags: bug, oracle 280 :tickets: 5784 281 :versions: 1.4.0b2 282 283 Fixed regression which occurred due to :ticket:`5755` which implemented 284 isolation level support for Oracle. It has been reported that many Oracle 285 accounts don't actually have permission to query the ``v$transaction`` 286 view so this feature has been altered to gracefully fallback when it fails 287 upon database connect, where the dialect will assume "READ COMMITTED" is 288 the default isolation level as was the case prior to SQLAlchemy 1.3.21. 289 However, explicit use of the :meth:`_engine.Connection.get_isolation_level` 290 method must now necessarily raise an exception, as Oracle databases with 291 this restriction explicitly disallow the user from reading the current 292 isolation level. 293 294.. changelog:: 295 :version: 1.3.21 296 :released: December 17, 2020 297 298 .. change:: 299 :tags: bug, orm 300 :tickets: 5774 301 :versions: 1.4.0b2 302 303 Added a comprehensive check and an informative error message for the case 304 where a mapped class, or a string mapped class name, is passed to 305 :paramref:`_orm.relationship.secondary`. This is an extremely common error 306 which warrants a clear message. 307 308 Additionally, added a new rule to the class registry resolution such that 309 with regards to the :paramref:`_orm.relationship.secondary` parameter, if a 310 mapped class and its table are of the identical string name, the 311 :class:`.Table` will be favored when resolving this parameter. In all 312 other cases, the class continues to be favored if a class and table 313 share the identical name. 314 315 .. change:: 316 :tags: sqlite, usecase 317 :tickets: 5685 318 319 Added ``sqlite_with_rowid=False`` dialect keyword to enable creating 320 tables as ``CREATE TABLE … WITHOUT ROWID``. Patch courtesy Sean Anderson. 321 322 .. change:: 323 :tags: bug, sql 324 :tickets: 5691 325 326 A warning is emitted if a returning() method such as 327 :meth:`_sql.Insert.returning` is called multiple times, as this does not 328 yet support additive operation. Version 1.4 will support additive 329 operation for this. Additionally, any combination of the 330 :meth:`_sql.Insert.returning` and :meth:`_sql.ValuesBase.return_defaults` 331 methods now raises an error as these methods are mutually exclusive; 332 previously the operation would fail silently. 333 334 335 .. change:: 336 :tags: bug, mssql 337 :tickets: 5751 338 339 Fixed bug where a CREATE INDEX statement was rendered incorrectly when 340 both ``mssql-include`` and ``mssql_where`` were specified. Pull request 341 courtesy @Adiorz. 342 343 .. change:: 344 :tags: bug, postgresql, mysql 345 :tickets: 5729 346 :versions: 1.4.0b2 347 348 Fixed regression introduced in 1.3.2 for the PostgreSQL dialect, also 349 copied out to the MySQL dialect's feature in 1.3.18, where usage of a non 350 :class:`_schema.Table` construct such as :func:`_sql.text` as the argument 351 to :paramref:`_sql.Select.with_for_update.of` would fail to be accommodated 352 correctly within the PostgreSQL or MySQL compilers. 353 354 355 .. change:: 356 :tags: bug, mssql 357 :tickets: 5646 358 359 Added SQL Server code "01000" to the list of disconnect codes. 360 361 362 .. change:: 363 :tags: usecase, postgresql 364 :tickets: 5604 365 :versions: 1.4.0b2 366 367 Added new parameter :paramref:`_postgresql.ExcludeConstraint.ops` to the 368 :class:`_postgresql.ExcludeConstraint` object, to support operator class 369 specification with this constraint. Pull request courtesy Alon Menczer. 370 371 .. change:: 372 :tags: bug, mysql, reflection 373 :tickets: 5744 374 :versions: 1.4.0b2 375 376 Fixed issue where reflecting a server default on MariaDB only that 377 contained a decimal point in the value would fail to be reflected 378 correctly, leading towards a reflected table that lacked any server 379 default. 380 381 382 .. change:: 383 :tags: bug, orm 384 :tickets: 5664 385 386 Fixed bug in :meth:`_query.Query.update` where objects in the 387 :class:`_ormsession.Session` that were already expired would be 388 unnecessarily SELECTed individually when they were refreshed by the 389 "evaluate"synchronize strategy. 390 391 .. change:: 392 :tags: usecase, oracle 393 :tickets: 5755 394 395 Implemented support for the SERIALIZABLE isolation level for Oracle 396 databases, as well as a real implementation for 397 :meth:`_engine.Connection.get_isolation_level`. 398 399 .. seealso:: 400 401 :ref:`oracle_isolation_level` 402 403 .. change:: 404 :tags: mysql, sql 405 :tickets: 5696 406 407 Added missing keywords to the ``RESERVED_WORDS`` list for the MySQL 408 dialect: ``action``, ``level``, ``mode``, ``status``, ``text``, ``time``. 409 Pull request courtesy Oscar Batori. 410 411 .. change:: 412 :tags: bug, orm 413 :tickets: 5737 414 :versions: 1.4.0b2 415 416 Fixed bug involving the ``restore_load_context`` option of ORM events such 417 as :meth:`_ormevent.InstanceEvents.load` such that the flag would not be 418 carried along to subclasses which were mapped after the event handler were 419 first established. 420 421 422 423 .. change:: 424 :tags: bug, sql 425 :tickets: 5656 426 427 Fixed structural compiler issue where some constructs such as MySQL / 428 PostgreSQL "on conflict / on duplicate key" would rely upon the state of 429 the :class:`_sql.Compiler` object being fixed against their statement as 430 the top level statement, which would fail in cases where those statements 431 are branched from a different context, such as a DDL construct linked to a 432 SQL statement. 433 434 435 .. change:: 436 :tags: mssql, sqlite, reflection 437 :tickets: 5661 438 439 Fixed issue with composite primary key columns not being reported 440 in the correct order. Patch courtesy @fulpm. 441 442.. changelog:: 443 :version: 1.3.20 444 :released: October 12, 2020 445 446 .. change:: 447 :tags: bug, orm 448 :tickets: 4428 449 450 An :class:`.ArgumentError` with more detail is now raised if the target 451 parameter for :meth:`_query.Query.join` is set to an unmapped object. 452 Prior to this change a less detailed ``AttributeError`` was raised. 453 Pull request courtesy Ramon Williams. 454 455 .. change:: 456 :tags: bug, mysql 457 :tickets: 5568 458 459 The "skip_locked" keyword used with ``with_for_update()`` will emit a 460 warning when used on MariaDB backends, and will then be ignored. This is 461 a deprecated behavior that will raise in SQLAlchemy 1.4, as an application 462 that requests "skip locked" is looking for a non-blocking operation which 463 is not available on those backends. 464 465 466 467 .. change:: 468 :tags: bug, engine 469 :tickets: 5599 470 471 Fixed issue where a non-string object sent to 472 :class:`_exc.SQLAlchemyError` or a subclass, as occurs with some third 473 party dialects, would fail to stringify correctly. Pull request 474 courtesy Andrzej Bartosiński. 475 476 .. change:: 477 :tags: bug, sql 478 :tickets: 5644 479 480 Fixed issue where the ``pickle.dumps()`` operation against 481 :class:`_expression.Over` construct would produce a recursion overflow. 482 483 .. change:: 484 :tags: postgresql, usecase 485 :tickets: 4392 486 487 The psycopg2 dialect now support PostgreSQL multiple host connections, by 488 passing host/port combinations to the query string. Pull request courtesy 489 Ramon Williams. 490 491 .. seealso:: 492 493 :ref:`psycopg2_multi_host` 494 495 .. change:: 496 :tags: bug, mysql 497 :tickets: 5617 498 499 Fixed bug where an UPDATE statement against a JOIN using MySQL multi-table 500 format would fail to include the table prefix for the target table if the 501 statement had no WHERE clause, as only the WHERE clause were scanned to 502 detect a "multi table update" at that particular point. The target 503 is now also scanned if it's a JOIN to get the leftmost table as the 504 primary table and the additional entries as additional FROM entries. 505 506 507 .. change:: 508 :tags: bug, postgresql 509 :tickets: 5518 510 511 Adjusted the :meth:`_types.ARRAY.Comparator.any` and 512 :meth:`_types.ARRAY.Comparator.all` methods to implement a straight "NOT" 513 operation for negation, rather than negating the comparison operator. 514 515 .. change:: 516 :tags: bug, pool 517 :tickets: 5582 518 519 Fixed issue where the following pool parameters were not being propagated 520 to the new pool created when :meth:`_engine.Engine.dispose` were called: 521 ``pre_ping``, ``use_lifo``. Additionally the ``recycle`` and 522 ``reset_on_return`` parameter is now propagated for the 523 :class:`_engine.AssertionPool` class. 524 525 .. change:: 526 :tags: bug, ext, associationproxy 527 :tickets: 5541, 5542 528 529 An informative error is now raised when attempting to use an association 530 proxy element as a plain column expression to be SELECTed from or used in a 531 SQL function; this use case is not currently supported. 532 533 534 .. change:: 535 :tags: bug, sql 536 :tickets: 5618 537 538 Fixed bug where an error was not raised in the case where a 539 :func:`_sql.column` were added to more than one :func:`_sql.table` at a 540 time. This raised correctly for the :class:`_schema.Column` and 541 :class:`_schema.Table` objects. An :class:`_exc.ArgumentError` is now 542 raised when this occurs. 543 544 .. change:: 545 :tags: bug, orm 546 :tickets: 4589 547 548 Fixed issue where using a loader option against a string attribute name 549 that is not actually a mapped attribute, such as a plain Python descriptor, 550 would raise an uninformative AttributeError; a descriptive error is now 551 raised. 552 553 554 555 .. change:: 556 :tags: mysql, usecase 557 :tickets: 5462 558 559 Adjusted the MySQL dialect to correctly parenthesize functional index 560 expressions as accepted by MySQL 8. Pull request courtesy Ramon Williams. 561 562 .. change:: 563 :tags: bug, engine 564 :tickets: 5632 565 566 Repaired a function-level import that was not using SQLAlchemy's standard 567 late-import system within the sqlalchemy.exc module. 568 569 570 .. change:: 571 :tags: change, mysql 572 :tickets: 5539 573 574 Add new MySQL reserved words: ``cube``, ``lateral`` added in MySQL 8.0.1 575 and 8.0.14, respectively; this indicates that these terms will be quoted if 576 used as table or column identifier names. 577 578 .. change:: 579 :tags: bug, mssql 580 :tickets: 5592 581 582 Fixed issue where a SQLAlchemy connection URI for Azure DW with 583 ``authentication=ActiveDirectoryIntegrated`` (and no username+password) 584 was not constructing the ODBC connection string in a way that was 585 acceptable to the Azure DW instance. 586 587 .. change:: 588 :tags: bug, postgresql 589 :tickets: 5520 590 591 Fixed issue where the :class:`_postgresql.ENUM` type would not consult the 592 schema translate map when emitting a CREATE TYPE or DROP TYPE during the 593 test to see if the type exists or not. Additionally, repaired an issue 594 where if the same enum were encountered multiple times in a single DDL 595 sequence, the "check" query would run repeatedly rather than relying upon a 596 cached value. 597 598 599 .. change:: 600 :tags: bug, tests 601 :tickets: 5635 602 603 Fixed incompatibilities in the test suite when running against Pytest 6.x. 604 605 606.. changelog:: 607 :version: 1.3.19 608 :released: August 17, 2020 609 610 .. change:: 611 :tags: usecase, py3k 612 :tickets: #5357 613 614 Added a ``**kw`` argument to the :meth:`.DeclarativeMeta.__init__` method. 615 This allows a class to support the :pep:`487` metaclass hook 616 ``__init_subclass__``. Pull request courtesy Ewen Gillies. 617 618 619 .. change:: 620 :tags: bug, sql 621 :tickets: 5470 622 623 Repaired an issue where the "ORDER BY" clause rendering a label name rather 624 than a complete expression, which is particularly important for SQL Server, 625 would fail to occur if the expression were enclosed in a parenthesized 626 grouping in some cases. This case has been added to test support. The 627 change additionally adjusts the "automatically add ORDER BY columns when 628 DISTINCT is present" behavior of ORM query, deprecated in 1.4, to more 629 accurately detect column expressions that are already present. 630 631 .. change:: 632 :tags: usecase, mysql 633 :tickets: 5481 634 635 The MySQL dialect will render FROM DUAL for a SELECT statement that has no 636 FROM clause but has a WHERE clause. This allows things like "SELECT 1 WHERE 637 EXISTS (subquery)" kinds of queries to be used as well as other use cases. 638 639 640 .. change:: 641 :tags: bug, mssql, sql 642 :tickets: 5467 643 644 Fixed bug where the mssql dialect incorrectly escaped object names that 645 contained ']' character(s). 646 647 .. change:: 648 :tags: bug, reflection, sqlite, mssql 649 :tickets: 5456 650 651 Applied a sweep through all included dialects to ensure names that contain 652 single or double quotes are properly escaped when querying system tables, 653 for all :class:`.Inspector` methods that accept object names as an argument 654 (e.g. table names, view names, etc). SQLite and MSSQL contained two 655 quoting issues that were repaired. 656 657 .. change:: 658 :tags: bug, mysql 659 :tickets: 5411 660 661 Fixed an issue where CREATE TABLE statements were not specifying the 662 COLLATE keyword correctly. 663 664 .. change:: 665 :tags: bug, datatypes, sql 666 :tickets: 4733 667 668 The ``LookupError`` message will now provide the user with up to four 669 possible values that a column is constrained to via the :class:`.Enum`. 670 Values longer than 11 characters will be truncated and replaced with 671 ellipses. Pull request courtesy Ramon Williams. 672 673 .. change:: 674 :tags: bug, postgresql 675 :tickets: 5476 676 677 Fixed issue where the return type for the various RANGE comparison 678 operators would itself be the same RANGE type rather than BOOLEAN, which 679 would cause an undesirable result in the case that a 680 :class:`.TypeDecorator` that defined result-processing behavior were in 681 use. Pull request courtesy Jim Bosch. 682 683 684 685 .. change:: 686 :tags: bug, mysql 687 :tickets: 5493 688 689 Added MariaDB code 1927 to the list of "disconnect" codes, as recent 690 MariaDB versions apparently use this code when the database server was 691 stopped. 692 693 .. change:: 694 :tags: usecase, declarative, orm 695 :tickets: 5513 696 697 The name of the virtual column used when using the 698 :class:`_declarative.AbstractConcreteBase` and 699 :class:`_declarative.ConcreteBase` classes can now be customized, to allow 700 for models that have a column that is actually named ``type``. Pull 701 request courtesy Jesse-Bakker. 702 703 .. change:: 704 :tags: usecase, orm 705 :tickets: 5494 706 707 Adjusted the workings of the :meth:`_orm.Mapper.all_orm_descriptors` 708 accessor to represent the attributes in the order that they are located in 709 a deterministic way, assuming the use of Python 3.6 or higher which 710 maintains the sorting order of class attributes based on how they were 711 declared. This sorting is not guaranteed to match the declared order of 712 attributes in all cases however; see the method documentation for the exact 713 scheme. 714 715 716 717 .. change:: 718 :tags: bug, sql 719 :tickets: 5500 720 721 Fixed issue where the 722 :paramref:`_engine.Connection.execution_options.schema_translate_map` 723 feature would not take effect when the :meth:`_schema.Sequence.next_value` 724 function function for a :class:`_schema.Sequence` were used in the 725 :paramref:`_schema.Column.server_default` parameter and the create table 726 DDL were emitted. 727 728.. changelog:: 729 :version: 1.3.18 730 :released: June 25, 2020 731 732 .. change:: 733 :tags: bug, sqlite 734 :tickets: 5395 735 736 Added "exists" to the list of reserved words for SQLite so that this word 737 will be quoted when used as a label or column name. Pull request courtesy 738 Thodoris Sotiropoulos. 739 740 .. change:: 741 :tags: bug, mssql 742 :tickets: 5366, 5364 743 744 Refined the logic used by the SQL Server dialect to interpret multi-part 745 schema names that contain many dots, to not actually lose any dots if the 746 name does not have bracking or quoting used, and additionally to support a 747 "dbname" token that has many parts including that it may have multiple, 748 independently-bracketed sections. 749 750 751 752 .. change:: 753 :tags: bug, mssql, pyodbc 754 :tickets: 5346 755 756 Fixed an issue in the pyodbc connector such that a warning about pyodbc 757 "drivername" would be emitted when using a totally empty URL. Empty URLs 758 are normal when producing a non-connected dialect object or when using the 759 "creator" argument to create_engine(). The warning now only emits if the 760 driver name is missing but other parameters are still present. 761 762 .. change:: 763 :tags: bug, mssql 764 :tickets: 5373 765 766 Fixed issue with assembling the ODBC connection string for the pyodbc 767 DBAPI. Tokens containing semicolons and/or braces "{}" were not being 768 correctly escaped, causing the ODBC driver to misinterpret the 769 connection string attributes. 770 771 .. change:: 772 :tags: usecase, orm 773 :tickets: 5326 774 775 Improve error message when using :meth:`_query.Query.filter_by` in 776 a query where the first entity is not a mapped class. 777 778 .. change:: 779 :tags: sql, schema 780 :tickets: 5324 781 782 Introduce :class:`.IdentityOptions` to store common parameters for 783 sequences and identity columns. 784 785 .. change:: 786 :tags: usecase, sql 787 :tickets: 5309 788 789 Added a ".schema" parameter to the :func:`_expression.table` construct, 790 allowing ad-hoc table expressions to also include a schema name. 791 Pull request courtesy Dylan Modesitt. 792 793 .. change:: 794 :tags: bug, mssql 795 :tickets: 5339 796 797 Fixed issue where ``datetime.time`` parameters were being converted to 798 ``datetime.datetime``, making them incompatible with comparisons like 799 ``>=`` against an actual :class:`_mssql.TIME` column. 800 801 .. change:: 802 :tags: bug, mssql 803 :tickets: 5359 804 805 Fixed an issue where the ``is_disconnect`` function in the SQL Server 806 pyodbc dialect was incorrectly reporting the disconnect state when the 807 exception message had a substring that matched a SQL Server ODBC error 808 code. 809 810 .. change:: 811 :tags: bug, engine 812 :tickets: 5326 813 814 Further refinements to the fixes to the "reset" agent fixed in 815 :ticket:`5326`, which now emits a warning when it is not being correctly 816 invoked and corrects for the behavior. Additional scenarios have been 817 identified and fixed where this warning was being emitted. 818 819 820 .. change:: 821 :tags: usecase, sqlite 822 :tickets: 5297 823 824 SQLite 3.31 added support for computed column. This change 825 enables their support in SQLAlchemy when targeting SQLite. 826 827 .. change:: 828 :tags: bug, schema 829 :tickets: 5276 830 831 Fixed issue where ``dialect_options`` were omitted when a 832 database object (e.g., :class:`.Table`) was copied using 833 :func:`.tometadata`. 834 835 .. change:: 836 :tags: bug, sql 837 :tickets: 5344 838 839 Correctly apply self_group in type_coerce element. 840 841 The type coerce element did not correctly apply grouping rules when using 842 in an expression 843 844 .. change:: 845 :tags: bug, oracle, reflection 846 :tickets: 5421 847 848 Fixed bug in Oracle dialect where indexes that contain the full set of 849 primary key columns would be mistaken as the primary key index itself, 850 which is omitted, even if there were multiples. The check has been refined 851 to compare the name of the primary key constraint against the index name 852 itself, rather than trying to guess based on the columns present in the 853 index. 854 855 .. change:: 856 :tags: change, sql, sybase 857 :tickets: 5294 858 859 Added ``.offset`` support to sybase dialect. 860 Pull request courtesy Alan D. Snow. 861 862 .. change:: 863 :tags: bug, engine 864 :tickets: 5341 865 866 Fixed issue in :class:`.URL` object where stringifying the object 867 would not URL encode special characters, preventing the URL from being 868 re-consumable as a real URL. Pull request courtesy Miguel Grinberg. 869 870 .. change:: 871 :tags: usecase, mysql 872 :tickets: 4860 873 874 Implemented row-level locking support for mysql. Pull request courtesy 875 Quentin Somerville. 876 877 .. change:: 878 :tags: change, mssql 879 :tickets: 5321 880 881 Moved the ``supports_sane_rowcount_returning = False`` requirement from 882 the ``PyODBCConnector`` level to the ``MSDialect_pyodbc`` since pyodbc 883 does work properly in some circumstances. 884 885 .. change:: 886 :tags: change, examples 887 888 Added new option ``--raw`` to the examples.performance suite 889 which will dump the raw profile test for consumption by any 890 number of profiling visualizer tools. Removed the "runsnake" 891 option as runsnake is very hard to build at this point; 892 893 .. change:: 894 :tags: bug, sql 895 :tickets: 5353 896 897 Added :meth:`.Select.with_hint` output to the generic SQL string that is 898 produced when calling ``str()`` on a statement. Previously, this clause 899 would be omitted under the assumption that it was dialect specific. 900 The hint text is presented within brackets to indicate the rendering 901 of such hints varies among backends. 902 903 904 .. change:: 905 :tags: usecase, orm 906 :tickets: 5198 907 908 Added a new parameter :paramref:`_orm.query_expression.default_expr` to the 909 :func:`_orm.query_expression` construct, which will be appled to queries 910 automatically if the :func:`_orm.with_expression` option is not used. Pull 911 request courtesy Haoyu Sun. 912 913.. changelog:: 914 :version: 1.3.17 915 :released: May 13, 2020 916 917 .. change:: 918 :tags: bug, oracle 919 :tickets: 5246 920 921 Some modifications to how the cx_oracle dialect sets up per-column 922 outputtype handlers for LOB and numeric datatypes to adjust for potential 923 changes coming in cx_Oracle 8. 924 925 926 .. change:: 927 :tags: bug, orm 928 :tickets: 5288 929 930 Fixed bug where using :func:`.with_polymorphic` as the target of a join via 931 :meth:`.RelationshipComparator.of_type` on a mapper that already has a 932 subquery-based with_polymorphic setting that's equivalent to the one 933 requested would not correctly alias the ON clause in the join. 934 935 .. change:: 936 :tags: bug, oracle, performance 937 :tickets: 5314 938 939 Changed the implementation of fetching CLOB and BLOB objects to use 940 cx_Oracle's native implementation which fetches CLOB/BLOB objects inline 941 with other result columns, rather than performing a separate fetch. As 942 always, this can be disabled by setting auto_convert_lobs to False. 943 944 As part of this change, the behavior of a CLOB that was given a blank 945 string on INSERT now returns None on SELECT, which is now consistent with 946 that of VARCHAR on Oracle. 947 948 949 .. change:: 950 :tags: usecase, postgresql 951 :tickets: 5265 952 953 Added support for columns or type :class:`.ARRAY` of :class:`.Enum`, 954 :class:`.JSON` or :class:`_postgresql.JSONB` in PostgreSQL. 955 Previously a workaround was required in these use cases. 956 957 958 .. change:: 959 :tags: schema 960 :tickets: 4138 961 962 Add ``comment`` attribute to :class:`_schema.Column` ``__repr__`` method. 963 964 .. change:: 965 :tags: bug, orm 966 :tickets: 5303 967 968 Fixed issue in the area of where loader options such as selectinload() 969 interact with the baked query system, such that the caching of a query is 970 not supposed to occur if the loader options themselves have elements such 971 as with_polymorphic() objects in them that currently are not 972 cache-compatible. The baked loader could sometimes not fully invalidate 973 itself in these some of these scenarios leading to missed eager loads. 974 975 976 .. change:: 977 :tags: bug, engine 978 :tickets: 5326 979 980 Fixed fairly critical issue where the DBAPI connection could be returned to 981 the connection pool while still in an un-rolled-back state. The reset agent 982 responsible for rolling back the connection could be corrupted in the case 983 that the transaction was "closed" without being rolled back or committed, 984 which can occur in some scenarios when using ORM sessions and emitting 985 .close() in a certain pattern involving savepoints. The fix ensures that 986 the reset agent is always active. 987 988 989 .. change:: 990 :tags: bug, orm 991 :tickets: 5304 992 993 Modified the internal "identity set" implementation, which is a set that 994 hashes objects on their id() rather than their hash values, to not actually 995 call the ``__hash__()`` method of the objects, which are typically 996 user-mapped objects. Some methods were calling this method as a side 997 effect of the implementation. 998 999 1000 .. change:: 1001 :tags: usecase, postgresql 1002 :tickets: 5266 1003 1004 Raise an explicit :class:`.exc.CompileError` when adding a table with a 1005 column of type :class:`.ARRAY` of :class:`.Enum` configured with 1006 :paramref:`.Enum.native_enum` set to ``False`` when 1007 :paramref:`.Enum.create_constraint` is not set to ``False`` 1008 1009 .. change:: 1010 :tags: bug, schema 1011 :tickets: 5298 1012 1013 Fixed issue where an :class:`.Index` that is deferred in being associated 1014 with a table, such as as when it contains a :class:`.Column` that is not 1015 associated with any :class:`.Table` yet, would fail to attach correctly if 1016 it also contained a non table-oriented expression. 1017 1018 1019 .. change:: 1020 :tags: change, firebird 1021 :tickets: 5278 1022 1023 Adjusted dialect loading for ``firebird://`` URIs so the external 1024 sqlalchemy-firebird dialect will be used if it has been installed, 1025 otherwise fall back to the (now deprecated) internal Firebird dialect. 1026 1027 .. change:: 1028 :tags: bug, mssql, reflection 1029 :tickets: 5255 1030 1031 Fix a regression introduced by the reflection of computed column in 1032 MSSQL when using the legacy TDS version 4.2. The dialect will try 1033 to detect the protocol version of first connect and run in compatibility 1034 mode if it cannot detect it. 1035 1036 .. change:: 1037 :tags: bug, mssql, reflection 1038 :tickets: 5271 1039 1040 Fix a regression introduced by the reflection of computed column in 1041 MSSQL when using SQL server versions before 2012, which does not support 1042 the ``concat`` function. 1043 1044 .. change:: 1045 :tags: bug, orm 1046 :tickets: 5269 1047 1048 An informative error message is raised when an ORM many-to-one comparison 1049 is attempted against an object that is not an actual mapped instance. 1050 Comparisons such as those to scalar subqueries aren't supported; 1051 generalized comparison with subqueries is better achieved using 1052 :meth:`~.RelationshipProperty.Comparator.has`. 1053 1054 1055 .. change:: 1056 :tags: usecase, orm 1057 :tickets: 5262 1058 1059 Added an accessor :attr:`.ColumnProperty.Comparator.expressions` which 1060 provides access to the group of columns mapped under a multi-column 1061 :class:`.ColumnProperty` attribute. 1062 1063 1064 .. change:: 1065 :tags: bug, schema 1066 :tickets: 5316 1067 1068 A warning is emitted when making use of the :attr:`.MetaData.sorted_tables` 1069 attribute as well as the :func:`_schema.sort_tables` function, and the 1070 given tables cannot be correctly sorted due to a cyclic dependency between 1071 foreign key constraints. In this case, the functions will no longer sort 1072 the involved tables by foreign key, and a warning will be emitted. Other 1073 tables that are not part of the cycle will still be returned in dependency 1074 order. Previously, the sorted_table routines would return a collection that 1075 would unconditionally omit all foreign keys when a cycle was detected, and 1076 no warning was emitted. 1077 1078 1079 .. change:: 1080 :tags: orm, usecase 1081 :tickets: 5237 1082 1083 Introduce :paramref:`_orm.relationship.sync_backref` flag in a relationship 1084 to control if the synchronization events that mutate the in-Python 1085 attributes are added. This supersedes the previous change :ticket:`5149`, 1086 which warned that ``viewonly=True`` relationship target of a 1087 back_populates or backref configuration would be disallowed. 1088 1089.. changelog:: 1090 :version: 1.3.16 1091 :released: April 7, 2020 1092 1093 .. change:: 1094 :tags: oracle, usecase 1095 :tickets: 5200 1096 1097 Implemented AUTOCOMMIT isolation level for Oracle when using cx_Oracle. 1098 Also added a fixed default isolation level of READ COMMITTED for Oracle. 1099 1100 1101 .. change:: 1102 :tags: bug, mysql 1103 :tickets: 5239 1104 1105 Fixed issue in MySQL dialect when connecting to a pseudo-MySQL database 1106 such as that provided by ProxySQL, the up front check for isolation level 1107 when it returns no row will not prevent the dialect from continuing to 1108 connect. A warning is emitted that the isolation level could not be 1109 detected. 1110 1111 1112 .. change:: 1113 :tags: bug, tests 1114 :tickets: 5201 1115 1116 Fixed an issue that prevented the test suite from running with the 1117 recently released py.test 5.4.0. 1118 1119 1120 .. change:: 1121 :tags: bug, oracle, reflection 1122 :tickets: 5146 1123 1124 Fixed regression / incorrect fix caused by fix for :ticket:`5146` where the 1125 Oracle dialect reads from the "all_tab_comments" view to get table comments 1126 but fails to accommodate for the current owner of the table being 1127 requested, causing it to read the wrong comment if multiple tables of the 1128 same name exist in multiple schemas. 1129 1130 1131 .. change:: 1132 :tags: types, enum 1133 :tickets: 5183 1134 1135 The :class:`.Enum` type now supports the parameter :paramref:`.Enum.length` 1136 to specify the length of the VARCHAR column to create when using 1137 non native enums by setting :paramref:`.Enum.native_enum` to ``False`` 1138 1139 .. change:: 1140 :tags: bug, orm 1141 :tickets: 5228 1142 1143 Fixed bug in :func:`_orm.selectinload` loading option where two or more 1144 loaders that represent different relationships with the same string key 1145 name as referenced from a single :func:`_orm.with_polymorphic` construct 1146 with multiple subclass mappers would fail to invoke each subqueryload 1147 separately, instead making use of a single string-based slot that would 1148 prevent the other loaders from being invoked. 1149 1150 1151 .. change:: 1152 :tags: schema, reflection 1153 :tickets: 5063 1154 1155 Added support for reflection of "computed" columns, which are now returned 1156 as part of the structure returned by :meth:`_reflection.Inspector.get_columns`. 1157 When reflecting full :class:`_schema.Table` objects, computed columns will 1158 be represented using the :class:`.Computed` construct. 1159 1160 .. change:: 1161 :tags: orm, performance 1162 :tickets: 5162 1163 1164 Modified the queries used by subqueryload and selectinload to no longer 1165 ORDER BY the primary key of the parent entity; this ordering was there to 1166 allow the rows as they come in to be copied into lists directly with a 1167 minimal level of Python-side collation. However, these ORDER BY clauses 1168 can negatively impact the performance of the query as in many scenarios 1169 these columns are derived from a subquery or are otherwise not actual 1170 primary key columns such that SQL planners cannot make use of indexes. The 1171 Python-side collation uses the native itertools.group_by() to collate the 1172 incoming rows, and has been modified to allow multiple 1173 row-groups-per-parent to be assembled together using list.extend(), which 1174 should still allow for relatively fast Python-side performance. There will 1175 still be an ORDER BY present for a relationship that includes an explicit 1176 order_by parameter, however this is the only ORDER BY that will be added to 1177 the query for both kinds of loading. 1178 1179 .. change:: 1180 :tags: mssql, mysql, oracle, usecase 1181 :tickets: 5137 1182 1183 Added support for :meth:`.ColumnOperators.is_distinct_from` and 1184 :meth:`.ColumnOperators.isnot_distinct_from` to SQL Server, 1185 MySQL, and Oracle. 1186 1187 .. change:: 1188 :tags: sqlite, usecase 1189 :tickets: 5164 1190 1191 Implemented AUTOCOMMIT isolation level for SQLite when using pysqlite. 1192 1193 .. change:: 1194 :tags: bug, postgresql 1195 :tickets: 5205 1196 1197 Fixed issue where a "covering" index, e.g. those which have an INCLUDE 1198 clause, would be reflected including all the columns in INCLUDE clause as 1199 regular columns. A warning is now emitted if these additional columns are 1200 detected indicating that they are currently ignored. Note that full 1201 support for "covering" indexes is part of :ticket:`4458`. Pull request 1202 courtesy Marat Sharafutdinov. 1203 1204 .. change:: 1205 :tags: sql, types 1206 :tickets: 5052 1207 1208 Add ability to literal compile a :class:`DateTime`, :class:`Date` 1209 or :class:`Time` when using the string dialect for debugging purposes. 1210 This change does not impact real dialect implementation that retain 1211 their current behavior. 1212 1213 .. change:: 1214 :tags: installer 1215 :tickets: 5207 1216 1217 Ensured that the "pyproject.toml" file is not included in builds, as the 1218 presence of this file indicates to pip that a pep-517 installation process 1219 should be used. As this mode of operation appears to be not well supported 1220 by current tools / distros, these problems are avoided within the scope 1221 of SQLAlchemy installation by omitting the file. 1222 1223 1224 .. change:: 1225 :tags: bug, orm 1226 :tickets: 5210 1227 1228 Fixed issue where a lazyload that uses session-local "get" against a target 1229 many-to-one relationship where an object with the correct primary key is 1230 present, however it's an instance of a sibling class, does not correctly 1231 return None as is the case when the lazy loader actually emits a load for 1232 that row. 1233 1234 .. change:: 1235 :tags: bug, orm, declarative 1236 :tickets: 5238 1237 1238 The string argument accepted as the first positional argument by the 1239 :func:`_orm.relationship` function when using the Declarative API is no longer 1240 interpreted using the Python ``eval()`` function; instead, the name is dot 1241 separated and the names are looked up directly in the name resolution 1242 dictionary without treating the value as a Python expression. However, 1243 passing a string argument to the other :func:`_orm.relationship` parameters 1244 that necessarily must accept Python expressions will still use ``eval()``; 1245 the documentation has been clarified to ensure that there is no ambiguity 1246 that this is in use. 1247 1248 .. seealso:: 1249 1250 :ref:`declarative_relationship_eval` - details on string evaluation 1251 1252.. changelog:: 1253 :version: 1.3.15 1254 :released: March 11, 2020 1255 1256 .. change:: 1257 :tags: bug, orm 1258 :tickets: 5194 1259 1260 Adjusted the error message emitted by :meth:`_query.Query.join` when a left hand 1261 side can't be located that the :meth:`_query.Query.select_from` method is the 1262 best way to resolve the issue. Also, within the 1.3 series, used a 1263 deterministic ordering when determining the FROM clause from a given column 1264 entity passed to :class:`_query.Query` so that the same expression is determined 1265 each time. 1266 1267 1268 .. change:: 1269 :tags: orm, bug 1270 :tickets: 5196 1271 1272 Fixed regression in 1.3.14 due to :ticket:`4849` where a sys.exc_info() 1273 call failed to be invoked correctly when a flush error would occur. Test 1274 coverage has been added for this exception case. 1275 1276 1277.. changelog:: 1278 :version: 1.3.14 1279 :released: March 10, 2020 1280 1281 .. change:: 1282 :tags: bug, sql, postgresql 1283 :tickets: 5181 1284 1285 Fixed bug where a CTE of an INSERT/UPDATE/DELETE that also uses RETURNING 1286 could then not be SELECTed from directly, as the internal state of the 1287 compiler would try to treat the outer SELECT as a DELETE statement itself 1288 and access nonexistent state. 1289 1290 1291 .. change:: 1292 :tags: bug, orm 1293 :tickets: 5110 1294 1295 Fixed regression caused in 1.3.13 by :ticket:`5056` where a refactor of the 1296 ORM path registry system made it such that a path could no longer be 1297 compared to an empty tuple, which can occur in a particular kind of joined 1298 eager loading path. The "empty tuple" use case has been resolved so that 1299 the path registry is compared to a path registry in all cases; the 1300 :class:`.PathRegistry` object itself now implements ``__eq__()`` and 1301 ``__ne__()`` methods which will take place for all equality comparisons and 1302 continue to succeed in the not anticipated case that a non- 1303 :class:`.PathRegistry` object is compared, while emitting a warning that 1304 this object should not be the subject of the comparison. 1305 1306 1307 1308 .. change:: 1309 :tags: bug, orm 1310 :tickets: 5149 1311 1312 Setting a relationship to viewonly=True which is also the target of a 1313 back_populates or backref configuration will now emit a warning and 1314 eventually be disallowed. back_populates refers specifically to mutation 1315 of an attribute or collection, which is disallowed when the attribute is 1316 subject to viewonly=True. The viewonly attribute is not subject to 1317 persistence behaviors which means it will not reflect correct results 1318 when it is locally mutated. 1319 1320 .. change:: 1321 :tags: bug, oracle 1322 :tickets: 5146 1323 1324 Fixed a reflection bug where table comments could only be retrieved for 1325 tables actually owned by the user but not for tables visible to the user 1326 but owned by someone else. Pull request courtesy Dave Hirschfeld. 1327 1328 .. change:: 1329 :tags: bug, performance 1330 :tickets: 5180 1331 1332 Revised an internal change to the test system added as a result of 1333 :ticket:`5085` where a testing-related module per dialect would be loaded 1334 unconditionally upon making use of that dialect, pulling in SQLAlchemy's 1335 testing framework as well as the ORM into the module import space. This 1336 would only impact initial startup time and memory to a modest extent, 1337 however it's best that these additional modules aren't reverse-dependent on 1338 straight Core usage. 1339 1340 .. change:: 1341 :tags: bug, installation 1342 :tickets: 5138 1343 1344 Vendored the ``inspect.formatannotation`` function inside of 1345 ``sqlalchemy.util.compat``, which is needed for the vendored version of 1346 ``inspect.formatargspec``. The function is not documented in cPython and 1347 is not guaranteed to be available in future Python versions. 1348 1349 1350 .. change:: 1351 :tags: bug, mssql 1352 :tickets: 5132 1353 1354 Fixed issue where the :class:`_mssql.DATETIMEOFFSET` type would not 1355 accommodate for the ``None`` value, introduced as part of the series of 1356 fixes for this type first introduced in :ticket:`4983`, :ticket:`5045`. 1357 Additionally, added support for passing a backend-specific date formatted 1358 string through this type, as is typically allowed for date/time types on 1359 most other DBAPIs. 1360 1361 .. change:: 1362 :tags: bug, engine 1363 :tickets: 5182 1364 1365 Expanded the scope of cursor/connection cleanup when a statement is 1366 executed to include when the result object fails to be constructed, or an 1367 after_cursor_execute() event raises an error, or autocommit / autoclose 1368 fails. This allows the DBAPI cursor to be cleaned up on failure and for 1369 connectionless execution allows the connection to be closed out and 1370 returned to the connection pool, where previously it waiting until garbage 1371 collection would trigger a pool return. 1372 1373 .. change:: 1374 :tags: bug, postgresql 1375 :tickets: 5158 1376 1377 Fixed issue where the "schema_translate_map" feature would not work with a 1378 PostgreSQL native enumeration type (i.e. :class:`.Enum`, 1379 :class:`_postgresql.ENUM`) in that while the "CREATE TYPE" statement would 1380 be emitted with the correct schema, the schema would not be rendered in 1381 the CREATE TABLE statement at the point at which the enumeration was 1382 referenced. 1383 1384 1385 .. change:: 1386 :tags: usecase, ext 1387 :tickets: 5114 1388 1389 Added keyword arguments to the :meth:`.MutableList.sort` function so that a 1390 key function as well as the "reverse" keyword argument can be provided. 1391 1392 1393 .. change:: 1394 :tags: bug, general, py3k 1395 :tickets: 4849 1396 1397 Applied an explicit "cause" to most if not all internally raised exceptions 1398 that are raised from within an internal exception catch, to avoid 1399 misleading stacktraces that suggest an error within the handling of an 1400 exception. While it would be preferable to suppress the internally caught 1401 exception in the way that the ``__suppress_context__`` attribute would, 1402 there does not as yet seem to be a way to do this without suppressing an 1403 enclosing user constructed context, so for now it exposes the internally 1404 caught exception as the cause so that full information about the context 1405 of the error is maintained. 1406 1407 .. change:: 1408 :tags: orm, bug 1409 :tickets: 5121 1410 1411 Fixed an additional regression in the same area as that of :ticket:`5080` 1412 introduced in 1.3.0b3 via :ticket:`4468` where the ability to create a 1413 joined option across a :func:`.with_polymorphic` into a relationship 1414 against the base class of that with_polymorphic, and then further into 1415 regular mapped relationships would fail as the base class component would 1416 not add itself to the load path in a way that could be located by the 1417 loader strategy. The changes applied in :ticket:`5080` have been further 1418 refined to also accommodate this scenario. 1419 1420 .. change:: 1421 :tags: bug, postgresql, reflection 1422 :tickets: 5170 1423 1424 Fixed bug where PostgreSQL reflection of CHECK constraints would fail to 1425 parse the constraint if the SQL text contained newline characters. The 1426 regular expression has been adjusted to accommodate for this case. Pull 1427 request courtesy Eric Borczuk. 1428 1429 .. change:: 1430 :tags: usecase, orm 1431 :tickets: 5129 1432 1433 Added a new flag :paramref:`.InstanceEvents.restore_load_context` and 1434 :paramref:`.SessionEvents.restore_load_context` which apply to the 1435 :meth:`.InstanceEvents.load`, :meth:`.InstanceEvents.refresh`, and 1436 :meth:`.SessionEvents.loaded_as_persistent` events, which when set will 1437 restore the "load context" of the object after the event hook has been 1438 called. This ensures that the object remains within the "loader context" 1439 of the load operation that is already ongoing, rather than the object being 1440 transferred to a new load context due to refresh operations which may have 1441 occurred in the event. A warning is now emitted when this condition occurs, 1442 which recommends use of the flag to resolve this case. The flag is 1443 "opt-in" so that there is no risk introduced to existing applications. 1444 1445 The change additionally adds support for the ``raw=True`` flag to 1446 session lifecycle events. 1447 1448 .. change:: 1449 :tags: bug, mysql 1450 :tickets: 5173 1451 1452 Fixed issue in MySQL :meth:`.mysql.Insert.on_duplicate_key_update` construct 1453 where using a SQL function or other composed expression for a column argument 1454 would not properly render the ``VALUES`` keyword surrounding the column 1455 itself. 1456 1457.. changelog:: 1458 :version: 1.3.13 1459 :released: January 22, 2020 1460 1461 .. change:: 1462 :tags: bug, postgresql 1463 :tickets: 5039 1464 1465 Fixed issue where the PostgreSQL dialect would fail to parse a reflected 1466 CHECK constraint that was a boolean-valued function (as opposed to a 1467 boolean-valued expression). 1468 1469 .. change:: 1470 :tags: bug, ext 1471 :tickets: 5086 1472 1473 Fixed bug in sqlalchemy.ext.serializer where a unique 1474 :class:`.BindParameter` object could conflict with itself if it were 1475 present in the mapping itself, as well as the filter condition of the 1476 query, as one side would be used against the non-deserialized version and 1477 the other side would use the deserialized version. Logic is added to 1478 :class:`.BindParameter` similar to its "clone" method which will uniquify 1479 the parameter name upon deserialize so that it doesn't conflict with its 1480 original. 1481 1482 1483 .. change:: 1484 :tags: usecase, sql 1485 :tickets: 5079 1486 1487 A function created using :class:`.GenericFunction` can now specify that the 1488 name of the function should be rendered with or without quotes by assigning 1489 the :class:`.quoted_name` construct to the .name element of the object. 1490 Prior to 1.3.4, quoting was never applied to function names, and some 1491 quoting was introduced in :ticket:`4467` but no means to force quoting for 1492 a mixed case name was available. Additionally, the :class:`.quoted_name` 1493 construct when used as the name will properly register its lowercase name 1494 in the function registry so that the name continues to be available via the 1495 ``func.`` registry. 1496 1497 .. seealso:: 1498 1499 :class:`.GenericFunction` 1500 1501 1502 .. change:: 1503 :tags: bug, engine 1504 :tickets: 5048 1505 1506 Fixed issue where the collection of value processors on a 1507 :class:`.Compiled` object would be mutated when "expanding IN" parameters 1508 were used with a datatype that has bind value processors; in particular, 1509 this would mean that when using statement caching and/or baked queries, the 1510 same compiled._bind_processors collection would be mutated concurrently. 1511 Since these processors are the same function for a given bind parameter 1512 namespace every time, there was no actual negative effect of this issue, 1513 however, the execution of a :class:`.Compiled` object should never be 1514 causing any changes in its state, especially given that they are intended 1515 to be thread-safe and reusable once fully constructed. 1516 1517 1518 .. change:: 1519 :tags: tests, postgresql 1520 :tickets: 5057 1521 1522 Improved detection of two phase transactions requirement for the PostgreSQL 1523 database by testing that max_prepared_transactions is set to a value 1524 greater than 0. Pull request courtesy Federico Caselli. 1525 1526 1527 .. change:: 1528 :tags: bug, orm, engine 1529 :tickets: 5056, 5050, 5071 1530 1531 Added test support and repaired a wide variety of unnecessary reference 1532 cycles created for short-lived objects, mostly in the area of ORM queries. 1533 Thanks much to Carson Ip for the help on this. 1534 1535 1536 .. change:: 1537 :tags: orm, bug 1538 :tickets: 5107 1539 1540 Fixed regression in loader options introduced in 1.3.0b3 via :ticket:`4468` 1541 where the ability to create a loader option using 1542 :meth:`.PropComparator.of_type` targeting an aliased entity that is an 1543 inheriting subclass of the entity which the preceding relationship refers 1544 to would fail to produce a matching path. See also :ticket:`5082` fixed 1545 in this same release which involves a similar kind of issue. 1546 1547 .. change:: 1548 :tags: bug, tests 1549 :tickets: 4946 1550 1551 Fixed a few test failures which would occur on Windows due to SQLite file 1552 locking issues, as well as some timing issues in connection pool related 1553 tests; pull request courtesy Federico Caselli. 1554 1555 1556 .. change:: 1557 :tags: orm, bug 1558 :tickets: 5082 1559 1560 Fixed regression in joined eager loading introduced in 1.3.0b3 via 1561 :ticket:`4468` where the ability to create a joined option across a 1562 :func:`.with_polymorphic` into a polymorphic subclass using 1563 :meth:`.RelationshipProperty.of_type` and then further along regular mapped 1564 relationships would fail as the polymorphic subclass would not add itself 1565 to the load path in a way that could be located by the loader strategy. A 1566 tweak has been made to resolve this scenario. 1567 1568 1569 .. change:: 1570 :tags: performance, orm 1571 1572 Identified a performance issue in the system by which a join is constructed 1573 based on a mapped relationship. The clause adaption system would be used 1574 for the majority of join expressions including in the common case where no 1575 adaptation is needed. The conditions under which this adaptation occur 1576 have been refined so that average non-aliased joins along a simple 1577 relationship without a "secondary" table use about 70% less function calls. 1578 1579 1580 .. change:: 1581 :tags: usecase, postgresql 1582 :tickets: 5040 1583 1584 Added support for prefixes to the :class:`_expression.CTE` construct, to allow 1585 support for Postgresql 12 "MATERIALIZED" and "NOT MATERIALIZED" phrases. 1586 Pull request courtesy Marat Sharafutdinov. 1587 1588 .. seealso:: 1589 1590 :meth:`_expression.HasCTE.cte` 1591 1592 .. change:: 1593 :tags: bug, mssql 1594 :tickets: 5045 1595 1596 Fixed issue where a timezone-aware ``datetime`` value being converted to 1597 string for use as a parameter value of a :class:`_mssql.DATETIMEOFFSET` 1598 column was omitting the fractional seconds. 1599 1600 .. change:: 1601 :tags: bug, orm 1602 :tickets: 5068 1603 1604 Repaired a warning in the ORM flush process that was not covered by test 1605 coverage when deleting objects that use the "version_id" feature. This 1606 warning is generally unreachable unless using a dialect that sets the 1607 "supports_sane_rowcount" flag to False, which is not typically the case 1608 however is possible for some MySQL configurations as well as older Firebird 1609 drivers, and likely some third party dialects. 1610 1611 .. change:: 1612 :tags: bug, orm 1613 :tickets: 5065 1614 1615 Fixed bug where usage of joined eager loading would not properly wrap the 1616 query inside of a subquery when :meth:`_query.Query.group_by` were used against 1617 the query. When any kind of result-limiting approach is used, such as 1618 DISTINCT, LIMIT, OFFSET, joined eager loading embeds the row-limited query 1619 inside of a subquery so that the collection results are not impacted. For 1620 some reason, the presence of GROUP BY was never included in this criterion, 1621 even though it has a similar effect as using DISTINCT. Additionally, the 1622 bug would prevent using GROUP BY at all for a joined eager load query for 1623 most database platforms which forbid non-aggregated, non-grouped columns 1624 from being in the query, as the additional columns for the joined eager 1625 load would not be accepted by the database. 1626 1627 1628 1629.. changelog:: 1630 :version: 1.3.12 1631 :released: December 16, 2019 1632 1633 .. change:: 1634 :tags: bug, sql 1635 :tickets: 5028 1636 1637 Fixed bug where "distinct" keyword passed to :func:`_expression.select` would not 1638 treat a string value as a "label reference" in the same way that the 1639 :meth:`_expression.select.distinct` does; it would instead raise unconditionally. This 1640 keyword argument and the others passed to :func:`_expression.select` will ultimately 1641 be deprecated for SQLAlchemy 2.0. 1642 1643 1644 .. change:: 1645 :tags: bug, orm 1646 :tickets: 4997 1647 1648 Fixed issue involving ``lazy="raise"`` strategy where an ORM delete of an 1649 object would raise for a simple "use-get" style many-to-one relationship 1650 that had lazy="raise" configured. This is inconsistent vs. the change 1651 introduced in 1.3 as part of :ticket:`4353`, where it was established that 1652 a history operation that does not expect emit SQL should bypass the 1653 ``lazy="raise"`` check, and instead effectively treat it as 1654 ``lazy="raise_on_sql"`` for this case. The fix adjusts the lazy loader 1655 strategy to not raise for the case where the lazy load was instructed that 1656 it should not emit SQL if the object were not present. 1657 1658 .. change:: 1659 :tags: bug, sql 1660 1661 Changed the text of the exception for "Can't resolve label reference" to 1662 include other kinds of label coercions, namely that "DISTINCT" is also in 1663 this category under the PostgreSQL dialect. 1664 1665 1666 .. change:: 1667 :tags: bug, orm 1668 :tickets: 5000 1669 1670 Fixed regression introduced in 1.3.0 related to the association proxy 1671 refactor in :ticket:`4351` that prevented :func:`.composite` attributes 1672 from working in terms of an association proxy that references them. 1673 1674 .. change:: 1675 :tags: bug, mssql 1676 :tickets: 4983 1677 1678 Repaired support for the :class:`_mssql.DATETIMEOFFSET` datatype on PyODBC, 1679 by adding PyODBC-level result handlers as it does not include native 1680 support for this datatype. This includes usage of the Python 3 "timezone" 1681 tzinfo subclass in order to set up a timezone, which on Python 2 makes 1682 use of a minimal backport of "timezone" in sqlalchemy.util. 1683 1684 1685 .. change:: 1686 :tags: bug, orm 1687 :tickets: 4993 1688 1689 Setting persistence-related flags on :func:`_orm.relationship` while also 1690 setting viewonly=True will now emit a regular warning, as these flags do 1691 not make sense for a viewonly=True relationship. In particular, the 1692 "cascade" settings have their own warning that is generated based on the 1693 individual values, such as "delete, delete-orphan", that should not apply 1694 to a viewonly relationship. Note however that in the case of "cascade", 1695 these settings are still erroneously taking effect even though the 1696 relationship is set up as "viewonly". In 1.4, all persistence-related 1697 cascade settings will be disallowed on a viewonly=True relationship in 1698 order to resolve this issue. 1699 1700 .. change:: 1701 :tags: bug, sqlite 1702 :tickets: 5014 1703 1704 Fixed issue to workaround SQLite's behavior of assigning "numeric" affinity 1705 to JSON datatypes, first described at :ref:`change_3850`, which returns 1706 scalar numeric JSON values as a number and not as a string that can be JSON 1707 deserialized. The SQLite-specific JSON deserializer now gracefully 1708 degrades for this case as an exception and bypasses deserialization for 1709 single numeric values, as from a JSON perspective they are already 1710 deserialized. 1711 1712 1713 1714 .. change:: 1715 :tags: bug, orm, py3k 1716 :tickets: 4990 1717 1718 Fixed issue where when assigning a collection to itself as a slice, the 1719 mutation operation would fail as it would first erase the assigned 1720 collection inadvertently. As an assignment that does not change the 1721 contents should not generate events, the operation is now a no-op. Note 1722 that the fix only applies to Python 3; in Python 2, the ``__setitem__`` 1723 hook isn't called in this case; ``__setslice__`` is used instead which 1724 recreates the list item-by-item in all cases. 1725 1726 .. change:: 1727 :tags: bug, orm 1728 :tickets: 5034 1729 1730 Fixed issue where by if the "begin" of a transaction failed at the Core 1731 engine/connection level, such as due to network error or database is locked 1732 for some transactional recipes, within the context of the :class:`.Session` 1733 procuring that connection from the connection pool and then immediately 1734 returning it, the ORM :class:`.Session` would not close the connection 1735 despite this connection not being stored within the state of that 1736 :class:`.Session`. This would lead to the connection being cleaned out by 1737 the connection pool weakref handler within garbage collection which is an 1738 unpreferred codepath that in some special configurations can emit errors in 1739 standard error. 1740 1741.. changelog:: 1742 :version: 1.3.11 1743 :released: November 11, 2019 1744 1745 .. change:: 1746 :tags: bug, mssql 1747 :tickets: 4973 1748 1749 Fixed issue in MSSQL dialect where an expression-based OFFSET value in a 1750 SELECT would be rejected, even though the dialect can render this 1751 expression inside of a ROW NUMBER-oriented LIMIT/OFFSET construct. 1752 1753 1754 .. change:: 1755 :tags: orm, usecase 1756 :tickets: 4934 1757 1758 Added accessor :meth:`_query.Query.is_single_entity` to :class:`_query.Query`, which 1759 will indicate if the results returned by this :class:`_query.Query` will be a 1760 list of ORM entities, or a tuple of entities or column expressions. 1761 SQLAlchemy hopes to improve upon the behavior of single entity / tuples in 1762 future releases such that the behavior would be explicit up front, however 1763 this attribute should be helpful with the current behavior. Pull request 1764 courtesy Patrick Hayes. 1765 1766 .. change:: 1767 :tags: bug, mysql 1768 :tickets: 4945 1769 1770 Added "Connection was killed" message interpreted from the base 1771 pymysql.Error class in order to detect closed connection, based on reports 1772 that this message is arriving via a pymysql.InternalError() object which 1773 indicates pymysql is not handling it correctly. 1774 1775 .. change:: 1776 :tags: bug, orm 1777 :tickets: 4954 1778 1779 The :paramref:`_orm.relationship.omit_join` flag was not intended to be 1780 manually set to True, and will now emit a warning when this occurs. The 1781 omit_join optimization is detected automatically, and the ``omit_join`` 1782 flag was only intended to disable the optimization in the hypothetical case 1783 that the optimization may have interfered with correct results, which has 1784 not been observed with the modern version of this feature. Setting the 1785 flag to True when it is not automatically detected may cause the selectin 1786 load feature to not work correctly when a non-default primary join 1787 condition is in use. 1788 1789 1790 .. change:: 1791 :tags: bug, orm 1792 :tickets: 4915 1793 1794 A warning is emitted if a primary key value is passed to :meth:`_query.Query.get` 1795 that consists of None for all primary key column positions. Previously, 1796 passing a single None outside of a tuple would raise a ``TypeError`` and 1797 passing a composite None (tuple of None values) would silently pass 1798 through. The fix now coerces the single None into a tuple where it is 1799 handled consistently with the other None conditions. Thanks to Lev 1800 Izraelit for the help with this. 1801 1802 1803 .. change:: 1804 :tags: bug, orm 1805 :tickets: 4947 1806 1807 The :class:`.BakedQuery` will not cache a query that was modified by a 1808 :meth:`.QueryEvents.before_compile` event, so that compilation hooks that 1809 may be applying ad-hoc modifications to queries will take effect on each 1810 run. In particular this is helpful for events that modify queries used in 1811 lazy loading as well as eager loading such as "select in" loading. In 1812 order to re-enable caching for a query modified by this event, a new 1813 flag ``bake_ok`` is added; see :ref:`baked_with_before_compile` for 1814 details. 1815 1816 A longer term plan to provide a new form of SQL caching should solve this 1817 kind of issue more comprehensively. 1818 1819 .. change:: 1820 :tags: bug, tests 1821 :tickets: 4920 1822 1823 Fixed test failures which would occur with newer SQLite as of version 3.30 1824 or greater, due to their addition of nulls ordering syntax as well as new 1825 restrictions on aggregate functions. Pull request courtesy Nils Philippsen. 1826 1827 1828 1829 .. change:: 1830 :tags: bug, installation, windows 1831 :tickets: 4967 1832 1833 Added a workaround for a setuptools-related failure that has been observed 1834 as occurring on Windows installations, where setuptools is not correctly 1835 reporting a build error when the MSVC build dependencies are not installed 1836 and therefore not allowing graceful degradation into non C extensions 1837 builds. 1838 1839 .. change:: 1840 :tags: bug, sql, py3k 1841 :tickets: 4931 1842 1843 Changed the ``repr()`` of the :class:`.quoted_name` construct to use 1844 regular string repr() under Python 3, rather than running it through 1845 "backslashreplace" escaping, which can be misleading. 1846 1847 .. change:: 1848 :tags: bug, oracle, firebird 1849 :tickets: 4931 1850 1851 Modified the approach of "name normalization" for the Oracle and Firebird 1852 dialects, which converts from the UPPERCASE-as-case-insensitive convention 1853 of these dialects into lowercase-as-case-insensitive for SQLAlchemy, to not 1854 automatically apply the :class:`.quoted_name` construct to a name that 1855 matches itself under upper or lower case conversion, as is the case for 1856 many non-european characters. All names used within metadata structures 1857 are converted to :class:`.quoted_name` objects in any case; the change 1858 here would only affect the output of some inspection functions. 1859 1860 .. change:: 1861 :tags: bug, schema 1862 :tickets: 4911 1863 1864 Fixed bug where a table that would have a column label overlap with a plain 1865 column name, such as "foo.id AS foo_id" vs. "foo.foo_id", would prematurely 1866 generate the ``._label`` attribute for a column before this overlap could 1867 be detected due to the use of the ``index=True`` or ``unique=True`` flag on 1868 the column in conjunction with the default naming convention of 1869 ``"column_0_label"``. This would then lead to failures when ``._label`` 1870 were used later to generate a bound parameter name, in particular those 1871 used by the ORM when generating the WHERE clause for an UPDATE statement. 1872 The issue has been fixed by using an alternate ``._label`` accessor for DDL 1873 generation that does not affect the state of the :class:`_schema.Column`. The 1874 accessor also bypasses the key-deduplication step as it is not necessary 1875 for DDL, the naming is now consistently ``"<tablename>_<columnname>"`` 1876 without any subsequent numeric symbols when used in DDL. 1877 1878 1879 1880 .. change:: 1881 :tags: bug, engine 1882 :tickets: 4902 1883 1884 Fixed bug where parameter repr as used in logging and error reporting needs 1885 additional context in order to distinguish between a list of parameters for 1886 a single statement and a list of parameter lists, as the "list of lists" 1887 structure could also indicate a single parameter list where the first 1888 parameter itself is a list, such as for an array parameter. The 1889 engine/connection now passes in an additional boolean indicating how the 1890 parameters should be considered. The only SQLAlchemy backend that expects 1891 arrays as parameters is that of psycopg2 which uses pyformat parameters, 1892 so this issue has not been too apparent, however as other drivers that use 1893 positional gain more features it is important that this be supported. It 1894 also eliminates the need for the parameter repr function to guess based on 1895 the parameter structure passed. 1896 1897 .. change:: 1898 :tags: usecase, schema 1899 :tickets: 4894 1900 1901 Added DDL support for "computed columns"; these are DDL column 1902 specifications for columns that have a server-computed value, either upon 1903 SELECT (known as "virtual") or at the point of which they are INSERTed or 1904 UPDATEd (known as "stored"). Support is established for Postgresql, MySQL, 1905 Oracle SQL Server and Firebird. Thanks to Federico Caselli for lots of work 1906 on this one. 1907 1908 .. seealso:: 1909 1910 :ref:`computed_ddl` 1911 1912 1913 .. change:: 1914 :tags: bug, engine, postgresql 1915 :tickets: 4955 1916 1917 Fixed bug in :class:`_reflection.Inspector` where the cache key generation did not 1918 take into account arguments passed in the form of tuples, such as the tuple 1919 of view name styles to return for the PostgreSQL dialect. This would lead 1920 the inspector to cache too generally for a more specific set of criteria. 1921 The logic has been adjusted to include every keyword element in the cache, 1922 as every argument is expected to be appropriate for a cache else the 1923 caching decorator should be bypassed by the dialect. 1924 1925 1926 .. change:: 1927 :tags: bug, mssql 1928 :tickets: 4923 1929 1930 Fixed an issue in the :meth:`_engine.Engine.table_names` method where it would 1931 feed the dialect's default schema name back into the dialect level table 1932 function, which in the case of SQL Server would interpret it as a 1933 dot-tokenized schema name as viewed by the mssql dialect, which would 1934 cause the method to fail in the case where the database username actually 1935 had a dot inside of it. In 1.3, this method is still used by the 1936 :meth:`_schema.MetaData.reflect` function so is a prominent codepath. In 1.4, 1937 which is the current master development branch, this issue doesn't exist, 1938 both because :meth:`_schema.MetaData.reflect` isn't using this method nor does the 1939 method pass the default schema name explicitly. The fix nonetheless 1940 guards against the default server name value returned by the dialect from 1941 being interpreted as dot-tokenized name under any circumstances by 1942 wrapping it in quoted_name(). 1943 1944 .. change:: 1945 :tags: bug, orm 1946 :tickets: 4974 1947 1948 Fixed ORM bug where a "secondary" table that referred to a selectable which 1949 in some way would refer to the local primary table would apply aliasing to 1950 both sides of the join condition when a relationship-related join, either 1951 via :meth:`_query.Query.join` or by :func:`_orm.joinedload`, were generated. The 1952 "local" side is now excluded. 1953 1954 .. change:: 1955 :tags: usecase, sql 1956 :tickets: 4276 1957 1958 Added new accessors to expressions of type :class:`_types.JSON` to allow for 1959 specific datatype access and comparison, covering strings, integers, 1960 numeric, boolean elements. This revises the documented approach of 1961 CASTing to string when comparing values, instead adding specific 1962 functionality into the PostgreSQL, SQlite, MySQL dialects to reliably 1963 deliver these basic types in all cases. 1964 1965 .. seealso:: 1966 1967 :class:`_types.JSON` 1968 1969 :meth:`.JSON.Comparator.as_string` 1970 1971 :meth:`.JSON.Comparator.as_boolean` 1972 1973 :meth:`.JSON.Comparator.as_float` 1974 1975 :meth:`.JSON.Comparator.as_integer` 1976 1977 .. change:: 1978 :tags: usecase, oracle 1979 :tickets: 4799 1980 1981 Added dialect-level flag ``encoding_errors`` to the cx_Oracle dialect, 1982 which can be specified as part of :func:`_sa.create_engine`. This is passed 1983 to SQLAlchemy's unicode decoding converter under Python 2, and to 1984 cx_Oracle's ``cursor.var()`` object as the ``encodingErrors`` parameter 1985 under Python 3, for the very unusual case that broken encodings are present 1986 in the target database which cannot be fetched unless error handling is 1987 relaxed. The value is ultimately one of the Python "encoding errors" 1988 parameters passed to ``decode()``. 1989 1990 .. change:: 1991 :tags: usecase, sql 1992 :tickets: 4933 1993 1994 The :func:`_expression.text` construct now supports "unique" bound parameters, which 1995 will dynamically uniquify themselves on compilation thus allowing multiple 1996 :func:`_expression.text` constructs with the same bound parameter names to be combined 1997 together. 1998 1999 2000 .. change:: 2001 :tags: bug, oracle 2002 :tickets: 4913 2003 2004 The :class:`_types.NCHAR` datatype will now bind to the 2005 ``cx_Oracle.FIXED_NCHAR`` DBAPI data bindings when used in a bound 2006 parameter, which supplies proper comparison behavior against a 2007 variable-length string. Previously, the :class:`_types.NCHAR` datatype 2008 would bind to ``cx_oracle.NCHAR`` which is not fixed length; the 2009 :class:`_types.CHAR` datatype already binds to ``cx_Oracle.FIXED_CHAR`` 2010 so it is now consistent that :class:`_types.NCHAR` binds to 2011 ``cx_Oracle.FIXED_NCHAR``. 2012 2013 2014 2015 .. change:: 2016 :tags: bug, firebird 2017 :tickets: 4903 2018 2019 Added additional "disconnect" message "Error writing data to the 2020 connection" to Firebird disconnection detection. Pull request courtesy 2021 lukens. 2022 2023.. changelog:: 2024 :version: 1.3.10 2025 :released: October 9, 2019 2026 2027 .. change:: 2028 :tags: bug, mssql 2029 :tickets: 4857 2030 2031 Fixed bug in SQL Server dialect with new "max_identifier_length" feature 2032 where the mssql dialect already featured this flag, and the implementation 2033 did not accommodate for the new initialization hook correctly. 2034 2035 2036 .. change:: 2037 :tags: bug, oracle 2038 :tickets: 4898, 4857 2039 2040 Fixed regression in Oracle dialect that was inadvertently using max 2041 identifier length of 128 characters on Oracle server 12.2 and greater even 2042 though the stated contract for the remainder of the 1.3 series is that 2043 this value stays at 30 until version SQLAlchemy 1.4. Also repaired issues 2044 with the retrieval of the "compatibility" version, and removed the warning 2045 emitted when the "v$parameter" view was not accessible as this was causing 2046 user confusion. 2047 2048.. changelog:: 2049 :version: 1.3.9 2050 :released: October 4, 2019 2051 2052 .. change:: 2053 :tags: usecase, engine 2054 :tickets: 4857 2055 2056 Added new :func:`_sa.create_engine` parameter 2057 :paramref:`_sa.create_engine.max_identifier_length`. This overrides the 2058 dialect-coded "max identifier length" in order to accommodate for databases 2059 that have recently changed this length and the SQLAlchemy dialect has 2060 not yet been adjusted to detect for that version. This parameter interacts 2061 with the existing :paramref:`_sa.create_engine.label_length` parameter in that 2062 it establishes the maximum (and default) value for anonymously generated 2063 labels. Additionally, post-connection detection of max identifier lengths 2064 has been added to the dialect system. This feature is first being used 2065 by the Oracle dialect. 2066 2067 .. seealso:: 2068 2069 :ref:`oracle_max_identifier_lengths` - in the Oracle dialect documentation 2070 2071 .. change:: 2072 :tags: usecase, oracle 2073 :tickets: 4857 2074 2075 The Oracle dialect now emits a warning if Oracle version 12.2 or greater is 2076 used, and the :paramref:`_sa.create_engine.max_identifier_length` parameter is 2077 not set. The version in this specific case defaults to that of the 2078 "compatibility" version set in the Oracle server configuration, not the 2079 actual server version. In version 1.4, the default max_identifier_length 2080 for 12.2 or greater will move to 128 characters. In order to maintain 2081 forwards compatibility, applications should set 2082 :paramref:`_sa.create_engine.max_identifier_length` to 30 in order to maintain 2083 the same length behavior, or to 128 in order to test the upcoming behavior. 2084 This length determines among other things how generated constraint names 2085 are truncated for statements like ``CREATE CONSTRAINT`` and ``DROP 2086 CONSTRAINT``, which means a the new length may produce a name-mismatch 2087 against a name that was generated with the old length, impacting database 2088 migrations. 2089 2090 .. seealso:: 2091 2092 :ref:`oracle_max_identifier_lengths` - in the Oracle dialect documentation 2093 2094 .. change:: 2095 :tags: usecase, sqlite 2096 :tickets: 4863 2097 2098 Added support for sqlite "URI" connections, which allow for sqlite-specific 2099 flags to be passed in the query string such as "read only" for Python 2100 sqlite3 drivers that support this. 2101 2102 .. seealso:: 2103 2104 :ref:`pysqlite_uri_connections` 2105 2106 .. change:: 2107 :tags: bug, tests 2108 :tickets: 4285 2109 2110 Fixed unit test regression released in 1.3.8 that would cause failure for 2111 Oracle, SQL Server and other non-native ENUM platforms due to new 2112 enumeration tests added as part of :ticket:`4285` enum sortability in the 2113 unit of work; the enumerations created constraints that were duplicated on 2114 name. 2115 2116 .. change:: 2117 :tags: bug, oracle 2118 :tickets: 4886 2119 2120 Restored adding cx_Oracle.DATETIME to the setinputsizes() call when a 2121 SQLAlchemy :class:`.Date`, :class:`.DateTime` or :class:`.Time` datatype is 2122 used, as some complex queries require this to be present. This was removed 2123 in the 1.2 series for arbitrary reasons. 2124 2125 .. change:: 2126 :tags: bug, mssql 2127 :tickets: 4883 2128 2129 Added identifier quoting to the schema name applied to the "use" statement 2130 which is invoked when a SQL Server multipart schema name is used within a 2131 :class:`_schema.Table` that is being reflected, as well as for :class:`_reflection.Inspector` 2132 methods such as :meth:`_reflection.Inspector.get_table_names`; this accommodates for 2133 special characters or spaces in the database name. Additionally, the "use" 2134 statement is not emitted if the current database matches the target owner 2135 database name being passed. 2136 2137 .. change:: 2138 :tags: bug, orm 2139 :tickets: 4872 2140 2141 Fixed regression in selectinload loader strategy caused by :ticket:`4775` 2142 (released in version 1.3.6) where a many-to-one attribute of None would no 2143 longer be populated by the loader. While this was usually not noticeable 2144 due to the lazyloader populating None upon get, it would lead to a detached 2145 instance error if the object were detached. 2146 2147 .. change:: 2148 :tags: bug, orm 2149 :tickets: 4873 2150 2151 Passing a plain string expression to :meth:`.Session.query` is deprecated, 2152 as all string coercions were removed in :ticket:`4481` and this one should 2153 have been included. The :func:`_expression.literal_column` function may be used to 2154 produce a textual column expression. 2155 2156 .. change:: 2157 :tags: usecase, sql 2158 :tickets: 4847 2159 2160 Added an explicit error message for the case when objects passed to 2161 :class:`_schema.Table` are not :class:`.SchemaItem` objects, rather than resolving 2162 to an attribute error. 2163 2164 2165 .. change:: 2166 :tags: bug, orm 2167 :tickets: 4890 2168 2169 A warning is emitted for a condition in which the :class:`.Session` may 2170 implicitly swap an object out of the identity map for another one with the 2171 same primary key, detaching the old one, which can be an observed result of 2172 load operations which occur within the :meth:`.SessionEvents.after_flush` 2173 hook. The warning is intended to notify the user that some special 2174 condition has caused this to happen and that the previous object may not be 2175 in the expected state. 2176 2177 .. change:: 2178 :tags: bug, sql 2179 :tickets: 4837 2180 2181 Characters that interfere with "pyformat" or "named" formats in bound 2182 parameters, namely ``%, (, )`` and the space character, as well as a few 2183 other typically undesirable characters, are stripped early for a 2184 :func:`.bindparam` that is using an anonymized name, which is typically 2185 generated automatically from a named column which itself includes these 2186 characters in its name and does not use a ``.key``, so that they do not 2187 interfere either with the SQLAlchemy compiler's use of string formatting or 2188 with the driver-level parsing of the parameter, both of which could be 2189 demonstrated before the fix. The change only applies to anonymized 2190 parameter names that are generated and consumed internally, not end-user 2191 defined names, so the change should have no impact on any existing code. 2192 Applies in particular to the psycopg2 driver which does not otherwise quote 2193 special parameter names, but also strips leading underscores to suit Oracle 2194 (but not yet leading numbers, as some anon parameters are currently 2195 entirely numeric/underscore based); Oracle in any case continues to quote 2196 parameter names that include special characters. 2197 2198.. changelog:: 2199 :version: 1.3.8 2200 :released: August 27, 2019 2201 2202 .. change:: 2203 :tags: bug, orm 2204 :tickets: 4823 2205 2206 Fixed bug where :class:`_orm.Load` objects were not pickleable due to 2207 mapper/relationship state in the internal context dictionary. These 2208 objects are now converted to picklable using similar techniques as that of 2209 other elements within the loader option system that have long been 2210 serializable. 2211 2212 .. change:: 2213 :tags: bug, postgresql 2214 :tickets: 4623 2215 2216 Revised the approach for the just added support for the psycopg2 2217 "execute_values()" feature added in 1.3.7 for :ticket:`4623`. The approach 2218 relied upon a regular expression that would fail to match for a more 2219 complex INSERT statement such as one which had subqueries involved. The 2220 new approach matches exactly the string that was rendered as the VALUES 2221 clause. 2222 2223 .. change:: 2224 :tags: usecase, orm 2225 :tickets: 4285 2226 2227 Added support for the use of an :class:`.Enum` datatype using Python 2228 pep-435 enumeration objects as values for use as a primary key column 2229 mapped by the ORM. As these values are not inherently sortable, as 2230 required by the ORM for primary keys, a new 2231 :attr:`.TypeEngine.sort_key_function` attribute is added to the typing 2232 system which allows any SQL type to implement a sorting for Python objects 2233 of its type which is consulted by the unit of work. The :class:`.Enum` 2234 type then defines this using the database value of a given enumeration. 2235 The sorting scheme can be also be redefined by passing a callable to the 2236 :paramref:`.Enum.sort_key_function` parameter. Pull request courtesy 2237 Nicolas Caniart. 2238 2239 .. change:: 2240 :tags: bug, engine 2241 :tickets: 4807 2242 2243 Fixed an issue whereby if the dialect "initialize" process which occurs on 2244 first connect would encounter an unexpected exception, the initialize 2245 process would fail to complete and then no longer attempt on subsequent 2246 connection attempts, leaving the dialect in an un-initialized, or partially 2247 initialized state, within the scope of parameters that need to be 2248 established based on inspection of a live connection. The "invoke once" 2249 logic in the event system has been reworked to accommodate for this 2250 occurrence using new, private API features that establish an "exec once" 2251 hook that will continue to allow the initializer to fire off on subsequent 2252 connections, until it completes without raising an exception. This does not 2253 impact the behavior of the existing ``once=True`` flag within the event 2254 system. 2255 2256 .. change:: 2257 :tags: bug, sqlite, reflection 2258 :tickets: 4810 2259 2260 Fixed bug where a FOREIGN KEY that was set up to refer to the parent table 2261 by table name only without the column names would not correctly be 2262 reflected as far as setting up the "referred columns", since SQLite's 2263 PRAGMA does not report on these columns if they weren't given explicitly. 2264 For some reason this was hardcoded to assume the name of the local column, 2265 which might work for some cases but is not correct. The new approach 2266 reflects the primary key of the referred table and uses the constraint 2267 columns list as the referred columns list, if the remote column(s) aren't 2268 present in the reflected pragma directly. 2269 2270 2271 .. change:: 2272 :tags: bug, postgresql 2273 :tickets: 4822 2274 2275 Fixed bug where Postgresql operators such as 2276 :meth:`.postgresql.ARRAY.Comparator.contains` and 2277 :meth:`.postgresql.ARRAY.Comparator.contained_by` would fail to function 2278 correctly for non-integer values when used against a 2279 :class:`_postgresql.array` object, due to an erroneous assert statement. 2280 2281 .. change:: 2282 :tags: feature, engine 2283 :tickets: 4815 2284 2285 Added new parameter :paramref:`_sa.create_engine.hide_parameters` which when 2286 set to True will cause SQL parameters to no longer be logged, nor rendered 2287 in the string representation of a :class:`.StatementError` object. 2288 2289 2290 .. change:: 2291 :tags: usecase, postgresql 2292 :tickets: 4824 2293 2294 Added support for reflection of CHECK constraints that include the special 2295 PostgreSQL qualifier "NOT VALID", which can be present for CHECK 2296 constraints that were added to an existing table with the directive that 2297 they not be applied to existing data in the table. The PostgreSQL 2298 dictionary for CHECK constraints as returned by 2299 :meth:`_reflection.Inspector.get_check_constraints` may include an additional entry 2300 ``dialect_options`` which within will contain an entry ``"not_valid": 2301 True`` if this symbol is detected. Pull request courtesy Bill Finn. 2302 2303.. changelog:: 2304 :version: 1.3.7 2305 :released: August 14, 2019 2306 2307 .. change:: 2308 :tags: bug, sql 2309 :tickets: 4778 2310 2311 Fixed issue where :class:`.Index` object which contained a mixture of 2312 functional expressions which were not resolvable to a particular column, 2313 in combination with string-based column names, would fail to initialize 2314 its internal state correctly leading to failures during DDL compilation. 2315 2316 .. change:: 2317 :tags: bug, sqlite 2318 :tickets: 4798 2319 2320 The dialects that support json are supposed to take arguments 2321 ``json_serializer`` and ``json_deserializer`` at the create_engine() level, 2322 however the SQLite dialect calls them ``_json_serializer`` and 2323 ``_json_deserilalizer``. The names have been corrected, the old names are 2324 accepted with a change warning, and these parameters are now documented as 2325 :paramref:`_sa.create_engine.json_serializer` and 2326 :paramref:`_sa.create_engine.json_deserializer`. 2327 2328 2329 .. change:: 2330 :tags: bug, mysql 2331 :tickets: 4804 2332 2333 The MySQL dialects will emit "SET NAMES" at the start of a connection when 2334 charset is given to the MySQL driver, to appease an apparent behavior 2335 observed in MySQL 8.0 that raises a collation error when a UNION includes 2336 string columns unioned against columns of the form CAST(NULL AS CHAR(..)), 2337 which is what SQLAlchemy's polymorphic_union function does. The issue 2338 seems to have affected PyMySQL for at least a year, however has recently 2339 appeared as of mysqlclient 1.4.4 based on changes in how this DBAPI creates 2340 a connection. As the presence of this directive impacts three separate 2341 MySQL charset settings which each have intricate effects based on their 2342 presence, SQLAlchemy will now emit the directive on new connections to 2343 ensure correct behavior. 2344 2345 .. change:: 2346 :tags: usecase, postgresql 2347 :tickets: 4623 2348 2349 Added new dialect flag for the psycopg2 dialect, ``executemany_mode`` which 2350 supersedes the previous experimental ``use_batch_mode`` flag. 2351 ``executemany_mode`` supports both the "execute batch" and "execute values" 2352 functions provided by psycopg2, the latter which is used for compiled 2353 :func:`_expression.insert` constructs. Pull request courtesy Yuval Dinari. 2354 2355 .. seealso:: 2356 2357 :ref:`psycopg2_executemany_mode` 2358 2359 2360 2361 2362 .. change:: 2363 :tags: bug, sql 2364 :tickets: 4787 2365 2366 Fixed bug where :meth:`.TypeEngine.column_expression` method would not be 2367 applied to subsequent SELECT statements inside of a UNION or other 2368 :class:`_selectable.CompoundSelect`, even though the SELECT statements are rendered at 2369 the topmost level of the statement. New logic now differentiates between 2370 rendering the column expression, which is needed for all SELECTs in the 2371 list, vs. gathering the returned data type for the result row, which is 2372 needed only for the first SELECT. 2373 2374 .. change:: 2375 :tags: bug, sqlite 2376 :tickets: 4793 2377 2378 Fixed bug where usage of "PRAGMA table_info" in SQLite dialect meant that 2379 reflection features to detect for table existence, list of table columns, 2380 and list of foreign keys, would default to any table in any attached 2381 database, when no schema name was given and the table did not exist in the 2382 base schema. The fix explicitly runs PRAGMA for the 'main' schema and then 2383 the 'temp' schema if the 'main' returned no rows, to maintain the behavior 2384 of tables + temp tables in the "no schema" namespace, attached tables only 2385 in the "schema" namespace. 2386 2387 2388 .. change:: 2389 :tags: bug, sql 2390 :tickets: 4780 2391 2392 Fixed issue where internal cloning of SELECT constructs could lead to a key 2393 error if the copy of the SELECT changed its state such that its list of 2394 columns changed. This was observed to be occurring in some ORM scenarios 2395 which may be unique to 1.3 and above, so is partially a regression fix. 2396 2397 2398 2399 .. change:: 2400 :tags: bug, orm 2401 :tickets: 4777 2402 2403 Fixed regression caused by new selectinload for many-to-one logic where 2404 a primaryjoin condition not based on real foreign keys would cause 2405 KeyError if a related object did not exist for a given key value on the 2406 parent object. 2407 2408 .. change:: 2409 :tags: usecase, mysql 2410 :tickets: 4783 2411 2412 Added reserved words ARRAY and MEMBER to the MySQL reserved words list, as 2413 MySQL 8.0 has now made these reserved. 2414 2415 2416 .. change:: 2417 :tags: bug, events 2418 :tickets: 4794 2419 2420 Fixed issue in event system where using the ``once=True`` flag with 2421 dynamically generated listener functions would cause event registration of 2422 future events to fail if those listener functions were garbage collected 2423 after they were used, due to an assumption that a listened function is 2424 strongly referenced. The "once" wrapped is now modified to strongly 2425 reference the inner function persistently, and documentation is updated 2426 that using "once" does not imply automatic de-registration of listener 2427 functions. 2428 2429 .. change:: 2430 :tags: bug, mysql 2431 :tickets: 4751 2432 2433 Added another fix for an upstream MySQL 8 issue where a case sensitive 2434 table name is reported incorrectly in foreign key constraint reflection, 2435 this is an extension of the fix first added for :ticket:`4344` which 2436 affects a case sensitive column name. The new issue occurs through MySQL 2437 8.0.17, so the general logic of the 88718 fix remains in place. 2438 2439 .. seealso:: 2440 2441 https://bugs.mysql.com/bug.php?id=96365 - upstream bug 2442 2443 2444 .. change:: 2445 :tags: usecase, mssql 2446 :tickets: 4782 2447 2448 Added new :func:`_mssql.try_cast` construct for SQL Server which emits 2449 "TRY_CAST" syntax. Pull request courtesy Leonel Atencio. 2450 2451 .. change:: 2452 :tags: bug, orm 2453 :tickets: 4803 2454 2455 Fixed bug where using :meth:`_query.Query.first` or a slice expression in 2456 conjunction with a query that has an expression based "offset" applied 2457 would raise TypeError, due to an "or" conditional against "offset" that did 2458 not expect it to be a SQL expression as opposed to an integer or None. 2459 2460 2461.. changelog:: 2462 :version: 1.3.6 2463 :released: July 21, 2019 2464 2465 .. change:: 2466 :tags: bug, engine 2467 :tickets: 4754 2468 2469 Fixed bug where using reflection function such as :meth:`_schema.MetaData.reflect` 2470 with an :class:`_engine.Engine` object that had execution options applied to it 2471 would fail, as the resulting :class:`.OptionEngine` proxy object failed to 2472 include a ``.engine`` attribute used within the reflection routines. 2473 2474 .. change:: 2475 :tags: bug, mysql 2476 :tickets: 4743 2477 2478 Fixed bug where the special logic to render "NULL" for the 2479 :class:`_types.TIMESTAMP` datatype when ``nullable=True`` would not work if the 2480 column's datatype were a :class:`.TypeDecorator` or a :class:`.Variant`. 2481 The logic now ensures that it unwraps down to the original 2482 :class:`_types.TIMESTAMP` so that this special case NULL keyword is correctly 2483 rendered when requested. 2484 2485 .. change:: 2486 :tags: performance, orm 2487 :tickets: 4775 2488 2489 The optimization applied to selectin loading in :ticket:`4340` where a JOIN 2490 is not needed to eagerly load related items is now applied to many-to-one 2491 relationships as well, so that only the related table is queried for a 2492 simple join condition. In this case, the related items are queried 2493 based on the value of a foreign key column on the parent; if these columns 2494 are deferred or otherwise not loaded on any of the parent objects in 2495 the collection, the loader falls back to the JOIN method. 2496 2497 2498 .. change:: 2499 :tags: bug, orm 2500 :tickets: 4773 2501 2502 Fixed regression caused by :ticket:`4365` where a join from an entity to 2503 itself without using aliases no longer raises an informative error message, 2504 instead failing on an assertion. The informative error condition has been 2505 restored. 2506 2507 2508 .. change:: 2509 :tags: orm, feature 2510 :tickets: 4736 2511 2512 Added new loader option method :meth:`_orm.Load.options` which allows loader 2513 options to be constructed hierarchically, so that many sub-options can be 2514 applied to a particular path without needing to call :func:`.defaultload` 2515 many times. Thanks to Alessio Bogon for the idea. 2516 2517 2518 .. change:: 2519 :tags: usecase, postgresql 2520 :tickets: 4771 2521 2522 Added support for reflection of indexes on PostgreSQL partitioned tables, 2523 which was added to PostgreSQL as of version 11. 2524 2525 .. change:: 2526 :tags: bug, mysql 2527 :tickets: 4624 2528 2529 Enhanced MySQL/MariaDB version string parsing to accommodate for exotic 2530 MariaDB version strings where the "MariaDB" word is embedded among other 2531 alphanumeric characters such as "MariaDBV1". This detection is critical in 2532 order to correctly accommodate for API features that have split between MySQL 2533 and MariaDB such as the "transaction_isolation" system variable. 2534 2535 2536 .. change:: 2537 :tags: bug, mssql 2538 :tickets: 4745 2539 2540 Ensured that the queries used to reflect indexes and view definitions will 2541 explicitly CAST string parameters into NVARCHAR, as many SQL Server drivers 2542 frequently treat string values, particularly those with non-ascii 2543 characters or larger string values, as TEXT which often don't compare 2544 correctly against VARCHAR characters in SQL Server's information schema 2545 tables for some reason. These CAST operations already take place for 2546 reflection queries against SQL Server ``information_schema.`` tables but 2547 were missing from three additional queries that are against ``sys.`` 2548 tables. 2549 2550 .. change:: 2551 :tags: bug, orm 2552 :tickets: 4713 2553 2554 Fixed an issue where the :meth:`.orm._ORMJoin.join` method, which is a 2555 not-internally-used ORM-level method that exposes what is normally an 2556 internal process of :meth:`_query.Query.join`, did not propagate the ``full`` and 2557 ``outerjoin`` keyword arguments correctly. Pull request courtesy Denis 2558 Kataev. 2559 2560 .. change:: 2561 :tags: bug, sql 2562 :tickets: 4758 2563 2564 Adjusted the initialization for :class:`.Enum` to minimize how often it 2565 invokes the ``.__members__`` attribute of a given PEP-435 enumeration 2566 object, to suit the case where this attribute is expensive to invoke, as is 2567 the case for some popular third party enumeration libraries. 2568 2569 2570 .. change:: 2571 :tags: bug, orm 2572 :tickets: 4772 2573 2574 Fixed bug where a many-to-one relationship that specified ``uselist=True`` 2575 would fail to update correctly during a primary key change where a related 2576 column needs to change. 2577 2578 2579 .. change:: 2580 :tags: bug, orm 2581 :tickets: 4772 2582 2583 Fixed bug where the detection for many-to-one or one-to-one use with a 2584 "dynamic" relationship, which is an invalid configuration, would fail to 2585 raise if the relationship were configured with ``uselist=True``. The 2586 current fix is that it warns, instead of raises, as this would otherwise be 2587 backwards incompatible, however in a future release it will be a raise. 2588 2589 2590 .. change:: 2591 :tags: bug, orm 2592 :tickets: 4767 2593 2594 Fixed bug where a synonym created against a mapped attribute that does not 2595 exist yet, as is the case when it refers to backref before mappers are 2596 configured, would raise recursion errors when trying to test for attributes 2597 on it which ultimately don't exist (as occurs when the classes are run 2598 through Sphinx autodoc), as the unconfigured state of the synonym would put 2599 it into an attribute not found loop. 2600 2601 2602 .. change:: 2603 :tags: usecase, postgresql 2604 :tickets: 4756 2605 2606 Added support for multidimensional Postgresql array literals via nesting 2607 the :class:`_postgresql.array` object within another one. The 2608 multidimensional array type is detected automatically. 2609 2610 .. seealso:: 2611 2612 :class:`_postgresql.array` 2613 2614 .. change:: 2615 :tags: bug, sql, postgresql 2616 :tickets: 4760 2617 2618 Fixed issue where the :class:`_functions.array_agg` construct in combination with 2619 :meth:`.FunctionElement.filter` would not produce the correct operator 2620 precedence in combination with the array index operator. 2621 2622 2623 .. change:: 2624 :tags: bug, sql 2625 :tickets: 4747 2626 2627 Fixed an unlikely issue where the "corresponding column" routine for unions 2628 and other :class:`_selectable.CompoundSelect` objects could return the wrong column in 2629 some overlapping column situations, thus potentially impacting some ORM 2630 operations when set operations are in use, if the underlying 2631 :func:`_expression.select` constructs were used previously in other similar kinds of 2632 routines, due to a cached value not being cleared. 2633 2634 .. change:: 2635 :tags: usecase, sqlite 2636 :tickets: 4766 2637 2638 Added support for composite (tuple) IN operators with SQLite, by rendering 2639 the VALUES keyword for this backend. As other backends such as DB2 are 2640 known to use the same syntax, the syntax is enabled in the base compiler 2641 using a dialect-level flag ``tuple_in_values``. The change also includes 2642 support for "empty IN tuple" expressions for SQLite when using "in_()" 2643 between a tuple value and an empty set. 2644 2645 2646.. changelog:: 2647 :version: 1.3.5 2648 :released: June 17, 2019 2649 2650 .. change:: 2651 :tags: bug, mysql 2652 :tickets: 4715 2653 2654 Fixed bug where MySQL ON DUPLICATE KEY UPDATE would not accommodate setting 2655 a column to the value NULL. Pull request courtesy Lukáš Banič. 2656 2657 .. change:: 2658 :tags: bug, orm 2659 :tickets: 4723 2660 2661 Fixed a series of related bugs regarding joined table inheritance more than 2662 two levels deep, in conjunction with modification to primary key values, 2663 where those primary key columns are also linked together in a foreign key 2664 relationship as is typical for joined table inheritance. The intermediary 2665 table in a three-level inheritance hierarchy will now get its UPDATE if 2666 only the primary key value has changed and passive_updates=False (e.g. 2667 foreign key constraints not being enforced), whereas before it would be 2668 skipped; similarly, with passive_updates=True (e.g. ON UPDATE CASCADE in 2669 effect), the third-level table will not receive an UPDATE statement as was 2670 the case earlier which would fail since CASCADE already modified it. In a 2671 related issue, a relationship linked to a three-level inheritance hierarchy 2672 on the primary key of an intermediary table of a joined-inheritance 2673 hierarchy will also correctly have its foreign key column updated when the 2674 parent object's primary key is modified, even if that parent object is a 2675 subclass of the linked parent class, whereas before these classes would 2676 not be counted. 2677 2678 .. change:: 2679 :tags: bug, orm 2680 :tickets: 4729 2681 2682 Fixed bug where the :attr:`_orm.Mapper.all_orm_descriptors` accessor would 2683 return an entry for the :class:`_orm.Mapper` itself under the declarative 2684 ``__mapper___`` key, when this is not a descriptor. The ``.is_attribute`` 2685 flag that's present on all :class:`.InspectionAttr` objects is now 2686 consulted, which has also been modified to be ``True`` for an association 2687 proxy, as it was erroneously set to False for this object. 2688 2689 .. change:: 2690 :tags: bug, orm 2691 :tickets: 4704 2692 2693 Fixed regression in :meth:`_query.Query.join` where the ``aliased=True`` flag 2694 would not properly apply clause adaptation to filter criteria, if a 2695 previous join were made to the same entity. This is because the adapters 2696 were placed in the wrong order. The order has been reversed so that the 2697 adapter for the most recent ``aliased=True`` call takes precedence as was 2698 the case in 1.2 and earlier. This broke the "elementtree" examples among 2699 other things. 2700 2701 .. change:: 2702 :tags: bug, orm, py3k 2703 :tickets: 4674 2704 2705 Replaced the Python compatibility routines for ``getfullargspec()`` with a 2706 fully vendored version from Python 3.3. Originally, Python was emitting 2707 deprecation warnings for this function in Python 3.8 alphas. While this 2708 change was reverted, it was observed that Python 3 implementations for 2709 ``getfullargspec()`` are an order of magnitude slower as of the 3.4 series 2710 where it was rewritten against ``Signature``. While Python plans to 2711 improve upon this situation, SQLAlchemy projects for now are using a simple 2712 replacement to avoid any future issues. 2713 2714 .. change:: 2715 :tags: bug, orm 2716 :tickets: 4694 2717 2718 Reworked the attribute mechanics used by :class:`.AliasedClass` to no 2719 longer rely upon calling ``__getattribute__`` on the MRO of the wrapped 2720 class, and to instead resolve the attribute normally on the wrapped class 2721 using getattr(), and then unwrap/adapt that. This allows a greater range 2722 of attribute styles on the mapped class including special ``__getattr__()`` 2723 schemes; but it also makes the code simpler and more resilient in general. 2724 2725 .. change:: 2726 :tags: usecase, postgresql 2727 :tickets: 4717 2728 2729 Added support for column sorting flags when reflecting indexes for 2730 PostgreSQL, including ASC, DESC, NULLSFIRST, NULLSLAST. Also adds this 2731 facility to the reflection system in general which can be applied to other 2732 dialects in future releases. Pull request courtesy Eli Collins. 2733 2734 .. change:: 2735 :tags: bug, postgresql 2736 :tickets: 4701 2737 2738 Fixed bug where PostgreSQL dialect could not correctly reflect an ENUM 2739 datatype that has no members, returning a list with ``None`` for the 2740 ``get_enums()`` call and raising a TypeError when reflecting a column which 2741 has such a datatype. The inspection now returns an empty list. 2742 2743 .. change:: 2744 :tags: bug, sql 2745 :tickets: 4730 2746 2747 Fixed a series of quoting issues which all stemmed from the concept of the 2748 :func:`_expression.literal_column` construct, which when being "proxied" through a 2749 subquery to be referred towards by a label that matches its text, the label 2750 would not have quoting rules applied to it, even if the string in the 2751 :class:`.Label` were set up as a :class:`.quoted_name` construct. Not 2752 applying quoting to the text of the :class:`.Label` is a bug because this 2753 text is strictly a SQL identifier name and not a SQL expression, and the 2754 string should not have quotes embedded into it already unlike the 2755 :func:`_expression.literal_column` which it may be applied towards. The existing 2756 behavior of a non-labeled :func:`_expression.literal_column` being propagated as is on 2757 the outside of a subquery is maintained in order to help with manual 2758 quoting schemes, although it's not clear if valid SQL can be generated for 2759 such a construct in any case. 2760 2761.. changelog:: 2762 :version: 1.3.4 2763 :released: May 27, 2019 2764 2765 .. change:: 2766 :tags: feature, mssql 2767 :tickets: 4657 2768 2769 Added support for SQL Server filtered indexes, via the ``mssql_where`` 2770 parameter which works similarly to that of the ``postgresql_where`` index 2771 function in the PostgreSQL dialect. 2772 2773 .. seealso:: 2774 2775 :ref:`mssql_index_where` 2776 2777 .. change:: 2778 :tags: bug, misc 2779 :tickets: 4625 2780 2781 Removed errant "sqla_nose.py" symbol from MANIFEST.in which created an 2782 undesirable warning message. 2783 2784 .. change:: 2785 :tags: bug, sql 2786 :tickets: 4653 2787 2788 Fixed that the :class:`.GenericFunction` class was inadvertently 2789 registering itself as one of the named functions. Pull request courtesy 2790 Adrien Berchet. 2791 2792 .. change:: 2793 :tags: bug, engine, postgresql 2794 :tickets: 4663 2795 2796 Moved the "rollback" which occurs during dialect initialization so that it 2797 occurs after additional dialect-specific initialize steps, in particular 2798 those of the psycopg2 dialect which would inadvertently leave transactional 2799 state on the first new connection, which could interfere with some 2800 psycopg2-specific APIs which require that no transaction is started. Pull 2801 request courtesy Matthew Wilkes. 2802 2803 2804 .. change:: 2805 :tags: bug, orm 2806 :tickets: 4695 2807 2808 Fixed issue where the :paramref:`.AttributeEvents.active_history` flag 2809 would not be set for an event listener that propagated to a subclass via the 2810 :paramref:`.AttributeEvents.propagate` flag. This bug has been present 2811 for the full span of the :class:`.AttributeEvents` system. 2812 2813 2814 .. change:: 2815 :tags: bug, orm 2816 :tickets: 4690 2817 2818 Fixed regression where new association proxy system was still not proxying 2819 hybrid attributes when they made use of the ``@hybrid_property.expression`` 2820 decorator to return an alternate SQL expression, or when the hybrid 2821 returned an arbitrary :class:`.PropComparator`, at the expression level. 2822 This involved further generalization of the heuristics used to detect the 2823 type of object being proxied at the level of :class:`.QueryableAttribute`, 2824 to better detect if the descriptor ultimately serves mapped classes or 2825 column expressions. 2826 2827 .. change:: 2828 :tags: bug, orm 2829 :tickets: 4686 2830 2831 Applied the mapper "configure mutex" against the declarative class mapping 2832 process, to guard against the race which can occur if mappers are used 2833 while dynamic module import schemes are still in the process of configuring 2834 mappers for related classes. This does not guard against all possible race 2835 conditions, such as if the concurrent import has not yet encountered the 2836 dependent classes as of yet, however it guards against as much as possible 2837 within the SQLAlchemy declarative process. 2838 2839 .. change:: 2840 :tags: bug, mssql 2841 :tickets: 4680 2842 2843 Added error code 20047 to "is_disconnect" for pymssql. Pull request 2844 courtesy Jon Schuff. 2845 2846 2847 .. change:: 2848 :tags: bug, postgresql, orm 2849 :tickets: 4661 2850 2851 Fixed an issue where the "number of rows matched" warning would emit even if 2852 the dialect reported "supports_sane_multi_rowcount=False", as is the case 2853 for psycogp2 with ``use_batch_mode=True`` and others. 2854 2855 2856 .. change:: 2857 :tags: bug, sql 2858 :tickets: 4618 2859 2860 Fixed issue where double negation of a boolean column wouldn't reset 2861 the "NOT" operator. 2862 2863 .. change:: 2864 :tags: mysql, bug 2865 :tickets: 4650 2866 2867 Added support for DROP CHECK constraint which is required by MySQL 8.0.16 2868 to drop a CHECK constraint; MariaDB supports plain DROP CONSTRAINT. The 2869 logic distinguishes between the two syntaxes by checking the server version 2870 string for MariaDB presence. Alembic migrations has already worked 2871 around this issue by implementing its own DROP for MySQL / MariaDB CHECK 2872 constraints, however this change implements it straight in Core so that its 2873 available for general use. Pull request courtesy Hannes Hansen. 2874 2875 .. change:: 2876 :tags: bug, orm 2877 :tickets: 4647 2878 2879 A warning is now emitted for the case where a transient object is being 2880 merged into the session with :meth:`.Session.merge` when that object is 2881 already transient in the :class:`.Session`. This warns for the case where 2882 the object would normally be double-inserted. 2883 2884 2885 .. change:: 2886 :tags: bug, orm 2887 :tickets: 4676 2888 2889 Fixed regression in new relationship m2o comparison logic first introduced 2890 at :ref:`change_4359` when comparing to an attribute that is persisted as 2891 NULL and is in an un-fetched state in the mapped instance. Since the 2892 attribute has no explicit default, it needs to default to NULL when 2893 accessed in a persistent setting. 2894 2895 2896 .. change:: 2897 :tags: bug, sql 2898 :tickets: 4569 2899 2900 The :class:`.GenericFunction` namespace is being migrated so that function 2901 names are looked up in a case-insensitive manner, as SQL functions do not 2902 collide on case sensitive differences nor is this something which would 2903 occur with user-defined functions or stored procedures. Lookups for 2904 functions declared with :class:`.GenericFunction` now use a case 2905 insensitive scheme, however a deprecation case is supported which allows 2906 two or more :class:`.GenericFunction` objects with the same name of 2907 different cases to exist, which will cause case sensitive lookups to occur 2908 for that particular name, while emitting a warning at function registration 2909 time. Thanks to Adrien Berchet for a lot of work on this complicated 2910 feature. 2911 2912 2913.. changelog:: 2914 :version: 1.3.3 2915 :released: April 15, 2019 2916 2917 .. change:: 2918 :tags: bug, postgresql 2919 :tickets: 4601 2920 2921 Fixed regression from release 1.3.2 caused by :ticket:`4562` where a URL 2922 that contained only a query string and no hostname, such as for the 2923 purposes of specifying a service file with connection information, would no 2924 longer be propagated to psycopg2 properly. The change in :ticket:`4562` 2925 has been adjusted to further suit psycopg2's exact requirements, which is 2926 that if there are any connection parameters whatsoever, the "dsn" parameter 2927 is no longer required, so in this case the query string parameters are 2928 passed alone. 2929 2930 .. change:: 2931 :tags: bug, pool 2932 :tickets: 4585 2933 2934 Fixed behavioral regression as a result of deprecating the "use_threadlocal" 2935 flag for :class:`_pool.Pool`, where the :class:`.SingletonThreadPool` no longer 2936 makes use of this option which causes the "rollback on return" logic to take 2937 place when the same :class:`_engine.Engine` is used multiple times in the context 2938 of a transaction to connect or implicitly execute, thereby cancelling the 2939 transaction. While this is not the recommended way to work with engines 2940 and connections, it is nonetheless a confusing behavioral change as when 2941 using :class:`.SingletonThreadPool`, the transaction should stay open 2942 regardless of what else is done with the same engine in the same thread. 2943 The ``use_threadlocal`` flag remains deprecated however the 2944 :class:`.SingletonThreadPool` now implements its own version of the same 2945 logic. 2946 2947 2948 .. change:: 2949 :tags: bug, orm 2950 :tickets: 4584 2951 2952 Fixed 1.3 regression in new "ambiguous FROMs" query logic introduced in 2953 :ref:`change_4365` where a :class:`_query.Query` that explicitly places an entity 2954 in the FROM clause with :meth:`_query.Query.select_from` and also joins to it 2955 using :meth:`_query.Query.join` would later cause an "ambiguous FROM" error if 2956 that entity were used in additional joins, as the entity appears twice in 2957 the "from" list of the :class:`_query.Query`. The fix resolves this ambiguity by 2958 folding the standalone entity into the join that it's already a part of in 2959 the same way that ultimately happens when the SELECT statement is rendered. 2960 2961 .. change:: 2962 :tags: bug, ext 2963 :tickets: 4603 2964 2965 Fixed bug where using ``copy.copy()`` or ``copy.deepcopy()`` on 2966 :class:`.MutableList` would cause the items within the list to be 2967 duplicated, due to an inconsistency in how Python pickle and copy both make 2968 use of ``__getstate__()`` and ``__setstate__()`` regarding lists. In order 2969 to resolve, a ``__reduce_ex__`` method had to be added to 2970 :class:`.MutableList`. In order to maintain backwards compatibility with 2971 existing pickles based on ``__getstate__()``, the ``__setstate__()`` method 2972 remains as well; the test suite asserts that pickles made against the old 2973 version of the class can still be deserialized by the pickle module. 2974 2975 .. change:: 2976 :tags: bug, orm 2977 :tickets: 4606 2978 2979 Adjusted the :meth:`_query.Query.filter_by` method to not call :func:`.and()` 2980 internally against multiple criteria, instead passing it off to 2981 :meth:`_query.Query.filter` as a series of criteria, instead of a single criteria. 2982 This allows :meth:`_query.Query.filter_by` to defer to :meth:`_query.Query.filter`'s 2983 treatment of variable numbers of clauses, including the case where the list 2984 is empty. In this case, the :class:`_query.Query` object will not have a 2985 ``.whereclause``, which allows subsequent "no whereclause" methods like 2986 :meth:`_query.Query.select_from` to behave consistently. 2987 2988 .. change:: 2989 :tags: bug, mssql 2990 :tickets: 4587 2991 2992 Fixed issue in SQL Server dialect where if a bound parameter were present in 2993 an ORDER BY expression that would ultimately not be rendered in the SQL 2994 Server version of the statement, the parameters would still be part of the 2995 execution parameters, leading to DBAPI-level errors. Pull request courtesy 2996 Matt Lewellyn. 2997 2998.. changelog:: 2999 :version: 1.3.2 3000 :released: April 2, 2019 3001 3002 .. change:: 3003 :tags: bug, documentation, sql 3004 :tickets: 4580 3005 3006 Thanks to :ref:`change_3981`, we no longer need to rely on recipes that 3007 subclass dialect-specific types directly, :class:`.TypeDecorator` can now 3008 handle all cases. Additionally, the above change made it slightly less 3009 likely that a direct subclass of a base SQLAlchemy type would work as 3010 expected, which could be misleading. Documentation has been updated to use 3011 :class:`.TypeDecorator` for these examples including the PostgreSQL 3012 "ArrayOfEnum" example datatype and direct support for the "subclass a type 3013 directly" has been removed. 3014 3015 .. change:: 3016 :tags: bug, postgresql 3017 :tickets: 4550 3018 3019 Modified the :paramref:`.Select.with_for_update.of` parameter so that if a 3020 join or other composed selectable is passed, the individual :class:`_schema.Table` 3021 objects will be filtered from it, allowing one to pass a join() object to 3022 the parameter, as occurs normally when using joined table inheritance with 3023 the ORM. Pull request courtesy Raymond Lu. 3024 3025 3026 .. change:: 3027 :tags: feature, postgresql 3028 :tickets: 4562 3029 3030 Added support for parameter-less connection URLs for the psycopg2 dialect, 3031 meaning, the URL can be passed to :func:`_sa.create_engine` as 3032 ``"postgresql+psycopg2://"`` with no additional arguments to indicate an 3033 empty DSN passed to libpq, which indicates to connect to "localhost" with 3034 no username, password, or database given. Pull request courtesy Julian 3035 Mehnle. 3036 3037 .. change:: 3038 :tags: bug, orm, ext 3039 :tickets: 4574, 4573 3040 3041 Restored instance-level support for plain Python descriptors, e.g. 3042 ``@property`` objects, in conjunction with association proxies, in that if 3043 the proxied object is not within ORM scope at all, it gets classified as 3044 "ambiguous" but is proxed directly. For class level access, a basic class 3045 level``__get__()`` now returns the 3046 :class:`.AmbiguousAssociationProxyInstance` directly, rather than raising 3047 its exception, which is the closest approximation to the previous behavior 3048 that returned the :class:`.AssociationProxy` itself that's possible. Also 3049 improved the stringification of these objects to be more descriptive of 3050 current state. 3051 3052 .. change:: 3053 :tags: bug, orm 3054 :tickets: 4537 3055 3056 Fixed bug where use of :func:`.with_polymorphic` or other aliased construct 3057 would not properly adapt when the aliased target were used as the 3058 :meth:`_expression.Select.correlate_except` target of a subquery used inside of a 3059 :func:`.column_property`. This required a fix to the clause adaption 3060 mechanics to properly handle a selectable that shows up in the "correlate 3061 except" list, in a similar manner as which occurs for selectables that show 3062 up in the "correlate" list. This is ultimately a fairly fundamental bug 3063 that has lasted for a long time but it is hard to come across it. 3064 3065 3066 .. change:: 3067 :tags: bug, orm 3068 :tickets: 4566 3069 3070 Fixed regression where a new error message that was supposed to raise when 3071 attempting to link a relationship option to an AliasedClass without using 3072 :meth:`.PropComparator.of_type` would instead raise an ``AttributeError``. 3073 Note that in 1.3, it is no longer valid to create an option path from a 3074 plain mapper relationship to an :class:`.AliasedClass` without using 3075 :meth:`.PropComparator.of_type`. 3076 3077.. changelog:: 3078 :version: 1.3.1 3079 :released: March 9, 2019 3080 3081 .. change:: 3082 :tags: bug, mssql 3083 :tickets: 4525 3084 3085 Fixed regression in SQL Server reflection due to :ticket:`4393` where the 3086 removal of open-ended ``**kw`` from the :class:`.Float` datatype caused 3087 reflection of this type to fail due to a "scale" argument being passed. 3088 3089 .. change:: 3090 :tags: bug, orm, ext 3091 :tickets: 4522 3092 3093 Fixed regression where an association proxy linked to a synonym would no 3094 longer work, both at instance level and at class level. 3095 3096.. changelog:: 3097 :version: 1.3.0 3098 :released: March 4, 2019 3099 3100 .. change:: 3101 :tags: feature, schema 3102 :tickets: 4517 3103 3104 Added new parameters :paramref:`_schema.Table.resolve_fks` and 3105 :paramref:`.MetaData.reflect.resolve_fks` which when set to False will 3106 disable the automatic reflection of related tables encountered in 3107 :class:`_schema.ForeignKey` objects, which can both reduce SQL overhead for omitted 3108 tables as well as avoid tables that can't be reflected for database-specific 3109 reasons. Two :class:`_schema.Table` objects present in the same :class:`_schema.MetaData` 3110 collection can still refer to each other even if the reflection of the two 3111 tables occurred separately. 3112 3113 3114 .. change:: 3115 :tags: feature, orm 3116 :tickets: 4316 3117 3118 The :meth:`_query.Query.get` method can now accept a dictionary of attribute keys 3119 and values as a means of indicating the primary key value to load; is 3120 particularly useful for composite primary keys. Pull request courtesy 3121 Sanjana S. 3122 3123 .. change:: 3124 :tags: feature, orm 3125 :tickets: 3133 3126 3127 A SQL expression can now be assigned to a primary key attribute for an ORM 3128 flush in the same manner as ordinary attributes as described in 3129 :ref:`flush_embedded_sql_expressions` where the expression will be evaluated 3130 and then returned to the ORM using RETURNING, or in the case of pysqlite, 3131 works using the cursor.lastrowid attribute.Requires either a database that 3132 supports RETURNING (e.g. Postgresql, Oracle, SQL Server) or pysqlite. 3133 3134 .. change:: 3135 :tags: bug, sql 3136 :tickets: 4509 3137 3138 The :class:`_expression.Alias` class and related subclasses :class:`_expression.CTE`, 3139 :class:`_expression.Lateral` and :class:`_expression.TableSample` have been reworked so that it is 3140 not possible for a user to construct the objects directly. These constructs 3141 require that the standalone construction function or selectable-bound method 3142 be used to instantiate new objects. 3143 3144 3145 .. change:: 3146 :tags: feature, engine 3147 :tickets: 4500 3148 3149 Revised the formatting for :class:`.StatementError` when stringified. Each 3150 error detail is broken up over multiple newlines instead of spaced out on a 3151 single line. Additionally, the SQL representation now stringifies the SQL 3152 statement rather than using ``repr()``, so that newlines are rendered as is. 3153 Pull request courtesy Nate Clark. 3154 3155 .. seealso:: 3156 3157 :ref:`change_4500` 3158 3159.. changelog:: 3160 :version: 1.3.0b3 3161 :released: March 4, 2019 3162 :released: February 8, 2019 3163 3164 .. change:: 3165 :tags: bug, ext 3166 :tickets: 2642 3167 3168 Implemented a more comprehensive assignment operation (e.g. "bulk replace") 3169 when using association proxy with sets or dictionaries. Fixes the problem 3170 of redundant proxy objects being created to replace the old ones, which 3171 leads to excessive events and SQL and in the case of unique constraints 3172 will cause the flush to fail. 3173 3174 .. seealso:: 3175 3176 :ref:`change_2642` 3177 3178 .. change:: 3179 :tags: bug, postgresql 3180 :tickets: 4473 3181 3182 Fixed issue where using an uppercase name for an index type (e.g. GIST, 3183 BTREE, etc. ) or an EXCLUDE constraint would treat it as an identifier to 3184 be quoted, rather than rendering it as is. The new behavior converts these 3185 types to lowercase and ensures they contain only valid SQL characters. 3186 3187 .. change:: 3188 :tags: bug, orm 3189 :tickets: 4469 3190 3191 Improved the behavior of :func:`_orm.with_polymorphic` in conjunction with 3192 loader options, in particular wildcard operations as well as 3193 :func:`_orm.load_only`. The polymorphic object will be more accurately 3194 targeted so that column-level options on the entity will correctly take 3195 effect.The issue is a continuation of the same kinds of things fixed in 3196 :ticket:`4468`. 3197 3198 3199 .. change:: 3200 :tags: bug, sql 3201 :tickets: 4481 3202 3203 Fully removed the behavior of strings passed directly as components of a 3204 :func:`_expression.select` or :class:`_query.Query` object being coerced to :func:`_expression.text` 3205 constructs automatically; the warning that has been emitted is now an 3206 ArgumentError or in the case of order_by() / group_by() a CompileError. 3207 This has emitted a warning since version 1.0 however its presence continues 3208 to create concerns for the potential of mis-use of this behavior. 3209 3210 Note that public CVEs have been posted for order_by() / group_by() which 3211 are resolved by this commit: CVE-2019-7164 CVE-2019-7548 3212 3213 3214 .. seealso:: 3215 3216 :ref:`change_4481` 3217 3218 .. change:: 3219 :tags: bug, sql 3220 :tickets: 4467 3221 3222 Quoting is applied to :class:`.Function` names, those which are usually but 3223 not necessarily generated from the :attr:`_expression.func` construct, at compile 3224 time if they contain illegal characters, such as spaces or punctuation. The 3225 names are as before treated as case insensitive however, meaning if the 3226 names contain uppercase or mixed case characters, that alone does not 3227 trigger quoting. The case insensitivity is currently maintained for 3228 backwards compatibility. 3229 3230 3231 .. change:: 3232 :tags: bug, sql 3233 :tickets: 4481 3234 3235 Added "SQL phrase validation" to key DDL phrases that are accepted as plain 3236 strings, including :paramref:`_schema.ForeignKeyConstraint.on_delete`, 3237 :paramref:`_schema.ForeignKeyConstraint.on_update`, 3238 :paramref:`.ExcludeConstraint.using`, 3239 :paramref:`_schema.ForeignKeyConstraint.initially`, for areas where a series of SQL 3240 keywords only are expected.Any non-space characters that suggest the phrase 3241 would need to be quoted will raise a :class:`.CompileError`. This change 3242 is related to the series of changes committed as part of :ticket:`4481`. 3243 3244 .. change:: 3245 :tags: bug, orm, declarative 3246 :tickets: 4470 3247 3248 Added some helper exceptions that invoke when a mapping based on 3249 :class:`.AbstractConcreteBase`, :class:`.DeferredReflection`, or 3250 :class:`.AutoMap` is used before the mapping is ready to be used, which 3251 contain descriptive information on the class, rather than falling through 3252 into other failure modes that are less informative. 3253 3254 3255 .. change:: 3256 :tags: change, tests 3257 :tickets: 4460 3258 3259 The test system has removed support for Nose, which is unmaintained for 3260 several years and is producing warnings under Python 3. The test suite is 3261 currently standardized on Pytest. Pull request courtesy Parth Shandilya. 3262 3263.. changelog:: 3264 :version: 1.3.0b2 3265 :released: March 4, 2019 3266 :released: January 25, 2019 3267 3268 .. change:: 3269 :tags: bug, ext 3270 :tickets: 4401 3271 3272 Fixed a regression in 1.3.0b1 caused by :ticket:`3423` where association 3273 proxy objects that access an attribute that's only present on a polymorphic 3274 subclass would raise an ``AttributeError`` even though the actual instance 3275 being accessed was an instance of that subclass. 3276 3277 .. change:: 3278 :tags: bug, orm 3279 :tickets: 1103 3280 3281 Fixed long-standing issue where duplicate collection members would cause a 3282 backref to delete the association between the member and its parent object 3283 when one of the duplicates were removed, as occurs as a side effect of 3284 swapping two objects in one statement. 3285 3286 .. seealso:: 3287 3288 :ref:`change_1103` 3289 3290 .. change:: 3291 :tags: bug, mssql 3292 :tickets: 4442 3293 3294 The ``literal_processor`` for the :class:`.Unicode` and 3295 :class:`.UnicodeText` datatypes now render an ``N`` character in front of 3296 the literal string expression as required by SQL Server for Unicode string 3297 values rendered in SQL expressions. 3298 3299 .. change:: 3300 :tags: feature, orm 3301 :tickets: 4423 3302 3303 Implemented a new feature whereby the :class:`.AliasedClass` construct can 3304 now be used as the target of a :func:`_orm.relationship`. This allows the 3305 concept of "non primary mappers" to no longer be necessary, as the 3306 :class:`.AliasedClass` is much easier to configure and automatically inherits 3307 all the relationships of the mapped class, as well as preserves the 3308 ability for loader options to work normally. 3309 3310 .. seealso:: 3311 3312 :ref:`change_4423` 3313 3314 .. change:: 3315 :tags: bug, orm 3316 :tickets: 4373 3317 3318 Extended the fix first made as part of :ticket:`3287`, where a loader option 3319 made against a subclass using a wildcard would extend itself to include 3320 application of the wildcard to attributes on the super classes as well, to a 3321 "bound" loader option as well, e.g. in an expression like 3322 ``Load(SomeSubClass).load_only('foo')``. Columns that are part of the 3323 parent class of ``SomeSubClass`` will also be excluded in the same way as if 3324 the unbound option ``load_only('foo')`` were used. 3325 3326 .. change:: 3327 :tags: bug, orm 3328 :tickets: 4433 3329 3330 Improved error messages emitted by the ORM in the area of loader option 3331 traversal. This includes early detection of mis-matched loader strategies 3332 along with a clearer explanation why these strategies don't match. 3333 3334 3335 .. change:: 3336 :tags: change, orm 3337 :tickets: 4412 3338 3339 Added a new function :func:`.close_all_sessions` which takes 3340 over the task of the :meth:`.Session.close_all` method, which 3341 is now deprecated as this is confusing as a classmethod. 3342 Pull request courtesy Augustin Trancart. 3343 3344 .. change:: 3345 :tags: feature, orm 3346 :tickets: 4397 3347 3348 Added new :meth:`.MapperEvents.before_mapper_configured` event. This 3349 event complements the other "configure" stage mapper events with a per 3350 mapper event that receives each :class:`_orm.Mapper` right before its 3351 configure step, and additionally may be used to prevent or delay the 3352 configuration of specific :class:`_orm.Mapper` objects using a new 3353 return value :attr:`.orm.interfaces.EXT_SKIP`. See the 3354 documentation link for an example. 3355 3356 .. seealso:: 3357 3358 :meth:`.MapperEvents.before_mapper_configured` 3359 3360 3361 3362 .. change:: 3363 :tags: bug, orm 3364 3365 The "remove" event for collections is now called before the item is removed 3366 in the case of the ``collection.remove()`` method, as is consistent with the 3367 behavior for most other forms of collection item removal (such as 3368 ``__delitem__``, replacement under ``__setitem__``). For ``pop()`` methods, 3369 the remove event still fires after the operation. 3370 3371 .. change:: 3372 :tags: bug, orm declarative 3373 :tickets: 4372 3374 3375 Added a ``__clause_element__()`` method to :class:`.ColumnProperty` which 3376 can allow the usage of a not-fully-declared column or deferred attribute in 3377 a declarative mapped class slightly more friendly when it's used in a 3378 constraint or other column-oriented scenario within the class declaration, 3379 though this still can't work in open-ended expressions; prefer to call the 3380 :attr:`.ColumnProperty.expression` attribute if receiving ``TypeError``. 3381 3382 .. change:: 3383 :tags: bug, orm, engine 3384 :tickets: 4464 3385 3386 Added accessors for execution options to Core and ORM, via 3387 :meth:`_query.Query.get_execution_options`, 3388 :meth:`_engine.Connection.get_execution_options`, 3389 :meth:`_engine.Engine.get_execution_options`, and 3390 :meth:`.Executable.get_execution_options`. PR courtesy Daniel Lister. 3391 3392 .. change:: 3393 :tags: bug, orm 3394 :tickets: 4446 3395 3396 Fixed issue in association proxy due to :ticket:`3423` which caused the use 3397 of custom :class:`.PropComparator` objects with hybrid attributes, such as 3398 the one demonstrated in the ``dictlike-polymorphic`` example to not 3399 function within an association proxy. The strictness that was added in 3400 :ticket:`3423` has been relaxed, and additional logic to accommodate for 3401 an association proxy that links to a custom hybrid have been added. 3402 3403 .. change:: 3404 :tags: change, general 3405 :tickets: 4393 3406 3407 A large change throughout the library has ensured that all objects, 3408 parameters, and behaviors which have been noted as deprecated or legacy now 3409 emit ``DeprecationWarning`` warnings when invoked.As the Python 3 3410 interpreter now defaults to displaying deprecation warnings, as well as that 3411 modern test suites based on tools like tox and pytest tend to display 3412 deprecation warnings, this change should make it easier to note what API 3413 features are obsolete. A major rationale for this change is so that long- 3414 deprecated features that nonetheless still see continue to see real world 3415 use can finally be removed in the near future; the biggest example of this 3416 are the :class:`.SessionExtension` and :class:`.MapperExtension` classes as 3417 well as a handful of other pre-event extension hooks, which have been 3418 deprecated since version 0.7 but still remain in the library. Another is 3419 that several major longstanding behaviors are to be deprecated as well, 3420 including the threadlocal engine strategy, the convert_unicode flag, and non 3421 primary mappers. 3422 3423 .. seealso:: 3424 3425 :ref:`change_4393_general` 3426 3427 3428 .. change:: 3429 :tags: change, engine 3430 :tickets: 4393 3431 3432 The "threadlocal" engine strategy which has been a legacy feature of 3433 SQLAlchemy since around version 0.2 is now deprecated, along with the 3434 :paramref:`_pool.Pool.threadlocal` parameter of :class:`_pool.Pool` which has no 3435 effect in most modern use cases. 3436 3437 .. seealso:: 3438 3439 :ref:`change_4393_threadlocal` 3440 3441 .. change:: 3442 :tags: change, sql 3443 :tickets: 4393 3444 3445 The :paramref:`_sa.create_engine.convert_unicode` and 3446 :paramref:`.String.convert_unicode` parameters have been deprecated. These 3447 parameters were built back when most Python DBAPIs had little to no support 3448 for Python Unicode objects, and SQLAlchemy needed to take on the very 3449 complex task of marshalling data and SQL strings between Unicode and 3450 bytestrings throughout the system in a performant way. Thanks to Python 3, 3451 DBAPIs were compelled to adapt to Unicode-aware APIs and today all DBAPIs 3452 supported by SQLAlchemy support Unicode natively, including on Python 2, 3453 allowing this long-lived and very complicated feature to finally be (mostly) 3454 removed. There are still of course a few Python 2 edge cases where 3455 SQLAlchemy has to deal with Unicode however these are handled automatically; 3456 in modern use, there should be no need for end-user interaction with these 3457 flags. 3458 3459 .. seealso:: 3460 3461 :ref:`change_4393_convertunicode` 3462 3463 .. change:: 3464 :tags: bug, orm 3465 :tickets: 3777 3466 3467 Implemented the ``.get_history()`` method, which also implies availability 3468 of :attr:`.AttributeState.history`, for :func:`.synonym` attributes. 3469 Previously, trying to access attribute history via a synonym would raise an 3470 ``AttributeError``. 3471 3472 .. change:: 3473 :tags: feature, engine 3474 :tickets: 3689 3475 3476 Added public accessor :meth:`.QueuePool.timeout` that returns the configured 3477 timeout for a :class:`.QueuePool` object. Pull request courtesy Irina Delamare. 3478 3479 .. change:: 3480 :tags: feature, sql 3481 :tickets: 4386 3482 3483 Amended the :class:`.AnsiFunction` class, the base of common SQL 3484 functions like ``CURRENT_TIMESTAMP``, to accept positional arguments 3485 like a regular ad-hoc function. This to suit the case that many of 3486 these functions on specific backends accept arguments such as 3487 "fractional seconds" precision and such. If the function is created 3488 with arguments, it renders the parenthesis and the arguments. If 3489 no arguments are present, the compiler generates the non-parenthesized form. 3490 3491.. changelog:: 3492 :version: 1.3.0b1 3493 :released: March 4, 2019 3494 :released: November 16, 2018 3495 3496 .. change:: 3497 :tags: bug, ext 3498 :tickets: 3423 3499 3500 Reworked :class:`.AssociationProxy` to store state that's specific to a 3501 parent class in a separate object, so that a single 3502 :class:`.AssociationProxy` can serve for multiple parent classes, as is 3503 intrinsic to inheritance, without any ambiguity in the state returned by it. 3504 A new method :meth:`.AssociationProxy.for_class` is added to allow 3505 inspection of class-specific state. 3506 3507 .. seealso:: 3508 3509 :ref:`change_3423` 3510 3511 3512 .. change:: 3513 :tags: bug, oracle 3514 :tickets: 4369 3515 3516 Updated the parameters that can be sent to the cx_Oracle DBAPI to both allow 3517 for all current parameters as well as for future parameters not added yet. 3518 In addition, removed unused parameters that were deprecated in version 1.2, 3519 and additionally we are now defaulting "threaded" to False. 3520 3521 .. seealso:: 3522 3523 :ref:`change_4369` 3524 3525 .. change:: 3526 :tags: bug, oracle 3527 :tickets: 4242 3528 3529 The Oracle dialect will no longer use the NCHAR/NCLOB datatypes 3530 represent generic unicode strings or clob fields in conjunction with 3531 :class:`.Unicode` and :class:`.UnicodeText` unless the flag 3532 ``use_nchar_for_unicode=True`` is passed to :func:`_sa.create_engine` - 3533 this includes CREATE TABLE behavior as well as ``setinputsizes()`` for 3534 bound parameters. On the read side, automatic Unicode conversion under 3535 Python 2 has been added to CHAR/VARCHAR/CLOB result rows, to match the 3536 behavior of cx_Oracle under Python 3. In order to mitigate the performance 3537 hit under Python 2, SQLAlchemy's very performant (when C extensions 3538 are built) native Unicode handlers are used under Python 2. 3539 3540 .. seealso:: 3541 3542 :ref:`change_4242` 3543 3544 .. change:: 3545 :tags: bug, orm 3546 :tickets: 3844 3547 3548 Fixed issue regarding passive_deletes="all", where the foreign key 3549 attribute of an object is maintained with its value even after the object 3550 is removed from its parent collection. Previously, the unit of work would 3551 set this to NULL even though passive_deletes indicated it should not be 3552 modified. 3553 3554 .. seealso:: 3555 3556 :ref:`change_3844` 3557 3558 .. change:: 3559 :tags: bug, ext 3560 :tickets: 4268 3561 3562 The long-standing behavior of the association proxy collection maintaining 3563 only a weak reference to the parent object is reverted; the proxy will now 3564 maintain a strong reference to the parent for as long as the proxy 3565 collection itself is also in memory, eliminating the "stale association 3566 proxy" error. This change is being made on an experimental basis to see if 3567 any use cases arise where it causes side effects. 3568 3569 .. seealso:: 3570 3571 :ref:`change_4268` 3572 3573 3574 .. change:: 3575 :tags: bug, sql 3576 :tickets: 4302 3577 3578 Added "like" based operators as "comparison" operators, including 3579 :meth:`.ColumnOperators.startswith` :meth:`.ColumnOperators.endswith` 3580 :meth:`.ColumnOperators.ilike` :meth:`.ColumnOperators.notilike` among many 3581 others, so that all of these operators can be the basis for an ORM 3582 "primaryjoin" condition. 3583 3584 3585 .. change:: 3586 :tags: feature, sqlite 3587 :tickets: 3850 3588 3589 Added support for SQLite's json functionality via the new 3590 SQLite implementation for :class:`_types.JSON`, :class:`_sqlite.JSON`. 3591 The name used for the type is ``JSON``, following an example found at 3592 SQLite's own documentation. Pull request courtesy Ilja Everilä. 3593 3594 .. seealso:: 3595 3596 :ref:`change_3850` 3597 3598 .. change:: 3599 :tags: feature, engine 3600 3601 Added new "lifo" mode to :class:`.QueuePool`, typically enabled by setting 3602 the flag :paramref:`_sa.create_engine.pool_use_lifo` to True. "lifo" mode 3603 means the same connection just checked in will be the first to be checked 3604 out again, allowing excess connections to be cleaned up from the server 3605 side during periods of the pool being only partially utilized. Pull request 3606 courtesy Taem Park. 3607 3608 .. seealso:: 3609 3610 :ref:`change_pr467` 3611 3612 .. change:: 3613 :tags: bug, orm 3614 :tickets: 4359 3615 3616 Improved the behavior of a relationship-bound many-to-one object expression 3617 such that the retrieval of column values on the related object are now 3618 resilient against the object being detached from its parent 3619 :class:`.Session`, even if the attribute has been expired. New features 3620 within the :class:`.InstanceState` are used to memoize the last known value 3621 of a particular column attribute before its expired, so that the expression 3622 can still evaluate when the object is detached and expired at the same 3623 time. Error conditions are also improved using modern attribute state 3624 features to produce more specific messages as needed. 3625 3626 .. seealso:: 3627 3628 :ref:`change_4359` 3629 3630 .. change:: 3631 :tags: feature, mysql 3632 :tickets: 4219 3633 3634 Support added for the "WITH PARSER" syntax of CREATE FULLTEXT INDEX 3635 in MySQL, using the ``mysql_with_parser`` keyword argument. Reflection 3636 is also supported, which accommodates MySQL's special comment format 3637 for reporting on this option as well. Additionally, the "FULLTEXT" and 3638 "SPATIAL" index prefixes are now reflected back into the ``mysql_prefix`` 3639 index option. 3640 3641 3642 3643 .. change:: 3644 :tags: bug, orm, mysql, postgresql 3645 :tickets: 4246 3646 3647 The ORM now doubles the "FOR UPDATE" clause within the subquery that 3648 renders in conjunction with joined eager loading in some cases, as it has 3649 been observed that MySQL does not lock the rows from a subquery. This 3650 means the query renders with two FOR UPDATE clauses; note that on some 3651 backends such as Oracle, FOR UPDATE clauses on subqueries are silently 3652 ignored since they are unnecessary. Additionally, in the case of the "OF" 3653 clause used primarily with PostgreSQL, the FOR UPDATE is rendered only on 3654 the inner subquery when this is used so that the selectable can be targeted 3655 to the table within the SELECT statement. 3656 3657 .. seealso:: 3658 3659 :ref:`change_4246` 3660 3661 .. change:: 3662 :tags: feature, mssql 3663 :tickets: 4158 3664 3665 Added ``fast_executemany=True`` parameter to the SQL Server pyodbc dialect, 3666 which enables use of pyodbc's new performance feature of the same name 3667 when using Microsoft ODBC drivers. 3668 3669 .. seealso:: 3670 3671 :ref:`change_4158` 3672 3673 .. change:: 3674 :tags: bug, ext 3675 :tickets: 4308 3676 3677 Fixed multiple issues regarding de-association of scalar objects with the 3678 association proxy. ``del`` now works, and additionally a new flag 3679 :paramref:`.AssociationProxy.cascade_scalar_deletes` is added, which when 3680 set to True indicates that setting a scalar attribute to ``None`` or 3681 deleting via ``del`` will also set the source association to ``None``. 3682 3683 .. seealso:: 3684 3685 :ref:`change_4308` 3686 3687 3688 .. change:: 3689 :tags: feature, ext 3690 :tickets: 4318 3691 3692 Added new feature :meth:`.BakedQuery.to_query`, which allows for a 3693 clean way of using one :class:`.BakedQuery` as a subquery inside of another 3694 :class:`.BakedQuery` without needing to refer explicitly to a 3695 :class:`.Session`. 3696 3697 3698 .. change:: 3699 :tags: feature, sqlite 3700 :tickets: 4360 3701 3702 Implemented the SQLite ``ON CONFLICT`` clause as understood at the DDL 3703 level, e.g. for primary key, unique, and CHECK constraints as well as 3704 specified on a :class:`_schema.Column` to satisfy inline primary key and NOT NULL. 3705 Pull request courtesy Denis Kataev. 3706 3707 .. seealso:: 3708 3709 :ref:`change_4360` 3710 3711 .. change:: 3712 :tags: feature, postgresql 3713 :tickets: 4237 3714 3715 Added rudimental support for reflection of PostgreSQL 3716 partitioned tables, e.g. that relkind='p' is added to reflection 3717 queries that return table information. 3718 3719 .. seealso:: 3720 3721 :ref:`change_4237` 3722 3723 .. change:: 3724 :tags: feature, ext 3725 :tickets: 4351 3726 3727 The :class:`.AssociationProxy` now has standard column comparison operations 3728 such as :meth:`.ColumnOperators.like` and 3729 :meth:`.ColumnOperators.startswith` available when the target attribute is a 3730 plain column - the EXISTS expression that joins to the target table is 3731 rendered as usual, but the column expression is then use within the WHERE 3732 criteria of the EXISTS. Note that this alters the behavior of the 3733 ``.contains()`` method on the association proxy to make use of 3734 :meth:`.ColumnOperators.contains` when used on a column-based attribute. 3735 3736 .. seealso:: 3737 3738 :ref:`change_4351` 3739 3740 3741 .. change:: 3742 :tags: feature, orm 3743 3744 Added new flag :paramref:`.Session.bulk_save_objects.preserve_order` to the 3745 :meth:`.Session.bulk_save_objects` method, which defaults to True. When set 3746 to False, the given mappings will be grouped into inserts and updates per 3747 each object type, to allow for greater opportunities to batch common 3748 operations together. Pull request courtesy Alessandro Cucci. 3749 3750 .. change:: 3751 :tags: bug, orm 3752 :tickets: 4365 3753 3754 Refactored :meth:`_query.Query.join` to further clarify the individual components 3755 of structuring the join. This refactor adds the ability for 3756 :meth:`_query.Query.join` to determine the most appropriate "left" side of the 3757 join when there is more than one element in the FROM list or the query is 3758 against multiple entities. If more than one FROM/entity matches, an error 3759 is raised that asks for an ON clause to be specified to resolve the 3760 ambiguity. In particular this targets the regression we saw in 3761 :ticket:`4363` but is also of general use. The codepaths within 3762 :meth:`_query.Query.join` are now easier to follow and the error cases are 3763 decided more specifically at an earlier point in the operation. 3764 3765 .. seealso:: 3766 3767 :ref:`change_4365` 3768 3769 .. change:: 3770 :tags: bug, sql 3771 :tickets: 3981 3772 3773 Fixed issue with :meth:`.TypeEngine.bind_expression` and 3774 :meth:`.TypeEngine.column_expression` methods where these methods would not 3775 work if the target type were part of a :class:`.Variant`, or other target 3776 type of a :class:`.TypeDecorator`. Additionally, the SQL compiler now 3777 calls upon the dialect-level implementation when it renders these methods 3778 so that dialects can now provide for SQL-level processing for built-in 3779 types. 3780 3781 .. seealso:: 3782 3783 :ref:`change_3981` 3784 3785 3786 .. change:: 3787 :tags: bug, orm 3788 :tickets: 4304 3789 3790 Fixed long-standing issue in :class:`_query.Query` where a scalar subquery such 3791 as produced by :meth:`_query.Query.exists`, :meth:`_query.Query.as_scalar` and other 3792 derivations from :attr:`_query.Query.statement` would not correctly be adapted 3793 when used in a new :class:`_query.Query` that required entity adaptation, such as 3794 when the query were turned into a union, or a from_self(), etc. The change 3795 removes the "no adaptation" annotation from the :func:`_expression.select` object 3796 produced by the :attr:`_query.Query.statement` accessor. 3797 3798 .. change:: 3799 :tags: bug, orm, declarative 3800 :tickets: 4133 3801 3802 Fixed bug where declarative would not update the state of the 3803 :class:`_orm.Mapper` as far as what attributes were present, when additional 3804 attributes were added or removed after the mapper attribute collections had 3805 already been called and memoized. Additionally, a ``NotImplementedError`` 3806 is now raised if a fully mapped attribute (e.g. column, relationship, etc.) 3807 is deleted from a class that is currently mapped, since the mapper will not 3808 function correctly if the attribute has been removed. 3809 3810 .. change:: 3811 :tags: bug, mssql 3812 :tickets: 4362 3813 3814 Deprecated the use of :class:`.Sequence` with SQL Server in order to affect 3815 the "start" and "increment" of the IDENTITY value, in favor of new 3816 parameters ``mssql_identity_start`` and ``mssql_identity_increment`` which 3817 set these parameters directly. :class:`.Sequence` will be used to generate 3818 real ``CREATE SEQUENCE`` DDL with SQL Server in a future release. 3819 3820 .. seealso:: 3821 3822 :ref:`change_4362` 3823 3824 3825 .. change:: 3826 :tags: feature, mysql 3827 3828 Added support for the parameters in an ON DUPLICATE KEY UPDATE statement on 3829 MySQL to be ordered, since parameter order in a MySQL UPDATE clause is 3830 significant, in a similar manner as that described at 3831 :ref:`updates_order_parameters`. Pull request courtesy Maxim Bublis. 3832 3833 .. seealso:: 3834 3835 :ref:`change_mysql_ondupordering` 3836 3837 .. change:: 3838 :tags: feature, sql 3839 :tickets: 4144 3840 3841 Added :class:`.Sequence` to the "string SQL" system that will render a 3842 meaningful string expression (``"<next sequence value: my_sequence>"``) 3843 when stringifying without a dialect a statement that includes a "sequence 3844 nextvalue" expression, rather than raising a compilation error. 3845 3846 3847 3848 .. change:: 3849 :tags: bug, orm 3850 :tickets: 4232 3851 3852 An informative exception is re-raised when a primary key value is not 3853 sortable in Python during an ORM flush under Python 3, such as an ``Enum`` 3854 that has no ``__lt__()`` method; normally Python 3 raises a ``TypeError`` 3855 in this case. The flush process sorts persistent objects by primary key 3856 in Python so the values must be sortable. 3857 3858 3859 .. change:: 3860 :tags: orm, bug 3861 :tickets: 3604 3862 3863 Removed the collection converter used by the :class:`.MappedCollection` 3864 class. This converter was used only to assert that the incoming dictionary 3865 keys matched that of their corresponding objects, and only during a bulk set 3866 operation. The converter can interfere with a custom validator or 3867 :meth:`.AttributeEvents.bulk_replace` listener that wants to convert 3868 incoming values further. The ``TypeError`` which would be raised by this 3869 converter when an incoming key didn't match the value is removed; incoming 3870 values during a bulk assignment will be keyed to their value-generated key, 3871 and not the key that's explicitly present in the dictionary. 3872 3873 Overall, @converter is superseded by the 3874 :meth:`.AttributeEvents.bulk_replace` event handler added as part of 3875 :ticket:`3896`. 3876 3877 .. change:: 3878 :tags: feature, sql 3879 :tickets: 3989 3880 3881 Added new naming convention tokens ``column_0N_name``, ``column_0_N_name``, 3882 etc., which will render the names / keys / labels for all columns referenced 3883 by a particular constraint in a sequence. In order to accommodate for the 3884 length of such a naming convention, the SQL compiler's auto-truncation 3885 feature now applies itself to constraint names as well, which creates a 3886 shortened, deterministically generated name for the constraint that will 3887 apply to a target backend without going over the character limit of that 3888 backend. 3889 3890 The change also repairs two other issues. One is that the ``column_0_key`` 3891 token wasn't available even though this token was documented, the other was 3892 that the ``referred_column_0_name`` token would inadvertently render the 3893 ``.key`` and not the ``.name`` of the column if these two values were 3894 different. 3895 3896 .. seealso:: 3897 3898 :ref:`change_3989` 3899 3900 3901 .. change:: 3902 :tags: feature, ext 3903 :tickets: 4196 3904 3905 Added support for bulk :meth:`_query.Query.update` and :meth:`_query.Query.delete` 3906 to the :class:`.ShardedQuery` class within the horizontal sharding 3907 extension. This also adds an additional expansion hook to the 3908 bulk update/delete methods :meth:`_query.Query._execute_crud`. 3909 3910 .. seealso:: 3911 3912 :ref:`change_4196` 3913 3914 .. change:: 3915 :tags: feature, sql 3916 :tickets: 4271 3917 3918 Added new logic to the "expanding IN" bound parameter feature whereby if 3919 the given list is empty, a special "empty set" expression that is specific 3920 to different backends is generated, thus allowing IN expressions to be 3921 fully dynamic including empty IN expressions. 3922 3923 .. seealso:: 3924 3925 :ref:`change_4271` 3926 3927 3928 3929 .. change:: 3930 :tags: feature, mysql 3931 3932 The "pre-ping" feature of the connection pool now uses 3933 the ``ping()`` method of the DBAPI connection in the case of 3934 mysqlclient, PyMySQL and mysql-connector-python. Pull request 3935 courtesy Maxim Bublis. 3936 3937 .. seealso:: 3938 3939 :ref:`change_mysql_ping` 3940 3941 .. change:: 3942 :tags: feature, orm 3943 :tickets: 4340 3944 3945 The "selectin" loader strategy now omits the JOIN in the case of a simple 3946 one-to-many load, where it instead relies loads only from the related 3947 table, relying upon the foreign key columns of the related table in order 3948 to match up to primary keys in the parent table. This optimization can be 3949 disabled by setting the :paramref:`_orm.relationship.omit_join` flag to False. 3950 Many thanks to Jayson Reis for the efforts on this. 3951 3952 .. seealso:: 3953 3954 :ref:`change_4340` 3955 3956 .. change:: 3957 :tags: bug, orm 3958 :tickets: 4353 3959 3960 Added new behavior to the lazy load that takes place when the "old" value of 3961 a many-to-one is retrieved, such that exceptions which would be raised due 3962 to either ``lazy="raise"`` or a detached session error are skipped. 3963 3964 .. seealso:: 3965 3966 :ref:`change_4353` 3967 3968 .. change:: 3969 :tags: feature, sql 3970 3971 The Python builtin ``dir()`` is now supported for a SQLAlchemy "properties" 3972 object, such as that of a Core columns collection (e.g. ``.c``), 3973 ``mapper.attrs``, etc. Allows iPython autocompletion to work as well. 3974 Pull request courtesy Uwe Korn. 3975 3976 .. change:: 3977 :tags: feature, orm 3978 :tickets: 4257 3979 3980 Added ``.info`` dictionary to the :class:`.InstanceState` class, the object 3981 that comes from calling :func:`_sa.inspect` on a mapped object. 3982 3983 .. seealso:: 3984 3985 :ref:`change_4257` 3986 3987 .. change:: 3988 :tags: feature, sql 3989 :tickets: 3831 3990 3991 Added new feature :meth:`.FunctionElement.as_comparison` which allows a SQL 3992 function to act as a binary comparison operation that can work within the 3993 ORM. 3994 3995 .. seealso:: 3996 3997 :ref:`change_3831` 3998 3999 .. change:: 4000 :tags: bug, orm 4001 :tickets: 4354 4002 4003 A long-standing oversight in the ORM, the ``__delete__`` method for a many- 4004 to-one relationship was non-functional, e.g. for an operation such as ``del 4005 a.b``. This is now implemented and is equivalent to setting the attribute 4006 to ``None``. 4007 4008 .. seealso:: 4009 4010 :ref:`change_4354` 4011