Commit Graph

15176 Commits

Author SHA1 Message Date
Mike Bayer dabebdefea update quickstart for 2.0
this is just so we can point people to something
while I get around to doing the rest of the docs

Change-Id: Ie818024a80ad30b76d7f7d6dc179939c246084c6
2022-06-12 12:32:55 -04:00
mike bayer b163099ada Merge "honor enum length in all cases" into main 2022-06-10 18:19:06 +00:00
mike bayer 6bbc1ef1e9 Merge "resolve large ints to BigInteger" into main 2022-06-10 18:18:35 +00:00
Mike Bayer bc0367c670 resolve large ints to BigInteger
The in-place type detection for Python integers, as occurs with an
expression such as ``literal(25)``, will now apply value-based adaption as
well to accommodate Python large integers, where the datatype determined
will be :class:`.BigInteger` rather than :class:`.Integer`. This
accommodates for dialects such as that of asyncpg which both sends implicit
typing information to the driver as well as is sensitive to numeric scale.

Fixes: #7909
Change-Id: I1cd3ec2676c9bb03ffedb600695252bd0037ba02
2022-06-10 13:23:20 -04:00
Mike Bayer 4274981156 honor enum length in all cases
The :paramref:`.Enum.length` parameter, which sets the length of the
``VARCHAR`` column for non-native enumeration types, is now used
unconditionally when emitting DDL for the ``VARCHAR`` datatype, including
when the :paramref:`.Enum.native_enum` parameter is set to ``True`` for
target backends that continue to use ``VARCHAR``. Previously the parameter
would be erroneously ignored in this case. The warning previously emitted
for this case is now removed.

Fixes: #7791
Change-Id: I91764546b56e9416479949be8a118cdc91ac5ed9
2022-06-10 13:21:26 -04:00
Mike Bayer f003360baa remove "undefer_pks" as a strategy option
The behavior of :func:`_orm.defer` regarding primary key and "polymorphic
discriminator" columns is revised such that these columns are no longer
deferrable, either explicitly or when using a wildcard such as
``defer('*')``. Previously, a wildcard deferral would not load
PK/polymorphic columns which led to errors in all cases, as the ORM relies
upon these columns to produce object identities. The behavior of explicit
deferral of primary key columns is unchanged as these deferrals already
were implicitly ignored.

Fixes: #7495
Change-Id: I76d9252426e86619bc142667670a3df75b4f5f6a
2022-06-10 12:27:03 -04:00
mike bayer b171f5d2e4 Merge "update cx_Oracle / oracledb LOB handling" into main 2022-06-10 15:11:44 +00:00
Mike Bayer 07678e0e34 update cx_Oracle / oracledb LOB handling
Adjustments made to the BLOB / CLOB / NCLOB datatypes in the cx_Oracle and
oracledb dialects, to improve performance based on recommendations from
Oracle developers.

References: https://github.com/oracle/python-cx_Oracle/issues/596
Fixes: #7494
Change-Id: I0d8cc3579140aa65cacf5b7d3373f7e1929a8f85
2022-06-10 10:48:17 -04:00
mike bayer 2e97c6a2e4 Merge "restore parameter escaping for public methods" into main 2022-06-09 16:03:53 +00:00
mike bayer c9642520c4 Merge "handle non-mapped mixins for with_loader_criteria reduce" into main 2022-06-09 16:02:21 +00:00
mike bayer 1eec436d68 Merge "dont transfer __weakref__ to regenerated class" into main 2022-06-09 16:01:26 +00:00
Mike Bayer e084b49360 Revert "document thread safety workaround for lambda statements"
This reverts commit bf40bade26.
2022-06-09 10:56:59 -04:00
Mike Bayer ab8b4f25ee restore parameter escaping for public methods
Adjusted the fix made for 🎫`8056` which adjusted the escaping of
bound parameter names with special characters such that the escaped names
were translated after the SQL compilation step, which broke a published
recipe on the FAQ illustrating how to merge parameter names into the string
output of a compiled SQL string. The change restores the escaped names that
come from ``compiled.params`` and adds a conditional parameter to
:meth:`.SQLCompiler.construct_params` named ``escape_names`` that defaults
to ``True``, restoring the old behavior by default.

Fixes: #8113
Change-Id: I9cbedb1080bc06d51f287fd2cbf26aaab1c74653
2022-06-09 10:14:13 -04:00
Mike Bayer cc7cc3c9ec dont transfer __weakref__ to regenerated class
Repaired a deprecation warning class decorator that was preventing key
objects such as :class:`_engine.Connection` from having a proper
``__weakref__`` attribute, causing operations like Python standard library
``inspect.getmembers()`` to fail.

Fixes: #8115
Change-Id: Ifd0bc2325fb9dc9e1431998c308b7fc081968373
2022-06-09 09:54:04 -04:00
Mike Bayer 6f93f88b5e handle non-mapped mixins for with_loader_criteria reduce
special handling is needed for a with_loader_criteria()
against a non-mapped mixin class.  added that to test
coverage

Fixes: #8109
Change-Id: Ia599361c8faab008e92095eb4607d02820f590d5
2022-06-09 08:55:14 -04:00
mike bayer e1935b1711 Merge "fix race conditions in lambda statements" into main 2022-06-09 12:37:17 +00:00
mike bayer d93f952b46 Merge "suppport with_loader_criteria pickling w/ fixed callable" into main 2022-06-09 00:54:16 +00:00
Mike Bayer 409a2173eb add tests to confirm no issue w/ pg json keys
Change-Id: Ie91e5efb217c309bc40c3933f538bcf29c1fd87b
References: #8112
2022-06-08 19:04:23 -04:00
Mike Bayer bf40bade26 document thread safety workaround for lambda statements
Change-Id: Idb7840ff64487ef985087a28bb6e96088e6a392e
References: #8098
2022-06-08 16:04:34 -04:00
mike bayer 73f867d996 Merge "graceful degrade for FKs not reflectable" into main 2022-06-08 17:13:28 +00:00
Mike Bayer 293b0e3dd8 suppport with_loader_criteria pickling w/ fixed callable
Fixed issue where a :func:`_orm.with_loader_criteria` option could not be
pickled, as is necessary when it is carried along for propagation to lazy
loaders in conjunction with a caching scheme. Currently, the only form that
is supported as picklable is to pass the "where criteria" as a fixed
module-level callable function that produces a SQL expression. An ad-hoc
"lambda" can't be pickled, and a SQL expression object is usually not fully
picklable directly.

Fixes: #8109
Change-Id: I49fe69088b0c7e58a0f22c67d2ea4e33752a5a73
2022-06-08 13:07:06 -04:00
Mike Bayer 258d07e478 add note re: pickling for loader criteria
Change-Id: I75992af71ba08799a03995178a6e4612c9a7428a
References: #8108
2022-06-08 11:54:46 -04:00
Mike Bayer 117878f787 fix race conditions in lambda statements
Fixed multiple observed race conditions related to :func:`.lambda_stmt`,
including an initial "dogpile" issue when a new Python code object is
initially analyzed among multiple simultaneous threads which created both a
performance issue as well as some internal corruption of state.
Additionally repaired observed race condition which could occur when
"cloning" an expression construct that is also in the process of being
compiled or otherwise accessed in a different thread due to memoized
attributes altering the ``__dict__`` while iterated, for Python versions
prior to 3.10; in particular the lambda SQL construct is sensitive to this
as it holds onto a single statement object persistently. The iteration has
been refined to use ``dict.copy()`` with or without an additional iteration
instead.

Fixes: #8098
Change-Id: I4e0b627bfa187f1780dc68ec81b94db1c78f846a
2022-06-08 09:45:10 -04:00
mike bayer 1961e13214 Merge "Add support for the new oracle driver `oracledb`." into main 2022-06-07 18:46:36 +00:00
mike bayer c0736e0b2a Merge "migrate labels to new tutorial" into main 2022-06-07 17:02:20 +00:00
Federico Caselli fcbdae075b Add support for the new oracle driver `oracledb`.
Fixes: #8054
Change-Id: Idd7c1bbb7ca39499f53bdf59a63a6a9d65f144a5
2022-06-07 12:59:57 -04:00
Mike Bayer 93bc7ed534 graceful degrade for FKs not reflectable
Fixed bugs involving the :paramref:`.Table.include_columns` and the
:paramref:`.Table.resolve_fks` parameters on :class:`.Table`; these
little-used parameters were apparently not working for columns that refer
to foreign key constraints.

In the first case, not-included columns that refer to foreign keys would
still attempt to create a :class:`.ForeignKey` object, producing errors
when attempting to resolve the columns for the foreign key constraint
within reflection; foreign key constraints that refer to skipped columns
are now omitted from the table reflection process in the same way as
occurs for :class:`.Index` and :class:`.UniqueConstraint` objects with the
same conditions. No warning is produced however, as we likely want to
remove the include_columns warnings for all constraints in 2.0.

In the latter case, the production of table aliases or subqueries would
fail on an FK related table not found despite the presence of
``resolve_fks=False``; the logic has been repaired so that if a related
table is not found, the :class:`.ForeignKey` object is still proxied to the
aliased table or subquery (these :class:`.ForeignKey` objects are normally
used in the production of join conditions), but it is sent with a flag that
it's not resolvable. The aliased table / subquery will then work normally,
with the exception that it cannot be used to generate a join condition
automatically, as the foreign key information is missing. This was already
the behavior for such foreign key constraints produced using non-reflection
methods, such as joining :class:`.Table` objects from different
:class:`.MetaData` collections.

Fixes: #8100
Fixes: #8101

Change-Id: Ifa37a91bd1f1785fca85ef163eec031660d9ea4d
2022-06-07 12:34:47 -04:00
Mike Bayer 1c99edf1b9 migrate labels to new tutorial
other org changes and some sections from old tutorial
ported to new tutorial.

Change-Id: Ic0fba60ec82fff481890887beef9ed0fa271875a
2022-06-07 12:25:19 -04:00
Mike Bayer 938c5d1033 run test_update_rowcount_return_defaults only w/ returning
sane_rowcount_w_returning asserts failure, which will only
occur here if the DBAPI actually uses RETURNING.

as SQLite conditionally supports RETURNING which breaks
rowcount support only if present, limit this test to that
case.

Additionally, newer pysqlites will likely fix the issue so
we will probably want to put a sqlite3_version check as well
once that fix is released.

Change-Id: I065aa181eb48363c1024550ae3622486ae0b4a6e
2022-06-06 10:58:59 -04:00
mike bayer 6e538cf64a Merge "Generalize RETURNING and suppor for MariaDB / SQLite" into main 2022-06-05 20:40:41 +00:00
Justin Crown 1508aed472 Docs Update - Add **kwargs to CaseInsensitiveComparator docs (#8063)
* Add **kwargs to CaseInsensitiveComparator docs

* add kwargs to other operate examples

Change-Id: I70a1e68bca27c2355ad3b7c5bbc538027f112bd9

* missed one entry

Change-Id: Ieb4a18ab6d96e588e9ec7672cfa65fe2fd8301e5

Co-authored-by: Federico Caselli <cfederico87@gmail.com>
2022-06-04 22:10:38 +02:00
mike bayer cdafd5bb86 Merge "Fixed orm not applying fetch" into main 2022-06-04 18:21:02 +00:00
Federico Caselli 526e9bb6ae Fixed orm not applying fetch
Fixed an issue where :meth:`_sql.GenerativeSelect.fetch` would be
ignored when executing a statement using the ORM.

Fixes: #8091
Change-Id: I6790c7272a71278e90de2529c8bc8ae89e54e288
2022-06-04 12:02:49 -04:00
cui fliter 8131ef51ef fix some typos (#8093)
Signed-off-by: cuishuang <imcusg@gmail.com>
2022-06-04 12:16:27 +02:00
clach04 7f20d50693 Link to dialect for Actian Avalanche, Vector, Actian X, and Ingres (#8039) 2022-06-04 12:15:17 +02:00
Galen Rice 424e9e6212 docs: spelling error (#8088)
Leave off the last S for savings!
2022-06-04 12:07:43 +02:00
Mike Bayer 47eff8b9e3 some typing fixes
* ClassVar for decl fields, add __tablename__
* dataclasses require annotations for all fields.  For us,
  if no annotation, then skip that field as part of what is
  considered to be a "dataclass", as this matches the behavior
  of pyright right now.   We could alternatively raise on this
  use, which is what dataclasses does.   we should ask the pep
  people
* plain field that's just "str", "int", etc., with no value.
  Disallow it unless __allow_unmapped__ is set.   If field
  has dataclasses.field, Column, None, a value etc, it goes through,
  and when using dataclasses mixin all such fields are considered
  for the dataclass setup just like a dataclass.  Hopefully this
  does not have major backwards compat issues.  __allow_unmapped__
  can be set on the base class, mixins, etc., it's liberal for
  now in case people have this problem.
* accommodate for ClassVar, these are not considered at all for
  mapping.

Change-Id: Id743aa0456bade9a5d5832796caeecc3dc4accb7
2022-06-03 13:29:57 -04:00
Mike Bayer ad86d32f7f emphasize expire_on_commit in detached error docs
issues like #8082 suggest users are still not
fully aware of the need to set this parameter
when dealing with detached objects.

Change-Id: I6f389fdbe18b9c977bfb8188fc4732dbd56884d9
2022-06-02 14:52:27 -04:00
Daniel Black 466ed5b53a Generalize RETURNING and suppor for MariaDB / SQLite
As almost every dialect supports RETURNING now, RETURNING
is also made more of a default assumption.

* the default compiler generates a RETURNING clause now
  when specified; CompileError is no longer raised.
* The dialect-level implicit_returning parameter now has
  no effect.   It's not fully clear if there are real world
  cases relying on the dialect-level parameter, so we will see
  once 2.0 is released.   ORM-level RETURNING can be disabled
  at the table level, and perhaps "implicit returning" should
  become an ORM-level option at some point as that's where
  it applies.
* Altered ORM update() / delete() to respect table-level
  implicit returning for fetch.
* Since MariaDB doesnt support UPDATE returning, "full_returning"
  is now split into insert_returning, update_returning, delete_returning
* Crazy new thing.  Dialects that have *both* cursor.lastrowid
  *and* returning.   so now we can pick between them for SQLite
  and mariadb.  so, we are trying to keep it on .lastrowid for
  simple inserts with an autoincrement column, this helps with
  some edge case test scenarios and i bet .lastrowid is faster
  anyway.  any return_defaults() / multiparams etc then we
  use returning
* SQLite decided they dont want to return rows that match in
  ON CONFLICT.  this is flat out wrong, but for now we need to
  work with it.

Fixes: #6195
Fixes: #7011
Closes: #7047
Pull-request: https://github.com/sqlalchemy/sqlalchemy/pull/7047
Pull-request-sha: d25d5ea3ab

Co-authored-by: Mike Bayer <mike_mp@zzzcomputing.com>
Change-Id: I9908ce0ff7bdc50bd5b27722081767c31c19a950
2022-06-02 12:51:20 -04:00
mike bayer 6e8bc369d2 Merge "propagate proxy_key from WrapsColumnExpression" into main 2022-06-01 17:27:13 +00:00
mike bayer 7b6fb299bb Merge "add backend agnostic UUID datatype" into main 2022-06-01 16:13:36 +00:00
Mike Bayer 14250f2668 propagate proxy_key from WrapsColumnExpression
this allows cast() of a label() to propagate the
proxy key outwards in the same way that it apparently
works at the SQL level.

This is stuffing even more rules into naming so basically
seeing how far we can go without other cases starting
to fail.

Fixes: #8084
Change-Id: I20bd97dae798fee6492334c06934e807d0f269ef
2022-06-01 12:11:19 -04:00
Mike Bayer 349a7c5e0e add backend agnostic UUID datatype
Added new backend-agnostic :class:`_types.Uuid` datatype generalized from
the PostgreSQL dialects to now be a core type, as well as migrated
:class:`_types.UUID` from the PostgreSQL dialect. Thanks to Trevor Gross
for the help on this.

also includes:

* corrects some missing behaviors in the suite literal fixtures
  test where row round trips weren't being correctly asserted.
* fixes some of the ISO literal date rendering added in
  952383f9ee for #5052 to truncate datetime strings for date/time
  datatypes in the same way that drivers typically do for bound
  parameters; this was not working fully and wasn't caught by the
  broken test fixture

Fixes: #7212
Change-Id: I981ac6d34d278c18281c144430a528764c241b04
2022-06-01 11:40:56 -04:00
mike bayer 79dbe94bb4 Merge "Support handle_error for pre_ping" into main 2022-06-01 13:58:17 +00:00
Mike Bayer 01ffcf387f cherry-pick changelog update for 1.4.38 2022-05-31 17:28:09 -04:00
Mike Bayer cfee6a2537 cherry-pick changelog from 1.4.37 2022-05-31 17:28:08 -04:00
Mike Bayer 1e8e4ace63 changelog fixes
Change-Id: Id3fc3019f8eb799aa5adf6ca28e0aeedc0da31dd
2022-05-31 17:21:39 -04:00
mike bayer f192da8d70 Merge "establish sessionmaker and async_sessionmaker as generic" into main 2022-05-31 20:56:53 +00:00
mike bayer 6eeee37190 Merge "Handle dead-connection errors for users of python-oracledb" into main 2022-05-31 20:42:21 +00:00
mike bayer f1b8f74a18 Merge "raise informative error when selectable can't be extended" into main 2022-05-31 19:47:49 +00:00