]> git.ipfire.org Git - thirdparty/sqlalchemy/sqlalchemy.git/log
thirdparty/sqlalchemy/sqlalchemy.git
2 years agoMerge "Support kw_only and match_args in dataclass mapping" into main
mike bayer [Fri, 5 Aug 2022 14:53:22 +0000 (14:53 +0000)] 
Merge "Support kw_only and match_args in dataclass mapping" into main

2 years agoMerge "deprecate Query.instances()" into main
mike bayer [Thu, 4 Aug 2022 20:30:19 +0000 (20:30 +0000)] 
Merge "deprecate Query.instances()" into main

2 years agoSupport kw_only and match_args in dataclass mapping
Federico Caselli [Wed, 3 Aug 2022 21:50:19 +0000 (23:50 +0200)] 
Support kw_only and match_args in dataclass mapping

Fixes: #8346
Change-Id: I964629e3bd25221bf6df6ab31c59b3ce1983cd9a

2 years agoMerge "Fix 'No transaction found' error on Synapse." into main
mike bayer [Thu, 4 Aug 2022 13:37:38 +0000 (13:37 +0000)] 
Merge "Fix 'No transaction found' error on Synapse." into main

2 years agodeprecate Query.instances()
Mike Bayer [Wed, 3 Aug 2022 22:59:05 +0000 (18:59 -0400)] 
deprecate Query.instances()

this method no longer does the thing that it was originally
intended to do, which is to get ORM results from arbitrary
result sets.   Modern patterns should supersede the
use of this construct.

Change-Id: Ia1656c84d7c323f55e3a9594b950a40763d63d90
References: #8347

2 years agoMerge "ensure RETURNING renders in stringify w/ no server version" into main
mike bayer [Thu, 4 Aug 2022 13:32:17 +0000 (13:32 +0000)] 
Merge "ensure RETURNING renders in stringify w/ no server version" into main

2 years agoupdate quoted_name doc
Mike Bayer [Thu, 4 Aug 2022 13:26:47 +0000 (09:26 -0400)] 
update quoted_name doc

Fixes: #8339
Change-Id: If78bc9babfdc6a4dde4e65d72858ac7a402cbb4d

2 years agomore mysql 8.0.30 fixes
Mike Bayer [Thu, 4 Aug 2022 00:47:50 +0000 (20:47 -0400)] 
more mysql 8.0.30 fixes

Change-Id: I9df3506f364f4721404cf2022486bc31fd5c2ce6

2 years agoensure RETURNING renders in stringify w/ no server version
Mike Bayer [Wed, 3 Aug 2022 18:08:32 +0000 (14:08 -0400)] 
ensure RETURNING renders in stringify w/ no server version

just in my own testing, if I say insert().return_defaults()
and stringify, I should see it, so make sure all the dialects
default to "insert_returning" etc. , with downgrade on
server version check.

Change-Id: Id64e78fcb03c48b5dcb0feb21cb9cc495edd15e9

2 years agoadjust mysql utf test
Mike Bayer [Wed, 3 Aug 2022 22:09:39 +0000 (18:09 -0400)] 
adjust mysql utf test

we've updated mysql on jenkins and this test seems to need
a small adjustment

Change-Id: I21508f667700cf8f3200f15af501a66a85f48779

2 years agoglossary/association relationship: role->role_name (#8331)
Fabian Preiß [Wed, 3 Aug 2022 20:25:19 +0000 (22:25 +0200)] 
glossary/association relationship: role->role_name (#8331)

2 years agosend in the dragons on async_scoped_session
Mike Bayer [Wed, 3 Aug 2022 16:08:54 +0000 (12:08 -0400)] 
send in the dragons on async_scoped_session

make it clear that async_scoped_session.remove() must
be called, else memory will build up.    Generally
discourage the whole pattern as well, as this is a
"framework" pattern and we don't really want to be supporting
frameworks.    Also indicate that scopefunc must be idempotent
and lightweight.

Fixes: #8340
Change-Id: Ibc3d21124ae73c3b25ee51966504bbb1975c36b2

2 years agoreword yield_per a bit more
Mike Bayer [Tue, 2 Aug 2022 18:51:49 +0000 (14:51 -0400)] 
reword yield_per a bit more

I'm still not satisified with this section as it is still
too wordy and dense, but at least let's put a better description
of what yield_per actually is and why one might use it at the top.

Change-Id: I10f4d862d9c499044f5718fca0d27ac106289717

2 years agoFix 'No transaction found' error on Synapse.
Gord Thompson [Fri, 22 Jul 2022 12:31:24 +0000 (08:31 -0400)] 
Fix 'No transaction found' error on Synapse.

Fixed issue where the SQL Server dialect's query for the current isolation
level would fail on Azure Synapse Analytics, due to the way in which this
database handles transaction rollbacks after an error has occurred. The
initial query has been modified to no longer rely upon catching an error
when attempting to detect the appropriate system view. Additionally, to
better support this database's very specific "rollback" behavior,
implemented new parameter ``ignore_no_transaction_on_rollback`` indicating
that a rollback should ignore Azure Synapse error 'No corresponding
transaction found. (111214)', which is raised if no transaction is present
in conflict with the Python DBAPI.

Fixes: #8231
Closes: #8233
Pull-request: https://github.com/sqlalchemy/sqlalchemy/pull/8233
Pull-request-sha: c48bd44a9f53d00e5e94f1b8bf996711b6419562

Change-Id: I6407a03148f45cc9eba8fe1d31d4f59ebf9c7ef7

2 years agoMerge "SQLite reflection ignores schema internal names" into main
mike bayer [Tue, 2 Aug 2022 15:48:49 +0000 (15:48 +0000)] 
Merge "SQLite reflection ignores schema internal names" into main

2 years agoMerge "implement tuple-slices from .c collections" into main
mike bayer [Tue, 2 Aug 2022 15:46:28 +0000 (15:46 +0000)] 
Merge "implement tuple-slices from .c collections" into main

2 years agofix up SAVEPOINT docs
Mike Bayer [Tue, 2 Aug 2022 15:34:35 +0000 (11:34 -0400)] 
fix up SAVEPOINT docs

these contained a factual error that the entire session is
expired, which is no longer the case (I can't find exactly
when this was changed).  Additionally, added a PostgreSQL
specific example w/ IntegrityError as this is the most
common case for this.   Tried to tighten up other language
and make it as clear as possible.

Change-Id: I39160e7443964db59d1d5a2e0616084767813eea

2 years agoMerge "repair psycopg2 (and psycopg) multiple hosts format" into main
mike bayer [Tue, 2 Aug 2022 13:49:42 +0000 (13:49 +0000)] 
Merge "repair psycopg2 (and psycopg) multiple hosts format" into main

2 years agodocument @ sign in issue template, docs
Mike Bayer [Tue, 2 Aug 2022 13:33:51 +0000 (09:33 -0400)] 
document @ sign in issue template, docs

Fixes: #8328
Change-Id: I69a48c4499fe7e57aad242403186e69c4452b84b

2 years agoSQLite reflection ignores schema internal names
Federico Caselli [Sat, 30 Jul 2022 10:40:37 +0000 (12:40 +0200)] 
SQLite reflection ignores schema internal names

Added new parameter to SQLite for reflection methods called
``sqlite_include_internal=True``; when omitted, local tables that start
with the prefix ``sqlite_``, which per SQLite documentation are noted as
"internal schema" tables such as the ``sqlite_sequence`` table generated to
support "AUTOINCREMENT" columns, will not be included in reflection methods
that return lists of local objects. This prevents issues for example when
using Alembic autogenerate, which previously would consider these
SQLite-generated tables as being remove from the model.

Fixes: #8234
Change-Id: I36ee7a053e04b6c46c912aaa0d7e035a5b88a4f9

2 years agoimplement tuple-slices from .c collections
Mike Bayer [Wed, 27 Jul 2022 15:36:57 +0000 (11:36 -0400)] 
implement tuple-slices from .c collections

Added new syntax to the ``.c`` collection on all :class:`.FromClause`
objects allowing tuples of keys to be passed to ``__getitem__()``, along
with support for ``select()`` handling of ``.c`` collections directly,
allowing the syntax ``select(table.c['a', 'b', 'c'])`` to be possible. The
sub-collection returned is itself a :class:`.ColumnCollection` which is
also directly consumable by :func:`_sql.select` and similar now.

Fixes: #8285
Change-Id: I2236662c477ffc50af079310589e213323c960d1

2 years agorepair psycopg2 (and psycopg) multiple hosts format
Mike Bayer [Mon, 1 Aug 2022 14:29:13 +0000 (10:29 -0400)] 
repair psycopg2 (and psycopg) multiple hosts format

Fixed issue in psycopg2 dialect where the "multiple hosts" feature
implemented for :ticket:`4392`, where multiple ``host:port`` pairs could be
passed in the query string as
``?host=host1:port1&host=host2:port2&host=host3:port3`` was not implemented
correctly, as it did not propagate the "port" parameter appropriately.
Connections that didn't use a different "port" likely worked without issue,
and connections that had "port" for some of the entries may have
incorrectly passed on that hostname. The format is now corrected to pass
hosts/ports appropriately.

As part of this change, maintained support for another multihost style that
worked unintentionally, which is comma-separated
``?host=h1,h2,h3&port=p1,p2,p3``. This format is more consistent with
libpq's query-string format, whereas the previous format is inspired by a
different aspect of libpq's URI format but is not quite the same thing.

If the two styles are mixed together, an error is raised as this is
ambiguous.

Fixes: #4392
Change-Id: Ic9cc0b0e6e90725e158d9efe73e042853dd1263f

2 years agoexclude __new__
Mike Bayer [Sun, 31 Jul 2022 14:33:30 +0000 (10:33 -0400)] 
exclude __new__

due to Generic this method seems to be coming out everywhere
and it's just noise

Change-Id: I8fabb462d5faebb156b147fbd8f89dbb1b1ba380

2 years agoRemove `__cmp__` methods (#8313)
Nikita Sobolev [Sun, 31 Jul 2022 10:08:36 +0000 (13:08 +0300)] 
Remove `__cmp__` methods (#8313)

2 years agoUpdate to flake8 5.
Federico Caselli [Sun, 31 Jul 2022 09:56:07 +0000 (11:56 +0200)] 
Update to flake8 5.

Change-Id: I5a241a70efba68bcea9819ddce6aebc25703e68d

2 years agouse inherited members for Query
Mike Bayer [Sat, 30 Jul 2022 19:14:23 +0000 (15:14 -0400)] 
use inherited members for Query

not sure why these four methods were here, they don't
get sorted when doing it this way.

Change-Id: I554f132df3f299858ca5b451a79fbd9dd1f520ee

2 years agoRemove all `__nonzero__` methods (#8308)
Nikita Sobolev [Sat, 30 Jul 2022 18:48:26 +0000 (21:48 +0300)] 
Remove all `__nonzero__` methods (#8308)

2 years agoglossary: update the acronym definition (#8306)
bbben [Sat, 30 Jul 2022 18:43:59 +0000 (02:43 +0800)] 
glossary: update the acronym definition (#8306)

* glossary: fix typo

* add 'Read' to the CRUD definition

2 years agoBump actions/checkout from 2 to 3 (#8310)
dependabot[bot] [Sat, 30 Jul 2022 14:10:19 +0000 (16:10 +0200)] 
Bump actions/checkout from 2 to 3 (#8310)

Bumps [actions/checkout](https://github.com/actions/checkout) from 2 to 3.
- [Release notes](https://github.com/actions/checkout/releases)
- [Changelog](https://github.com/actions/checkout/blob/main/CHANGELOG.md)
- [Commits](https://github.com/actions/checkout/compare/v2...v3)

---
updated-dependencies:
- dependency-name: actions/checkout
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2 years agoBump actions/setup-python from 2 to 4 (#8309)
dependabot[bot] [Sat, 30 Jul 2022 11:44:54 +0000 (13:44 +0200)] 
Bump actions/setup-python from 2 to 4 (#8309)

Bumps [actions/setup-python](https://github.com/actions/setup-python) from 2 to 4.
- [Release notes](https://github.com/actions/setup-python/releases)
- [Commits](https://github.com/actions/setup-python/compare/v2...v4)

---
updated-dependencies:
- dependency-name: actions/setup-python
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2 years agochore: Included githubactions in the dependabot config
Naveen [Sat, 30 Jul 2022 11:17:01 +0000 (07:17 -0400)] 
chore: Included githubactions in the dependabot config

This should help with keeping the GitHub actions updated on new releases. This will also help with keeping it secure.

Dependabot helps in keeping the supply chain secure https://docs.github.com/en/code-security/dependabot

GitHub actions up to date https://docs.github.com/en/code-security/dependabot/working-with-dependabot/keeping-your-actions-up-to-date-with-dependabot

https://github.com/ossf/scorecard/blob/main/docs/checks.md#dependency-update-tool
Signed-off-by: naveen <172697+naveensrinivasan@users.noreply.github.com>
Closes: #8180
Pull-request: https://github.com/sqlalchemy/sqlalchemy/pull/8180
Pull-request-sha: ef796e21f30da98c96e804bcdc056a17465525ca

Change-Id: I8252914951985de81dce944c3ab076dedf439cde

2 years agoglossary: primary_key needs value (#8298)
Fabian Preiß [Sat, 30 Jul 2022 10:47:15 +0000 (12:47 +0200)] 
glossary: primary_key needs value (#8298)

2 years agolink to index correctly
Mike Bayer [Sat, 30 Jul 2022 04:30:28 +0000 (00:30 -0400)] 
link to index correctly

Fixes: #8303
Change-Id: If3568309e4dd3e9ef715b32f9ad90eeba7f662e8

3 years agoMerge "feat: add `drop constraint if exists` to compiler" into main
mike bayer [Thu, 28 Jul 2022 18:19:44 +0000 (18:19 +0000)] 
Merge "feat: add `drop constraint if exists` to compiler" into main

3 years agoReflect expression-based indexes on PostgreSQL
Federico Caselli [Sat, 2 Jul 2022 21:49:07 +0000 (23:49 +0200)] 
Reflect expression-based indexes on PostgreSQL

The PostgreSQL dialect now supports reflection of expression based indexes.
The reflection is supported both when using
:meth:`_engine.Inspector.get_indexes` and when reflecting a
:class:`_schema.Table` using :paramref:`_schema.Table.autoload_with`.
Thanks to immerrr and Aidan Kane for the help on this ticket.

Fixes: #7442
Change-Id: I3e36d557235286c0f7f6d8276272ff9225058d48

3 years agoUpdate metadata.rst (#8290)
Paul Lettich [Tue, 26 Jul 2022 21:28:28 +0000 (23:28 +0200)] 
Update metadata.rst (#8290)

add missing colon in docs

3 years agofix lambda styles for relationship
Mike Bayer [Mon, 25 Jul 2022 13:26:40 +0000 (09:26 -0400)] 
fix lambda styles for relationship

Change-Id: I810fafc4cbcf0ac9b1f0de764130c81c56367a16

3 years agoset up Literal for synchronize_session
Mike Bayer [Sat, 23 Jul 2022 14:07:58 +0000 (10:07 -0400)] 
set up Literal for synchronize_session

Fixes: #8280
Change-Id: I59bc6cc0483375f79e17952188e0c2cde926502c

3 years agoremove mypy_path workaround and ensure messages received
Mike Bayer [Sat, 23 Jul 2022 14:18:06 +0000 (10:18 -0400)] 
remove mypy_path workaround and ensure messages received

Fixes: #8281
Change-Id: Ice47880ba7924daff68aef6b1791f3c66849f550

3 years agoclarify update perf test has only one test so far
Mike Bayer [Thu, 21 Jul 2022 13:41:50 +0000 (09:41 -0400)] 
clarify update perf test has only one test so far

this was pretty misleading as it shows up first in the
file listing

Change-Id: I6a92820e487a04632b651f9f6c631b32e338c043

3 years agoMerge "Use FETCH FIRST N ROWS / OFFSET for Oracle LIMIT/OFFSET" into main
mike bayer [Wed, 20 Jul 2022 17:29:59 +0000 (17:29 +0000)] 
Merge "Use FETCH FIRST N ROWS / OFFSET for Oracle LIMIT/OFFSET" into main

3 years agoMerge "add an extra load for non-new but unloaded" into main
mike bayer [Wed, 20 Jul 2022 15:41:56 +0000 (15:41 +0000)] 
Merge "add an extra load for non-new but unloaded" into main

3 years agoMerge "minor docs changes" into main
mike bayer [Wed, 20 Jul 2022 15:08:30 +0000 (15:08 +0000)] 
Merge "minor docs changes" into main

3 years agoUse FETCH FIRST N ROWS / OFFSET for Oracle LIMIT/OFFSET
Mike Bayer [Thu, 7 Jul 2022 16:07:39 +0000 (12:07 -0400)] 
Use FETCH FIRST N ROWS / OFFSET for Oracle LIMIT/OFFSET

Oracle will now use FETCH FIRST N ROWS / OFFSET syntax for limit/offset
support by default for Oracle 12c and above. This syntax was already
available when :meth:`_sql.Select.fetch` were used directly, it's now
implied for :meth:`_sql.Select.limit` and :meth:`_sql.Select.offset` as
well.

I'm currently setting this up so that the new syntax renders
in Oracle using POSTCOMPILE binds.    I really have no indication
if Oracle's SQL optimizer would be better with params
here, so that it can cache the SQL plan, or if it expects
hardcoded numbers for these. Since we had reports that the previous
ROWNUM thing really needed hardcoded ints, let's guess
for now that hardcoded ints would be preferable.  it can be turned
off with a single boolean if users report that they'd prefer
real bound values.

Fixes: #8221
Change-Id: I812ec24ffc947199866947b666d6ec6e6a690f22

3 years agoadd an extra load for non-new but unloaded
Mike Bayer [Thu, 23 Jun 2022 20:43:49 +0000 (16:43 -0400)] 
add an extra load for non-new but unloaded

Made an improvement to the "deferred" / "load_only" set of strategy options
where if a certain object is loaded from two different logical paths within
one query, attributes that have been configured by at least one of the
options to be populated will be populated in all cases, even if other load
paths for that same object did not set this option. previously, it was
based on randomness as to which "path" addressed the object first.

Fixes: #8166
Change-Id: I923a1484721d3a04d490ef882bc9fa609c9cd077

3 years agominor docs changes
Federico Caselli [Mon, 18 Jul 2022 21:31:15 +0000 (23:31 +0200)] 
minor docs changes

Change-Id: Iabcff11917eb267d0def191bee7ec03413d089e0

3 years agoMerge "fixes for mypy 0.971" into main
mike bayer [Tue, 19 Jul 2022 19:38:59 +0000 (19:38 +0000)] 
Merge "fixes for mypy 0.971" into main

3 years agoMerge "Ensure that a daclarative base is not used directly" into main
mike bayer [Tue, 19 Jul 2022 18:48:45 +0000 (18:48 +0000)] 
Merge "Ensure that a daclarative base is not used directly" into main

3 years agofixes for mypy 0.971
Mike Bayer [Tue, 19 Jul 2022 17:03:51 +0000 (13:03 -0400)] 
fixes for mypy 0.971

things that were passing with 0.961 need adjustment.
it seems mypy has become very pedantic about the difference
between importing from a module vs. accessing members of that
module as instance variables, so adjust the preloaded
typing block to be explicitly instance variables, since that's
how the accessor works in any case.

Change-Id: I746a3c9102530b7cf9b123aec7be6376657c1169

3 years agoMerge "check for TypeDecorator when handling getitem" into main
mike bayer [Tue, 19 Jul 2022 17:23:32 +0000 (17:23 +0000)] 
Merge "check for TypeDecorator when handling getitem" into main

3 years agocheck for TypeDecorator when handling getitem
Mike Bayer [Tue, 19 Jul 2022 14:50:05 +0000 (10:50 -0400)] 
check for TypeDecorator when handling getitem

Fixed issue where :class:`.TypeDecorator` would not correctly proxy the
``__getitem__()`` operator when decorating the :class:`.ARRAY` datatype,
without explicit workarounds.

Fixes: #7249
Change-Id: I3273572b4757e41fb5952639cb867314227d368a

3 years agorender all three elements selected in bundle example
Mike Bayer [Tue, 19 Jul 2022 15:13:59 +0000 (11:13 -0400)] 
render all three elements selected in bundle example

Fixes: #8013
Change-Id: I9b5f800d94abd80d07ca5f58c24f111618415674

3 years agoMerge "add shield() in aexit" into main
mike bayer [Mon, 18 Jul 2022 22:45:01 +0000 (22:45 +0000)] 
Merge "add shield() in aexit" into main

3 years agoEnsure that a daclarative base is not used directly
Federico Caselli [Fri, 15 Jul 2022 19:55:52 +0000 (21:55 +0200)] 
Ensure that a daclarative base is not used directly

Fixes: #8248
Change-Id: I4f4c690dd8659eaf74e9c757d681e9edc7d33eee

3 years agoMerge "implement executemany RETURNING for Oracle" into main
mike bayer [Mon, 18 Jul 2022 18:30:41 +0000 (18:30 +0000)] 
Merge "implement executemany RETURNING for Oracle" into main

3 years agoimplement executemany RETURNING for Oracle
Mike Bayer [Mon, 18 Jul 2022 16:52:28 +0000 (12:52 -0400)] 
implement executemany RETURNING for Oracle

this works straight out of the box as we can expand
upon what we did for #6245 to also receive for multiple
statements.    Oracle "fast ORM insert" then is basically done.

Fixes: #6245
Change-Id: I32902d199d473bc38cd03d14fec7482e1b37cd5b

3 years agoMerge "add contextmanager typing, open run_sync typing" into main
mike bayer [Mon, 18 Jul 2022 15:42:44 +0000 (15:42 +0000)] 
Merge "add contextmanager typing, open run_sync typing" into main

3 years agoadd shield() in aexit
Federico Caselli [Fri, 17 Jun 2022 21:12:39 +0000 (23:12 +0200)] 
add shield() in aexit

Added ``asyncio.shield()`` to the connection and session release process
specifically within the ``__aexit__()`` context manager exit, when using
:class:`.AsyncConnection` or :class:`.AsyncSession` as a context manager
that releases the object when the context manager is complete. This appears
to help with task cancellation when using alternate concurrency libraries
such as ``anyio``, ``uvloop`` that otherwise don't provide an async context
for the connection pool to release the connection properly during task
cancellation.

Fixes: #8145
Change-Id: I0b1ea9c3a22a18619341cbb8591225fcd339042c

3 years agoadd contextmanager typing, open run_sync typing
Mike Bayer [Mon, 18 Jul 2022 12:48:55 +0000 (08:48 -0400)] 
add contextmanager typing, open run_sync typing

was missing AsyncConnection type for the async
context manager.

fixing that revealed that _SyncConnectionCallable
and _SyncSessionCallable protocols are infeasible because
the given callable can have a lot of different signatures
that are compatible.

Change-Id: I559aa3dd88a902d0e7681c52223bb4bc0890adc1

3 years agouse concat() directly for contains, startswith, endswith
Mike Bayer [Sun, 17 Jul 2022 15:32:27 +0000 (11:32 -0400)] 
use concat() directly for contains, startswith, endswith

Adjusted the SQL compilation for string containment functions
``.contains()``, ``.startswith()``, ``.endswith()`` to force the use of the
string concatenation operator, rather than relying upon the overload of the
addition operator, so that non-standard use of these operators with for
example bytestrings still produces string concatenation operators.

To accommodate this, needed to add a new _rconcat operator function,
which is private, as well as a fallback in concat_op() that works
similarly to Python builtin ops.

Fixes: #8253
Change-Id: I2b7f56492f765742d88cb2a7834ded6a2892bd7e

3 years agoMerge "implement column._merge()" into main
mike bayer [Sun, 17 Jul 2022 01:14:39 +0000 (01:14 +0000)] 
Merge "implement column._merge()" into main

3 years agoimplement column._merge()
Mike Bayer [Sat, 16 Jul 2022 20:19:15 +0000 (16:19 -0400)] 
implement column._merge()

this takes the user-defined args of one Column and merges
them into the not-user-defined args of another Column.

Implemented within the pep-593 column transfer operation
to begin to make this new feature more robust.

work may still be needed for constraints etc. but
in theory everything from the left side annotated column
should take effect for the right side if not otherwise
specified on the right.

Change-Id: I57eb37ed6ceb4b60979a35cfc4b63731d990911d

3 years agoupdate ORM declarative docs for new features
Mike Bayer [Fri, 15 Jul 2022 16:53:37 +0000 (12:53 -0400)] 
update ORM declarative docs for new features

I screwed up a rebase or something so this was
temporarily in Ic51a12de3358f3a451bd7cf3542b375569499fc1

Change-Id: I847ee1336381221c0112b67854df022edf596b25

3 years agoMerge "make anno-only Mapped[] column available for mixins" into main
mike bayer [Fri, 15 Jul 2022 17:57:19 +0000 (17:57 +0000)] 
Merge "make anno-only Mapped[] column available for mixins" into main

3 years agoremove needlessly complex assoc proxy mixin example
Mike Bayer [Fri, 15 Jul 2022 16:53:37 +0000 (12:53 -0400)] 
remove needlessly complex assoc proxy mixin example

this is some very exotic example that doesn't really
explain anything new about mixins and only serves
to make the docs less accessible.

Change-Id: Ic51a12de3358f3a451bd7cf3542b375569499fc1

3 years agomake anno-only Mapped[] column available for mixins
Mike Bayer [Fri, 15 Jul 2022 16:25:22 +0000 (12:25 -0400)] 
make anno-only Mapped[] column available for mixins

Documentation is relying on the recently improved
behavior of produce_column_copies() to make sure everything is
available on cls for a declared_attr.  therefore for anno-only
attribute, we also need to generate the mapped_column() up front
before scan is called.

noticed in pylance, allow @declared_attr to recognize
@classmethod also which allows letting typing tools know
something is explicitly a classmethod

Change-Id: I07ff1a642a75679f685914a33c674807929f4918

3 years agostep five
Mike Bayer [Fri, 15 Jul 2022 12:55:08 +0000 (08:55 -0400)] 
step five

Change-Id: Ib6242d676c800b4b679aaf7f33f641ebcaed5b33

3 years agoMinor cleanup
Federico Caselli [Wed, 13 Jul 2022 21:18:57 +0000 (23:18 +0200)] 
Minor cleanup

- remove unnecessary postgresql visit that's equal to the default compiler
- clarify type_annotation_map documentation

Change-Id: I0c1fa212d06f6af799a5894802574250622c855e

3 years agosupport dataclasses with MutableComposite
Mike Bayer [Wed, 13 Jul 2022 18:30:36 +0000 (14:30 -0400)] 
support dataclasses with MutableComposite

basically a one line change

Change-Id: If6a70d49777e77f86e2b6936dd4aece20b00708e

3 years agoMerge "implement comparison ops for composites" into main
mike bayer [Wed, 13 Jul 2022 17:43:46 +0000 (17:43 +0000)] 
Merge "implement comparison ops for composites" into main

3 years agoimplement comparison ops for composites
Mike Bayer [Wed, 13 Jul 2022 16:48:37 +0000 (12:48 -0400)] 
implement comparison ops for composites

classes mapped by :class:`_orm.composite` now support
ordering comparison operations, e.g. ``<``, ``>=``, etc.

Change-Id: I44938b9ca2935b2f63c70e930768487ddc6b7669

3 years agodocument create_engine.isolation_level for PG
Mike Bayer [Wed, 13 Jul 2022 15:02:37 +0000 (11:02 -0400)] 
document create_engine.isolation_level for PG

Change-Id: I06eaede9e021eb0790929168e9bedb0c8b58140a
References: #8252

3 years agoMerge "Update docs for association_proxy" into main
mike bayer [Wed, 13 Jul 2022 00:41:26 +0000 (00:41 +0000)] 
Merge "Update docs for association_proxy" into main

3 years agoUpdate docs for association_proxy
Gord Thompson [Fri, 8 Jul 2022 17:50:54 +0000 (11:50 -0600)] 
Update docs for association_proxy

Make naming more consistent and explicit

Change-Id: If90de9ab8b10348d6d1547b9fd6e3b2c312d9ee8

3 years agoMerge "add some typing tests for declared_attr, mixins, decl base" into main
mike bayer [Tue, 12 Jul 2022 14:24:28 +0000 (14:24 +0000)] 
Merge "add some typing tests for declared_attr, mixins, decl base" into main

3 years agosupport "SELECT *" for ORM queries
Mike Bayer [Mon, 11 Jul 2022 01:24:17 +0000 (21:24 -0400)] 
support "SELECT *" for ORM queries

A :func:`_sql.select` construct that is passed a sole '*' argument for
``SELECT *``, either via string, :func:`_sql.text`, or
:func:`_sql.literal_column`, will be interpreted as a Core-level SQL
statement rather than as an ORM level statement. This is so that the ``*``,
when expanded to match any number of columns, will result in all columns
returned in the result. the ORM- level interpretation of
:func:`_sql.select` needs to know the names and types of all ORM columns up
front which can't be achieved when ``'*'`` is used.

If ``'*`` is used amongst other expressions simultaneously with an ORM
statement, an error is raised as this can't be interpreted correctly by the
ORM.

Fixes: #8235
Change-Id: Ic8e84491e14acdc8570704eadeaeaf6e16b1e870

3 years agoadd some typing tests for declared_attr, mixins, decl base
Mike Bayer [Fri, 8 Jul 2022 18:36:25 +0000 (14:36 -0400)] 
add some typing tests for declared_attr, mixins, decl base

to make typing easier, looking at using getattr on table.c
rather than getitem for now

Change-Id: I7946885071d0b0ddfc06be009f033495f9906de5

3 years agodocument using fetch() with Oracle
Mike Bayer [Thu, 7 Jul 2022 15:44:09 +0000 (11:44 -0400)] 
document using fetch() with Oracle

We implemented working FETCH support, but it's not
yet implied by limit/offset.  The docs make no mention
that this is available which is very misleading including
to maintainers.    Make it clear that fetch() support is
there right now, it's just not yet implicit with
limit/offset.

Change-Id: Ib2231dcdd80a8bf3ac4bbf590e1a8dfeac31e9da
References: #8221

3 years agoMerge "generalize sql server check for id col to accommodate ORM cases" into main
mike bayer [Wed, 6 Jul 2022 15:16:48 +0000 (15:16 +0000)] 
Merge "generalize sql server check for id col to accommodate ORM cases" into main

3 years agogeneralize sql server check for id col to accommodate ORM cases
Mike Bayer [Wed, 6 Jul 2022 01:05:18 +0000 (21:05 -0400)] 
generalize sql server check for id col to accommodate ORM cases

Fixed issues that prevented the new usage patterns for using DML with ORM
objects presented at :ref:`orm_dml_returning_objects` from working
correctly with the SQL Server pyodbc dialect.

Here we add a step to look in compile_state._dict_values more thoroughly
for the keys we need to determine "identity insert" or not, and also
add a new compiler variable dml_compile_state so that we can skip the
ORM's compile_state if present.

Fixes: #8210
Change-Id: Idbd76bb3eb075c647dc6c1cb78f7315c821e15f7

3 years agoMerge "test transfer of default, insert_default" into main
mike bayer [Wed, 6 Jul 2022 02:04:41 +0000 (02:04 +0000)] 
Merge "test transfer of default, insert_default" into main

3 years agoMerge "move backref to "legacy"" into main
mike bayer [Mon, 4 Jul 2022 18:13:57 +0000 (18:13 +0000)] 
Merge "move backref to "legacy"" into main

3 years agoMerge "Support lambda expression in mypy plugin" into main
mike bayer [Mon, 4 Jul 2022 18:13:32 +0000 (18:13 +0000)] 
Merge "Support lambda expression in mypy plugin" into main

3 years agomove backref to "legacy"
Mike Bayer [Mon, 4 Jul 2022 17:05:37 +0000 (13:05 -0400)] 
move backref to "legacy"

in the interests of consistency as well as new typing features,
backref should be considered legacy and is fully superseded
by back_populates.

this commit is for 2.0 /1.4, in 2.0 further updates will be
made for new ORM syntaxes.

Change-Id: Idd3b7a3b07843b73304df69e476dc4239c60b3f8

3 years agoruntime annotation fixes for relationship
Mike Bayer [Sun, 3 Jul 2022 20:25:15 +0000 (16:25 -0400)] 
runtime annotation fixes for relationship

* derive uselist=False when fwd ref passed to relationship

  This case needs to work whether or not the class name
  is a forward ref.  we dont allow the colleciton to be a
  forward ref so this will work.

* fix issues with MappedCollection

  When using string annotations or __future__.annotations,
  we need to do more parsing in order to get the target
  collection properly

Change-Id: I9e5a1358b62d060a8815826f98190801a9cc0b68

3 years agofeat: add `drop constraint if exists` to compiler
Mike Fiedler [Sun, 3 Jul 2022 21:56:07 +0000 (17:56 -0400)] 
feat: add `drop constraint if exists` to compiler

### Description

Add `DROP CONSTRAINT ... IF EXISTS` behavior to the compiler.

Fixes https://github.com/sqlalchemy/sqlalchemy/issues/8141

### Checklist
<!-- go over following points. check them with an `x` if they do apply, (they turn into clickable checkboxes once the PR is submitted, so no need to do everything at once)

-->

This pull request is:

- [ ] A documentation / typographical error fix
- Good to go, no issue or tests are needed
- [ ] A short code fix
- please include the issue number, and create an issue if none exists, which
  must include a complete example of the issue.  one line code fixes without an
  issue and demonstration will not be accepted.
- Please include: `Fixes: #<issue number>` in the commit message
- please include tests.   one line code fixes without tests will not be accepted.
- [x] A new feature implementation
- please include the issue number, and create an issue if none exists, which must
  include a complete example of how the feature would look.
- Please include: `Fixes: #<issue number>` in the commit message
- please include tests.

**Have a nice day!**

Closes: #8161
Pull-request: https://github.com/sqlalchemy/sqlalchemy/pull/8161
Pull-request-sha: 43276e29fa864fc66900c5a3fa0bf84df5f14271

Change-Id: I18bae3cf013159b6fffde4413fb59ce19ff83c16

3 years agotest transfer of default, insert_default
Mike Bayer [Sun, 3 Jul 2022 17:55:20 +0000 (13:55 -0400)] 
test transfer of default, insert_default

right now "default" goes to Column.default unconditionally
if insert_default is not present, including if dataclasses
are in use where the field effectively now does two things.
This generally works out because Python side default
can be assigned to the object or picked up by Core in any case.
However, we might want to look into later on migrating this
to have the fields act more separately.  I think it's
"OK" for now, will try to doc that this might change.

Change-Id: I30f2085ec79a6464da4d5c578500848c70d55ec2

3 years agofix formatting problems
Mike Bayer [Sun, 3 Jul 2022 15:09:16 +0000 (11:09 -0400)] 
fix formatting problems

Change-Id: Ib55fe1c60130a45bfbf28de5c74cfe7a30418bb3

3 years agodont use import * in any docs, ever
Mike Bayer [Sun, 3 Jul 2022 15:01:25 +0000 (11:01 -0400)] 
dont use import * in any docs, ever

3 years agochore: Set permissions for GitHub actions (#8117)
Naveen [Sat, 2 Jul 2022 21:58:16 +0000 (16:58 -0500)] 
chore: Set permissions for GitHub actions (#8117)

Restrict the GitHub token permissions only to the required ones; this way, even if the attackers will succeed in compromising your workflow, they won’t be able to do much.

- Included permissions for the action. https://github.com/ossf/scorecard/blob/main/docs/checks.md#token-permissions

https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#permissions

https://docs.github.com/en/actions/using-jobs/assigning-permissions-to-jobs

[Keeping your GitHub Actions and workflows secure Part 1: Preventing pwn requests](https://securitylab.github.com/research/github-actions-preventing-pwn-requests/)

Signed-off-by: naveen <172697+naveensrinivasan@users.noreply.github.com>
3 years agocall toinstance() on type arguments passed to mapped_column()
Mike Bayer [Sat, 2 Jul 2022 15:49:56 +0000 (11:49 -0400)] 
call toinstance() on type arguments passed to mapped_column()

Change-Id: I875cfbd925cb08e0a5235f87d13341d319c955bc

3 years agoSupport lambda expression in mypy plugin
Cyril Chapellier [Thu, 30 Jun 2022 12:59:38 +0000 (14:59 +0200)] 
Support lambda expression in mypy plugin

Avoid `error: INTERNAL ERROR` when the default is a lambda

Fixes: #8196
Change-Id: I7346c693519b024c56156db6f4ffc9a45bb748d3

3 years agoclarify eager loading terminology
Mike Bayer [Fri, 1 Jul 2022 18:35:27 +0000 (14:35 -0400)] 
clarify eager loading terminology

Change-Id: Idb27ec5f09ef958d71738e1095b4be7a1377eecb

3 years agorepair yield_per for non-SS dialects and add new options
Mike Bayer [Thu, 30 Jun 2022 23:10:06 +0000 (19:10 -0400)] 
repair yield_per for non-SS dialects and add new options

Implemented new :paramref:`_engine.Connection.execution_options.yield_per`
execution option for :class:`_engine.Connection` in Core, to mirror that of
the same :ref:`yield_per <orm_queryguide_yield_per>` option available in
the ORM. The option sets both the
:paramref:`_engine.Connection.execution_options.stream_results` option at
the same time as invoking :meth:`_engine.Result.yield_per`, to provide the
most common streaming result configuration which also mirrors that of the
ORM use case in its usage pattern.

Fixed bug in :class:`_engine.Result` where the usage of a buffered result
strategy would not be used if the dialect in use did not support an
explicit "server side cursor" setting, when using
:paramref:`_engine.Connection.execution_options.stream_results`. This is in
error as DBAPIs such as that of SQLite and Oracle already use a
non-buffered result fetching scheme, which still benefits from usage of
partial result fetching.   The "buffered" strategy is now used in all
cases where :paramref:`_engine.Connection.execution_options.stream_results`
is set.

Added :meth:`.FilterResult.yield_per` so that result implementations
such as :class:`.MappingResult`, :class:`.ScalarResult` and
:class:`.AsyncResult` have access to this method.

Fixes: #8199
Change-Id: I6dde3cbe483a1bf81e945561b60f4b7d1c434750

3 years agoImprove reflection method docs
Federico Caselli [Thu, 30 Jun 2022 20:26:12 +0000 (22:26 +0200)] 
Improve reflection method docs

Point to the typed dict for the documentation instead of
duplicating it in the mothod text.

Change-Id: I041abee7dc27b95409950741e702d69101c22c6d

3 years agomore partition doc adjustments
Mike Bayer [Thu, 30 Jun 2022 19:00:08 +0000 (15:00 -0400)] 
more partition doc adjustments

the partition story is not very good, this is a ton
of different options and they have to all be used
simultaenously for the common case.

Change-Id: I62963b7db1230a2670dda0ce812086f9265a3cb7

3 years agoadd more cross-linking / notes for yield_per, partitions
Mike Bayer [Thu, 30 Jun 2022 17:33:30 +0000 (13:33 -0400)] 
add more cross-linking / notes for yield_per, partitions

Change-Id: I0f8db2532827c76a2751186638d22104230db843
references: #8198

3 years agoMerge "Change setinputsizes behavior for mssql+pyodbc" into main
mike bayer [Wed, 29 Jun 2022 17:41:16 +0000 (17:41 +0000)] 
Merge "Change setinputsizes behavior for mssql+pyodbc" into main

3 years agoMerge "produce column copies up the whole hierarchy first" into main
mike bayer [Wed, 29 Jun 2022 16:52:49 +0000 (16:52 +0000)] 
Merge "produce column copies up the whole hierarchy first" into main

3 years agoMerge branch 'jefferson2z-documentation-typo'
Mike Bayer [Wed, 29 Jun 2022 15:31:15 +0000 (11:31 -0400)] 
Merge branch 'jefferson2z-documentation-typo'

Change-Id: I0b610804a969dd67901c420fdcc2d5275b8e308e