github sqlalchemy/sqlalchemy rel_1_3_0b1
1.3.0b1

1.3.0b1

Released: November 16, 2018

  • [feature] [sql] Refactored SQLCompiler to expose a
    SQLCompiler.group_by_clause() method similar to the
    SQLCompiler.order_by_clause() and SQLCompiler.limit_clause()
    methods, which can be overridden by dialects to customize how GROUP BY
    renders. Pull request courtesy Samuel Chou.

    This change is also backported to: 1.2.13

  • [bug] [orm] Fixed bug where use of Lateral construct in conjunction with
    Query.join() as well as Query.select_entity_from() would not
    apply clause adaption to the right side of the join. "lateral" introduces
    the use case of the right side of a join being correlatable. Previously,
    adaptation of this clause wasn't considered. Note that in 1.2 only,
    a selectable introduced by Query.subquery() is still not adapted
    due to #4304; the selectable needs to be produced by the
    select() function to be the right side of the "lateral" join.

    This change is also backported to: 1.2.12

    References: #4334

  • [feature] [oracle] Added a new event currently used only by the cx_Oracle dialect,
    DialectEvents.setiputsizes(). The event passes a dictionary of
    BindParameter objects to DBAPI-specific type objects that will be
    passed, after conversion to parameter names, to the cx_Oracle
    cursor.setinputsizes() method. This allows both visibility into the
    setinputsizes process as well as the ability to alter the behavior of what
    datatypes are passed to this method.

    This change is also backported to: 1.2.9

    References: #4290

  • [ext] [feature] Added new attribute Query.lazy_loaded_from which is populated
    with an InstanceState that is using this Query in
    order to lazy load a relationship. The rationale for this is that
    it serves as a hint for the horizontal sharding feature to use, such that
    the identity token of the state can be used as the default identity token
    to use for the query within id_chooser().

    This change is also backported to: 1.2.9

    References: #4243

  • [feature] [postgresql] Added new PG type postgresql.REGCLASS which assists in casting
    table names to OID values. Pull request courtesy Sebastian Bank.

    This change is also backported to: 1.2.7

    References: #4160

  • [feature] [orm] Added new feature Query.only_return_tuples(). Causes the
    Query object to return keyed tuple objects unconditionally even
    if the query is against a single entity. Pull request courtesy Eric
    Atkin.

    This change is also backported to: 1.2.5

  • [bug] [ext] Reworked AssociationProxy to store state that's specific to a
    parent class in a separate object, so that a single
    AssociationProxy can serve for multiple parent classes, as is
    intrinsic to inheritance, without any ambiguity in the state returned by it.
    A new method AssociationProxy.for_class() is added to allow
    inspection of class-specific state.

    References: #3423

  • [bug] [oracle] Updated the parameters that can be sent to the cx_Oracle DBAPI to both allow
    for all current parameters as well as for future parameters not added yet.
    In addition, removed unused parameters that were deprecated in version 1.2,
    and additionally we are now defaulting "threaded" to False.

    References: #4369

  • [bug] [oracle] The Oracle dialect will no longer use the NCHAR/NCLOB datatypes
    represent generic unicode strings or clob fields in conjunction with
    Unicode and UnicodeText unless the flag
    use_nchar_for_unicode=True is passed to create_engine() -
    this includes CREATE TABLE behavior as well as setinputsizes() for
    bound parameters. On the read side, automatic Unicode conversion under
    Python 2 has been added to CHAR/VARCHAR/CLOB result rows, to match the
    behavior of cx_Oracle under Python 3. In order to mitigate the performance
    hit under Python 2, SQLAlchemy's very performant (when C extensions
    are built) native Unicode handlers are used under Python 2.

    References: #4242

  • [bug] [orm] Fixed issue regarding passive_deletes="all", where the foreign key
    attribute of an object is maintained with its value even after the object
    is removed from its parent collection. Previously, the unit of work would
    set this to NULL even though passive_deletes indicated it should not be
    modified.

    References: #3844

  • [bug] [ext] The long-standing behavior of the association proxy collection maintaining
    only a weak reference to the parent object is reverted; the proxy will now
    maintain a strong reference to the parent for as long as the proxy
    collection itself is also in memory, eliminating the "stale association
    proxy" error. This change is being made on an experimental basis to see if
    any use cases arise where it causes side effects.

    References: #4268

  • [bug] [sql] Added "like" based operators as "comparison" operators, including
    ColumnOperators.startswith() ColumnOperators.endswith()
    ColumnOperators.ilike() ColumnOperators.notilike() among many
    others, so that all of these operators can be the basis for an ORM
    "primaryjoin" condition.

    References: #4302

  • [feature] [sqlite] Added support for SQLite's json functionality via the new
    SQLite implementation for types.JSON, sqlite.JSON.
    The name used for the type is JSON, following an example found at
    SQLite's own documentation. Pull request courtesy Ilja Everilä.

    References: #3850

  • [engine] [feature] Added new "lifo" mode to QueuePool, typically enabled by setting
    the flag create_engine.pool_use_lifo to True. "lifo" mode
    means the same connection just checked in will be the first to be checked
    out again, allowing excess connections to be cleaned up from the server
    side during periods of the pool being only partially utilized. Pull request
    courtesy Taem Park.

  • [bug] [orm] Improved the behavior of a relationship-bound many-to-one object expression
    such that the retrieval of column values on the related object are now
    resilient against the object being detached from its parent
    Session, even if the attribute has been expired. New features
    within the InstanceState are used to memoize the last known value
    of a particular column attribute before its expired, so that the expression
    can still evaluate when the object is detached and expired at the same
    time. Error conditions are also improved using modern attribute state
    features to produce more specific messages as needed.

    References: #4359

  • [feature] [mysql] Support added for the "WITH PARSER" syntax of CREATE FULLTEXT INDEX
    in MySQL, using the mysql_with_parser keyword argument. Reflection
    is also supported, which accommodates MySQL's special comment format
    for reporting on this option as well. Additionally, the "FULLTEXT" and
    "SPATIAL" index prefixes are now reflected back into the mysql_prefix
    index option.

    References: #4219

  • [bug] [mysql] [orm] [postgresql] The ORM now doubles the "FOR UPDATE" clause within the subquery that
    renders in conjunction with joined eager loading in some cases, as it has
    been observed that MySQL does not lock the rows from a subquery. This
    means the query renders with two FOR UPDATE clauses; note that on some
    backends such as Oracle, FOR UPDATE clauses on subqueries are silently
    ignored since they are unnecessary. Additionally, in the case of the "OF"
    clause used primarily with PostgreSQL, the FOR UPDATE is rendered only on
    the inner subquery when this is used so that the selectable can be targeted
    to the table within the SELECT statement.

    References: #4246

  • [feature] [mssql] Added fast_executemany=True parameter to the SQL Server pyodbc dialect,
    which enables use of pyodbc's new performance feature of the same name
    when using Microsoft ODBC drivers.

    References: #4158

  • [bug] [ext] Fixed multiple issues regarding de-association of scalar objects with the
    association proxy. del now works, and additionally a new flag
    AssociationProxy.cascade_scalar_deletes is added, which when
    set to True indicates that setting a scalar attribute to None or
    deleting via del will also set the source association to None.

    References: #4308

  • [ext] [feature] Added new feature BakedQuery.to_query(), which allows for a
    clean way of using one BakedQuery as a subquery inside of another
    BakedQuery without needing to refer explicitly to a
    Session.

    References: #4318

  • [feature] [sqlite] Implemented the SQLite ON CONFLICT clause as understood at the DDL
    level, e.g. for primary key, unique, and CHECK constraints as well as
    specified on a Column to satisfy inline primary key and NOT NULL.
    Pull request courtesy Denis Kataev.

    References: #4360

  • [feature] [postgresql] Added rudimental support for reflection of PostgreSQL
    partitioned tables, e.g. that relkind='p' is added to reflection
    queries that return table information.

    References: #4237

  • [ext] [feature] The AssociationProxy now has standard column comparison operations
    such as ColumnOperators.like() and
    ColumnOperators.startswith() available when the target attribute is a
    plain column - the EXISTS expression that joins to the target table is
    rendered as usual, but the column expression is then use within the WHERE
    criteria of the EXISTS. Note that this alters the behavior of the
    .contains() method on the association proxy to make use of
    ColumnOperators.contains() when used on a column-based attribute.

    References: #4351

  • [feature] [orm] Added new flag Session.bulk_save_objects.preserve_order to the
    Session.bulk_save_objects() method, which defaults to True. When set
    to False, the given mappings will be grouped into inserts and updates per
    each object type, to allow for greater opportunities to batch common
    operations together. Pull request courtesy Alessandro Cucci.

  • [bug] [orm] Refactored Query.join() to further clarify the individual components
    of structuring the join. This refactor adds the ability for
    Query.join() to determine the most appropriate "left" side of the
    join when there is more than one element in the FROM list or the query is
    against multiple entities. If more than one FROM/entity matches, an error
    is raised that asks for an ON clause to be specified to resolve the
    ambiguity. In particular this targets the regression we saw in
    #4363 but is also of general use. The codepaths within
    Query.join() are now easier to follow and the error cases are
    decided more specifically at an earlier point in the operation.

    References: #4365

  • [bug] [sql] Fixed issue with TypeEngine.bind_expression() and
    TypeEngine.column_expression() methods where these methods would not
    work if the target type were part of a Variant, or other target
    type of a TypeDecorator. Additionally, the SQL compiler now
    calls upon the dialect-level implementation when it renders these methods
    so that dialects can now provide for SQL-level processing for built-in
    types.

    References: #3981

  • [bug] [orm] Fixed long-standing issue in Query where a scalar subquery such
    as produced by Query.exists(), Query.as_scalar() and other
    derivations from Query.statement would not correctly be adapted
    when used in a new Query that required entity adaptation, such as
    when the query were turned into a union, or a from_self(), etc. The change
    removes the "no adaptation" annotation from the select() object
    produced by the Query.statement accessor.

    References: #4304

  • [bug] [declarative] [orm] Fixed bug where declarative would not update the state of the
    Mapper as far as what attributes were present, when additional
    attributes were added or removed after the mapper attribute collections had
    already been called and memoized. Additionally, a NotImplementedError
    is now raised if a fully mapped attribute (e.g. column, relationship, etc.)
    is deleted from a class that is currently mapped, since the mapper will not
    function correctly if the attribute has been removed.

    References: #4133

  • [bug] [mssql] Deprecated the use of Sequence with SQL Server in order to affect
    the "start" and "increment" of the IDENTITY value, in favor of new
    parameters mssql_identity_start and mssql_identity_increment which
    set these parameters directly. Sequence will be used to generate
    real CREATE SEQUENCE DDL with SQL Server in a future release.

    References: #4362

  • [feature] [mysql] Added support for the parameters in an ON DUPLICATE KEY UPDATE statement on
    MySQL to be ordered, since parameter order in a MySQL UPDATE clause is
    significant, in a similar manner as that described at
    updates_order_parameters. Pull request courtesy Maxim Bublis.

  • [feature] [sql] Added Sequence to the "string SQL" system that will render a
    meaningful string expression ("<next sequence value: my_sequence>")
    when stringifying without a dialect a statement that includes a "sequence
    nextvalue" expression, rather than raising a compilation error.

    References: #4144

  • [bug] [orm] An informative exception is re-raised when a primary key value is not
    sortable in Python during an ORM flush under Python 3, such as an Enum
    that has no __lt__() method; normally Python 3 raises a TypeError
    in this case. The flush process sorts persistent objects by primary key
    in Python so the values must be sortable.

    References: #4232

  • [bug] [orm] Removed the collection converter used by the MappedCollection
    class. This converter was used only to assert that the incoming dictionary
    keys matched that of their corresponding objects, and only during a bulk set
    operation. The converter can interfere with a custom validator or
    AttributeEvents.bulk_replace() listener that wants to convert
    incoming values further. The TypeError which would be raised by this
    converter when an incoming key didn't match the value is removed; incoming
    values during a bulk assignment will be keyed to their value-generated key,
    and not the key that's explicitly present in the dictionary.

    Overall, @converter is superseded by the
    AttributeEvents.bulk_replace() event handler added as part of
    #3896.

    References: #3604

  • [feature] [sql] Added new naming convention tokens column_0N_name, column_0_N_name,
    etc., which will render the names / keys / labels for all columns referenced
    by a particular constraint in a sequence. In order to accommodate for the
    length of such a naming convention, the SQL compiler's auto-truncation
    feature now applies itself to constraint names as well, which creates a
    shortened, deterministically generated name for the constraint that will
    apply to a target backend without going over the character limit of that
    backend.

    The change also repairs two other issues. One is that the column_0_key
    token wasn't available even though this token was documented, the other was
    that the referred_column_0_name token would inadvertently render the
    .key and not the .name of the column if these two values were
    different.

    References: #3989

  • [ext] [feature] Added support for bulk Query.update() and Query.delete()
    to the ShardedQuery class within the horizontal sharding
    extension. This also adds an additional expansion hook to the
    bulk update/delete methods Query._execute_crud().

    References: #4196

  • [feature] [sql] Added new logic to the "expanding IN" bound parameter feature whereby if
    the given list is empty, a special "empty set" expression that is specific
    to different backends is generated, thus allowing IN expressions to be
    fully dynamic including empty IN expressions.

    References: #4271

  • [feature] [mysql] The "pre-ping" feature of the connection pool now uses
    the ping() method of the DBAPI connection in the case of
    mysqlclient, PyMySQL and mysql-connector-python. Pull request
    courtesy Maxim Bublis.

  • [feature] [orm] The "selectin" loader strategy now omits the JOIN in the case of a simple
    one-to-many load, where it instead relies loads only from the related
    table, relying upon the foreign key columns of the related table in order
    to match up to primary keys in the parent table. This optimization can be
    disabled by setting the relationship.omit_join flag to False.
    Many thanks to Jayson Reis for the efforts on this.

    References: #4340

  • [bug] [orm] Added new behavior to the lazy load that takes place when the "old" value of
    a many-to-one is retrieved, such that exceptions which would be raised due
    to either lazy="raise" or a detached session error are skipped.

    References: #4353

  • [feature] [sql] The Python builtin dir() is now supported for a SQLAlchemy "properties"
    object, such as that of a Core columns collection (e.g. .c),
    mapper.attrs, etc. Allows iPython autocompletion to work as well.
    Pull request courtesy Uwe Korn.

  • [feature] [orm] Added .info dictionary to the InstanceState class, the object
    that comes from calling inspect() on a mapped object.

    References: #4257

  • [feature] [sql] Added new feature FunctionElement.as_comparison() which allows a SQL
    function to act as a binary comparison operation that can work within the
    ORM.

    References: #3831

  • [bug] [orm] A long-standing oversight in the ORM, the __delete__ method for a many-
    to-one relationship was non-functional, e.g. for an operation such as del a.b. This is now implemented and is equivalent to setting the attribute
    to None.

    References: #4354

latest releases: rel_1_3_20, rel_1_3_19, rel_1_3_18...
pre-release13 months ago