]> git.ipfire.org Git - thirdparty/sqlalchemy/sqlalchemy.git/log
thirdparty/sqlalchemy/sqlalchemy.git
3 years agogeneralize conditional DDL throughout schema / DDL
Mike Bayer [Thu, 27 Jan 2022 20:07:17 +0000 (15:07 -0500)] 
generalize conditional DDL throughout schema / DDL

Expanded on the "conditional DDL" system implemented by the
:class:`_schema.DDLElement` class to be directly available on
:class:`_schema.SchemaItem` constructs such as :class:`_schema.Index`,
:class:`_schema.ForeignKeyConstraint`, etc. such that the conditional logic
for generating these elements is included within the default DDL emitting
process. This system can also be accommodated by a future release of
Alembic to support conditional DDL elements within all schema-management
systems.

Fixes: #7631
Change-Id: I9457524d7f66f49696187cf7d2b37dbb44f0e20b

3 years agopep484 - SQL internals
Mike Bayer [Sun, 20 Mar 2022 20:39:36 +0000 (16:39 -0400)] 
pep484 - SQL internals

non-strict checking for mostly internal or semi-internal
code

Change-Id: Ib91b47f1a8ccc15e666b94bad1ce78c4ab15b0ec

3 years agofix generate series example
Mike Bayer [Wed, 23 Mar 2022 14:09:18 +0000 (10:09 -0400)] 
fix generate series example

this just drove me nuts because it didn't include
render_derived(), doesn't run on PG as given

Change-Id: I5d39336231c97b6cd5477644a718282709db2e1f

3 years agoUpgrade parts of the documentation to 2.0 style
provinzkraut [Tue, 22 Mar 2022 17:17:56 +0000 (13:17 -0400)] 
Upgrade parts of the documentation to 2.0 style

<!-- Provide a general summary of your proposed changes in the Title field above -->

I've started to work on #7659, implementing the low hanging fruit changes for now. Some still remain, which I've outlined as a [comment](https://github.com/sqlalchemy/sqlalchemy/issues/7659#issuecomment-1073029151), and probably also some that I didn't catch.

<!-- 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:

- [x] 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.
- [ ] 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: #7829
Pull-request: https://github.com/sqlalchemy/sqlalchemy/pull/7829
Pull-request-sha: a89561dd0c96c2f9a6d992fa0fb94683afaf7e30

Change-Id: Ibc5ea94b5c4b2d7b1cf7bea24f4394d1fde749be

3 years agoMerge branch 'abitrolly-patch-1'
Mike Bayer [Tue, 22 Mar 2022 13:57:14 +0000 (09:57 -0400)] 
Merge branch 'abitrolly-patch-1'

Change-Id: I049baded97844916869619f91b09ac71ef95907a

3 years agoMerge branch 'patch-1' of https://github.com/abitrolly/sqlalchemy into abitrolly...
Mike Bayer [Tue, 22 Mar 2022 13:55:53 +0000 (09:55 -0400)] 
Merge branch 'patch-1' of https://github.com/abitrolly/sqlalchemy into abitrolly-patch-1

Change-Id: Ic312eed882e9d6b547e8b4ef0c6f184c2b253547

3 years agouse begin() for settting up first PK
Mike Bayer [Mon, 21 Mar 2022 21:47:34 +0000 (17:47 -0400)] 
use begin() for settting up first PK

Change-Id: I227bbb46fbcbae1f60d3f5bb4dd2b9f41ca3dd0c

3 years agonote that horizontal sharding supports multi schema translates
Mike Bayer [Mon, 21 Mar 2022 21:35:26 +0000 (17:35 -0400)] 
note that horizontal sharding supports multi schema translates

the horizontal sharding API needs some work as it is
still exposing some legacy details, but in any case illustrate
how we can, for the moment, to use multiple schema translate
maps in a single session.

A lot more cleanup is needed in horizontal sharding, see #7837

Change-Id: Ia925e2226ecee9d747a8c4fc1772917f10bc505f
References: #7832
References: #7837

3 years agoadditional updates to stream results note
Mike Bayer [Mon, 21 Mar 2022 20:29:59 +0000 (16:29 -0400)] 
additional updates to stream results note

Change-Id: I9d7ed9f412a2d9384f6c0b50316df79b6f8f481a

3 years agoMerge "test #7820" into main
mike bayer [Mon, 21 Mar 2022 19:57:52 +0000 (19:57 +0000)] 
Merge "test #7820" into main

3 years agoadd note that schema translate not supported per object
Mike Bayer [Mon, 21 Mar 2022 13:07:51 +0000 (09:07 -0400)] 
add note that schema translate not supported per object

Fixes: #7832
Change-Id: I241e4cbd1b5d6df46e49e29e4ab1cac021f2895c

3 years agoMerge "pep 484 for types" into main
mike bayer [Sun, 20 Mar 2022 13:48:17 +0000 (13:48 +0000)] 
Merge "pep 484 for types" into main

3 years agoMerge "Remove duplicate entry in .gitignore" into main
mike bayer [Sun, 20 Mar 2022 13:43:38 +0000 (13:43 +0000)] 
Merge "Remove duplicate entry in .gitignore" into main

3 years agoMerge "catch unexpected errors when accessing clslevel attribute" into main
mike bayer [Sun, 20 Mar 2022 13:37:37 +0000 (13:37 +0000)] 
Merge "catch unexpected errors when accessing clslevel attribute" into main

3 years agoSmall docs fix in 'Relationship Loading Techniques' (#7824)
Andrés Álvarez [Sun, 20 Mar 2022 11:26:25 +0000 (05:26 -0600)] 
Small docs fix in 'Relationship Loading Techniques' (#7824)

3 years agopep 484 for types
Mike Bayer [Thu, 17 Mar 2022 20:18:55 +0000 (16:18 -0400)] 
pep 484 for types

strict types type_api.py, including TypeDecorator,
NativeForEmulated, etc.

Change-Id: Ib2eba26de0981324a83733954cb7044a29bbd7db

3 years agocatch unexpected errors when accessing clslevel attribute
Mike Bayer [Fri, 18 Mar 2022 14:33:40 +0000 (10:33 -0400)] 
catch unexpected errors when accessing clslevel attribute

Improved the error message that's raised for the case where the
:func:`.association_proxy` construct attempts to access a target attribute
at the class level, and this access fails. The particular use case here is
when proxying to a hybrid attribute that does not include a working
class-level implementation.

Fixes: #7827
Change-Id: Ic6ff9df010f49253e664a1e7c7e16d8546006965

3 years agoRemove duplicate entry in .gitignore
Gord Thompson [Thu, 17 Mar 2022 19:38:39 +0000 (13:38 -0600)] 
Remove duplicate entry in .gitignore

Change-Id: I0785c77398d067d06434f387897874aaf137b18d

3 years agoMerge "Fix "Ambiguous column name" error on FK reflection" into main
mike bayer [Thu, 17 Mar 2022 18:21:30 +0000 (18:21 +0000)] 
Merge "Fix "Ambiguous column name" error on FK reflection" into main

3 years agoMerge "remove intermediary _is_clone_of entries when cloning" into main
mike bayer [Thu, 17 Mar 2022 17:22:05 +0000 (17:22 +0000)] 
Merge "remove intermediary _is_clone_of entries when cloning" into main

3 years agoremove intermediary _is_clone_of entries when cloning
Mike Bayer [Wed, 16 Mar 2022 16:37:20 +0000 (12:37 -0400)] 
remove intermediary _is_clone_of entries when cloning

Improvements in memory usage by the ORM, removing a significant set of
intermediary expression objects that are typically stored when a copy of an
expression object is created. These clones have been greatly reduced,
reducing the number of total expression objects stored in memory by
ORM mappings by about 30%.

note this change causes the tests to have a bit of a harder time with
GC, which we would assume is because mappings now have a lot more
garbage to clean up after mappers are configured.   it remains
to be seen what the long term effects of this are.

Fixes: #7823
Change-Id: If8729747ffb9bf27e8974f069a994b5a823ee095

3 years agopep484 for hybrid
Mike Bayer [Wed, 16 Mar 2022 16:07:25 +0000 (12:07 -0400)] 
pep484 for hybrid

Change-Id: I53274b13094d996e11b04acb03f9613edbddf87f
References: #6810

3 years agopep-484 - SQL column operations
Mike Bayer [Sun, 13 Mar 2022 17:37:11 +0000 (13:37 -0400)] 
pep-484 - SQL column operations

note we are taking out the
ColumnOperartors[SQLCoreOperations] thing; not really clear
why that was needed and at the moment it seems I was likely
confused.

Change-Id: I834b75f9b44f91b97e29f2e1a7b1029bd910e0a1

3 years agotest #7820
Mike Bayer [Mon, 14 Mar 2022 18:09:03 +0000 (14:09 -0400)] 
test #7820

There was an apparent improvement in the distill params
methodology used in exec_driver_sql which allows raw tuples to
pass through.  In 1.4 there seems to be a _distill_cursor_params()
function that says it can handle this kind of parameter, but it isn't
used and when I tried to substitute it in for exec_driver_sql(),
things still fail.

In any case, add coverage here for the use case of passing
direct tuple params to exec_driver_sql including as the first
param, to note that it isn't mis-interpreted the way it is
in 1.x.

Change-Id: I27b875c0f874aee3f6f0d3e28c4c858dd39344e9

3 years agoFix "Ambiguous column name" error on FK reflection
Gord Thompson [Mon, 14 Mar 2022 17:26:54 +0000 (11:26 -0600)] 
Fix "Ambiguous column name" error on FK reflection

Fixes: #7812
Change-Id: Ic16eff9a9201d34515cb8eb884270eced4e1196a

3 years agomove compiler / pool critical casts away
Mike Bayer [Mon, 14 Mar 2022 18:34:05 +0000 (14:34 -0400)] 
move compiler / pool critical casts away

callcount tests were being impacted by a few cast() calls,
move them behind TYPE_CHECKING

Change-Id: I633bbfe55313db94ebb22f87cc4216f8e50d807e

3 years agorestore an updated version of cascade backrefs
Mike Bayer [Mon, 14 Mar 2022 04:01:30 +0000 (00:01 -0400)] 
restore an updated version of cascade backrefs

these sections were removed totally from SQLAlchemy 2.0
as the ``cascade_backrefs`` option was removed.  However,
the current behavior is still one that should be documented,
so restore the two removed sections in a re-worded form
that presents the current behavior as well as some
explaination.

Change-Id: I43fc0bca926a90937d419a1d11c27d18d5d5b4b8

3 years agopep-484: sqlalchemy.sql pass one
Mike Bayer [Tue, 8 Mar 2022 22:14:41 +0000 (17:14 -0500)] 
pep-484: sqlalchemy.sql pass one

sqlalchemy.sql will require many passes to get all
modules even gradually typed.  Will have to pick and
choose what modules can be strictly typed vs. which
can be gradual.

in this patch, emphasis is on visitors.py, cache_key.py,
annotations.py for strict typing, compiler.py is on gradual
typing but has much more structure, in particular where it
connects with the outside world.

The work within compiler.py also reached back out to
engine/cursor.py , default.py quite a bit.

References: #6810
Change-Id: I6e8a29f6013fd216e43d45091bc193f8be0368fd

3 years agoMerge "additional mypy strictness" into main
mike bayer [Sat, 12 Mar 2022 19:59:29 +0000 (19:59 +0000)] 
Merge "additional mypy strictness" into main

3 years agoadditional mypy strictness
Mike Bayer [Thu, 10 Mar 2022 16:57:00 +0000 (11:57 -0500)] 
additional mypy strictness

enable type checking within untyped defs.  This allowed
some more internals to be fixed up with assertions etc.

some internals that were unnecessary or not even used
at all were removed.  BaseCursorResult was no longer
necessary since we only have one kind of CursorResult
now.  The different ResultProxy subclasses that had
alternate "strategies" dont appear to be used at all
even in 1.4.x, as there's no code that accesses the
_cursor_strategy_cls attribute, which is also removed.
As these were mostly private constructs that weren't
even functioning correctly in any case,
it's fine to remove these over the 2.0 boundary.

Change-Id: Ifd536987d104b1cd8b546cefdbd5c1e5d1801082

3 years agorestore quickstart to toc
Mike Bayer [Fri, 11 Mar 2022 21:23:14 +0000 (16:23 -0500)] 
restore quickstart to toc

this was coming out wrong due to the wrong header level
on the page.  it needs to be in a visible toc so that
the inner elements show up on the sidebar / top mobile nav.

Change-Id: I13acbe0d82c6a839230bc2e2454e4ab82e4879e6

3 years agofurther simplify pool-sharing doc
Mike Bayer [Fri, 11 Mar 2022 21:01:09 +0000 (16:01 -0500)] 
further simplify pool-sharing doc

1. the event based approach doesn't require dispose() to be
   called at all, and the note that the "pool will hang" makes
   no sense.   I have no idea what that refers towards
2. the subsequent paragraph about connections and sessions
   is unintelligible.  old paragraphs like these are likely
   why people complain about the docs so much.  try to just
   say "don't do this", as that is easier than trying to
   explain to use connection.invalidate() etc.

Change-Id: Id840c65a2f71583ced4dc82fd8690e7da4c4b10e

3 years agodispose session outside of child proc
Mike Bayer [Fri, 11 Mar 2022 19:59:04 +0000 (14:59 -0500)] 
dispose session outside of child proc

disposing inside the child proc can interfere with the parent
process.  we likely never considered this.

Fixes: #7815
Change-Id: I6ad0e5840655ed99a9d30002eba280c8e44a5c2e

3 years agotake quickstart out of main TOC for now
Mike Bayer [Fri, 11 Mar 2022 19:10:17 +0000 (14:10 -0500)] 
take quickstart out of main TOC for now

looks kind of awkward and isn't reference

Change-Id: I4fb664f79b792a32c6695a9cae7b1845a3044271

3 years agofix section format headings, remove "Step: "
Mike Bayer [Fri, 11 Mar 2022 19:07:09 +0000 (14:07 -0500)] 
fix section format headings, remove "Step: "

Change-Id: I25a837cf866b152a30aa373d07f704e0cc11d497

3 years agoadd copybutton
Mike Bayer [Fri, 11 Mar 2022 18:40:16 +0000 (13:40 -0500)] 
add copybutton

works great, including for plain code plus prompt code
with SQL (copies only the prompt code when prompts are present).
added some styling to zzzeeksphinx

Change-Id: I1b94b0488689e875adfb90ec171e04f7e8022415

3 years agoORM quickstart
Mike Bayer [Fri, 11 Mar 2022 15:08:36 +0000 (10:08 -0500)] 
ORM quickstart

This is done in 1.4 style so it can be backported to 1.4.
Will put this up as is, we can work on it.   For 2.0, the
ORM mapping will be updated to mapped_column() style when
we do the full pass.

Change-Id: Icfdf81449973844dac244b3a107ce955a7d3b16c

3 years agoMerge "support adapt_on_names for with_polymorphic" into main
mike bayer [Wed, 9 Mar 2022 15:37:00 +0000 (15:37 +0000)] 
Merge "support adapt_on_names for with_polymorphic" into main

3 years agoadd note about slots=True for attrs
Mike Bayer [Tue, 8 Mar 2022 23:38:11 +0000 (18:38 -0500)] 
add note about slots=True for attrs

Fixes: #7802
Change-Id: Ic5fadd369a0b63309cd9c44798ee5395efdbab2b

3 years agopop the stack that we pushed
Mike Bayer [Tue, 8 Mar 2022 18:40:12 +0000 (13:40 -0500)] 
pop the stack that we pushed

Fixed regression caused by :ticket:`7760` where the new capabilities of
:class:`.TextualSelect` were not fully implemented within the compiler
properly, leading to issues with composed INSERT constructs such as "INSERT
FROM SELECT" and "INSERT...ON CONFLICT" when combined with CTE and textual
statements.

Fixes: #7798
Change-Id: Ia2ce92507e574dd36fd26dd38ec9dd2713584467

3 years agosupport adapt_on_names for with_polymorphic
Mike Bayer [Tue, 8 Mar 2022 14:34:09 +0000 (09:34 -0500)] 
support adapt_on_names for with_polymorphic

Added :paramref:`_orm.with_polymorphic.adapt_on_names` to the
:func:`_orm.with_polymorphic` function, which allows a polymorphic load
(typically with concrete mapping) to be stated against an alternative
selectable that will adapt to the original mapped selectable on column
names alone.

Fixes: #7805
Change-Id: I933e180a489fec8a6f4916d1622d444dd4434f30

3 years agoMerge "support selectin_polymorphic w/ no fixed polymorphic_on" into main
mike bayer [Tue, 8 Mar 2022 15:20:09 +0000 (15:20 +0000)] 
Merge "support selectin_polymorphic w/ no fixed polymorphic_on" into main

3 years agosupport selectin_polymorphic w/ no fixed polymorphic_on
Mike Bayer [Mon, 7 Mar 2022 20:11:29 +0000 (15:11 -0500)] 
support selectin_polymorphic w/ no fixed polymorphic_on

Fixed issue where the :func:`_orm.polymorphic_selectin` loader option would
not work with joined inheritance mappers that don't have a fixed
"polymorphic_on" column.   Additionally added test support for a wider
variety of usage patterns with this construct.

Fixed bug where :func:`_orm.composite` attributes would not work in
conjunction with the :func:`_orm.selectin_polymorphic` loader strategy for
joined table inheritance.

Fixes: #7799
Fixes: #7801
Change-Id: I7cfe32dfe844b188403b39545930c0aee71d0119

3 years agoMerge "adapt create_engine from sqlalchemy2-stubs" into main
mike bayer [Tue, 8 Mar 2022 04:25:21 +0000 (04:25 +0000)] 
Merge "adapt create_engine from sqlalchemy2-stubs" into main

3 years agoadapt create_engine from sqlalchemy2-stubs
Mike Bayer [Mon, 7 Mar 2022 17:01:42 +0000 (12:01 -0500)] 
adapt create_engine from sqlalchemy2-stubs

this is much simplified, will try to see if _IsolationLevel
can work out, technically some driver can have custom values
here but in practice this might not be a thing

Change-Id: I6085ccb559c377fab03c8ce79f0eecb240c56f7a

3 years agotest sqlite w/ savepoint workaround in session fixture test
Mike Bayer [Mon, 7 Mar 2022 16:17:47 +0000 (11:17 -0500)] 
test sqlite w/ savepoint workaround in session fixture test

Fixes: #7795
Change-Id: Ib790581555656c088f86c00080c70d19ca295a03

3 years agocherry-pick changelog update for 1.4.33
Mike Bayer [Sun, 6 Mar 2022 22:43:27 +0000 (17:43 -0500)] 
cherry-pick changelog update for 1.4.33

3 years agocherry-pick changelog from 1.4.32
Mike Bayer [Sun, 6 Mar 2022 22:43:26 +0000 (17:43 -0500)] 
cherry-pick changelog from 1.4.32

3 years ago1.4.32 changelog edits
Mike Bayer [Sun, 6 Mar 2022 18:18:59 +0000 (13:18 -0500)] 
1.4.32 changelog edits

Change-Id: I3f62ba9c8ff35c8ae1d0bd611db92521da38dff0
(cherry picked from commit 03e17631cc6e6e521668ef9deec908d8c7265a0a)

3 years agoMerge "warn for enum length silently ignored" into main
mike bayer [Fri, 4 Mar 2022 23:58:07 +0000 (23:58 +0000)] 
Merge "warn for enum length silently ignored" into main

3 years agoMerge "fix type string formatting calls" into main
mike bayer [Fri, 4 Mar 2022 23:31:49 +0000 (23:31 +0000)] 
Merge "fix type string formatting calls" into main

3 years agoadd missing changelog for #7045
Mike Bayer [Fri, 4 Mar 2022 23:30:40 +0000 (18:30 -0500)] 
add missing changelog for #7045

was missed in d2815b4ac39b42a38dff4cc21ec100c72b9f3cae

Fixes: #7045
Change-Id: Id4836690daabf7e547c278a4e538d39579e5f2a2

3 years agowarn for enum length silently ignored
Mike Bayer [Fri, 4 Mar 2022 23:27:24 +0000 (18:27 -0500)] 
warn for enum length silently ignored

the "length" parameter is silently ignored when native_enum
is not passed as False.  if native_enum is True, a non-native
VARCHAR can still be generated.   Warn for this silent ignore
right now, consider having "length" used in all cases where
non-native enum is rendered likely in 2.0.

Change-Id: Ibceedd4e3aa3926f3268c0c39d94ab73d17a9bdc

3 years agoadd length to enum repr params
Mike Bayer [Fri, 4 Mar 2022 22:30:21 +0000 (17:30 -0500)] 
add length to enum repr params

This amends the fix for #7789.

Fixes: #7598
Change-Id: I067a081d743f1efaf8288601bec0400712012265

3 years agofix type string formatting calls
Mike Bayer [Fri, 4 Mar 2022 22:17:53 +0000 (17:17 -0500)] 
fix type string formatting calls

Fixed type-related error messages that would fail for values that were
tuples, due to string formatting syntax, including compile of unsupported
literal values and invalid boolean values.

Fixes: #7721
Change-Id: I6775721486ef2db2d0738b9aa08b9f2570f55659

3 years agocorrect for pytest discovery
Mike Bayer [Fri, 4 Mar 2022 21:28:31 +0000 (16:28 -0500)] 
correct for pytest discovery

Made corrections to the default pytest configuration so that test discovery
runs correctly; previously, a configuration error had the effect of
discovery locating the wrong files if a super-directory of the current
directory were named "test".

Fixes: #7045
Change-Id: I2e1f63a35f80ae3f53008f327d83c8342fa7f2f6

3 years agoMerge "Fix repr for MySQL SET, generic Enum" into main
mike bayer [Fri, 4 Mar 2022 20:50:48 +0000 (20:50 +0000)] 
Merge "Fix repr for MySQL SET, generic Enum" into main

3 years agoAdd LongAsMax note to mssql+pyodbc dialect docs
Gord Thompson [Fri, 4 Mar 2022 18:13:14 +0000 (11:13 -0700)] 
Add LongAsMax note to mssql+pyodbc dialect docs

Change-Id: I4491b188bae49ac615f8691dd9b7a8a341428ce7

3 years agoFix repr for MySQL SET, generic Enum
petit87 [Sat, 26 Feb 2022 21:46:32 +0000 (16:46 -0500)] 
Fix repr for MySQL SET, generic Enum

Fixed issues in :class:`_mysql.SET` datatype as well as :class:`.Enum`
where the ``__repr__()`` method would not render all optional parameters in
the string output, impacting the use of these types in Alembic
autogenerate. Pull request for MySQL courtesy Yuki Nishimine.

Fixes: #7720
Fixes: #7789
Closes: #7772
Pull-request: https://github.com/sqlalchemy/sqlalchemy/pull/7772
Pull-request-sha: d58845479f497f6b2e12d7df2e9eb2d6ac22109b
Co-authored-by: Mike Bayer <mike_mp@zzzcomputing.com>
Change-Id: Idcec23eab4258511d9f32f4e3d78e511ea6021f1

3 years agoMerge "improve error raise for dialect/pool events w/ async engine" into main
mike bayer [Fri, 4 Mar 2022 17:43:17 +0000 (17:43 +0000)] 
Merge "improve error raise for dialect/pool events w/ async engine" into main

3 years agomore corrections to 1.4.31 release
Mike Bayer [Fri, 21 Jan 2022 01:33:00 +0000 (20:33 -0500)] 
more corrections to 1.4.31 release

(cherry picked from commit ab42b0e3d98386c8a13edea3206ef43f018de3b6)

Change-Id: I66414da6689d1f7fdd52056176ba9b04a415e532

3 years agocherry-pick changelog update for 1.4.32
Mike Bayer [Fri, 4 Mar 2022 16:29:54 +0000 (11:29 -0500)] 
cherry-pick changelog update for 1.4.32

(cherry picked from commit 19e6d4ffaba8cd8db5c6abfdf9e632c80c398507)

3 years agoUpdate __init__.py (#7778)
Jostein Leira [Thu, 3 Mar 2022 21:40:22 +0000 (22:40 +0100)] 
Update __init__.py (#7778)

Missing parenthesis in example code.

3 years agoquick doc adjustments
Mike Bayer [Thu, 3 Mar 2022 15:33:14 +0000 (10:33 -0500)] 
quick doc adjustments

tweet thread:  https://twitter.com/zzzeek/status/1499397255089909762

Change-Id: I5556ef707c2285e7b64c91ae5c58af52efcf4770

3 years agoremove errant comment
Mike Bayer [Thu, 3 Mar 2022 03:22:03 +0000 (22:22 -0500)] 
remove errant comment

Change-Id: I61e5a17ed079cf9c86419c7f480b651872248f6e

3 years agoimprove error raise for dialect/pool events w/ async engine
Mike Bayer [Thu, 3 Mar 2022 02:43:53 +0000 (21:43 -0500)] 
improve error raise for dialect/pool events w/ async engine

Fixed issues where a descriptive error message was not raised for some
classes of event listening with an async engine, which should instead be a
sync engine instance.

Change-Id: I00b9f4fe9373ef5fd5464fac10651cc4024f648e

3 years agoprevent Mapped[] auto-column logic w/ fixed table
Mike Bayer [Wed, 2 Mar 2022 16:51:57 +0000 (11:51 -0500)] 
prevent Mapped[] auto-column logic w/ fixed table

When a class has __table__, people will still want to
annotate the attributes on classes, so make sure a
Mapped annotation without a right side is only interpreted
as a column if there is no __table__

Change-Id: I7da4b4c43c4d2c8b6834b781569cb551e75b57b1

3 years agopep484 + abc bases for assocaitionproxy
Mike Bayer [Mon, 28 Feb 2022 04:05:46 +0000 (23:05 -0500)] 
pep484 + abc bases for assocaitionproxy

went to this one next as it was going to be hard,
and also exercises the ORM expression hierarchy a bit.
made some adjustments to SQLCoreOperations etc.

Change-Id: Ie5dde9218dc1318252826b766d3e70b17dd24ea7
References: #6810
References: #7774

3 years agoMerge "pep-484 for engine" into main
mike bayer [Wed, 2 Mar 2022 01:45:40 +0000 (01:45 +0000)] 
Merge "pep-484 for engine" into main

3 years agopep-484 for engine
Mike Bayer [Thu, 17 Feb 2022 18:43:04 +0000 (13:43 -0500)] 
pep-484 for engine

All modules in sqlalchemy.engine are strictly
typed with the exception of cursor, default, and
reflection.  cursor and default pass with non-strict
typing, reflection is waiting on the multi-reflection
refactor.

Behavioral changes:

* create_connect_args() methods return a tuple of list,
  dict, rather than a list of list, dict
* removed allow_chars parameter from
  pyodbc connector ._get_server_version_info()
  method
* the parameter list passed to do_executemany is now
  a list in all cases. previously, this was being run
  through dialect.execute_sequence_format, which
  defaults to tuple and was only intended for individual
  tuple params.
* broke up dialect.dbapi into dialect.import_dbapi
  class method and dialect.dbapi module object.  added
  a deprecation path for legacy dialects.  it's not
  really feasible to type a single attr as a classmethod
  vs. module type.  The "type_compiler" attribute also
  has this problem with greater ability to work around,
  left that one for now.
* lots of constants changing to be Enum, so that we can
  type them.  for fixed tuple-position constants in
  cursor.py / compiler.py (which are used to avoid the
  speed overhead of namedtuple), using Literal[value]
  which seems to work well
* some tightening up in Row regarding __getitem__, which
  we can do since we are on full 2.0 style result use
* altered the set_connection_execution_options and
  set_engine_execution_options event flows so that the
  dictionary of options may be mutated within the event
  hook, where it will then take effect as the actual
  options used.  Previously, changing the dict would
  be silently ignored which seems counter-intuitive
  and not very useful.
* A lot of DefaultDialect/DefaultExecutionContext
  methods and attributes, including underscored ones, move
  to interfaces.  This is not fully ideal as it means
  the Dialect/ExecutionContext interfaces aren't publicly
  subclassable directly, but their current purpose
  is more of documentation for dialect authors who should
  (and certainly are) still be subclassing the DefaultXYZ
  versions in all cases

Overall, Result was the most extremely difficult class
hierarchy to type here as this hierarchy passes through
largely amorphous "row" datatypes throughout, which
can in fact by all kinds of different things, like
raw DBAPI rows, or Row objects, or "scalar"/Any, but
at the same time these types have meaning so I tried still
maintaining some level of semantic markings for these,
it highlights how complex Result is now, as it's trying
to be extremely efficient and inlined while also being
very open-ended and extensible.

Change-Id: I98b75c0c09eab5355fc7a33ba41dd9874274f12a

3 years agotry fixing github actions again
Federico Caselli [Fri, 25 Feb 2022 21:08:09 +0000 (22:08 +0100)] 
try fixing github actions again

Change-Id: Iaf801a028510f276cf94b4999f129de8f4eb590c

3 years agorepair GH actions syntax
Mike Bayer [Fri, 25 Feb 2022 18:26:02 +0000 (13:26 -0500)] 
repair GH actions syntax

the commit in 51e6a62ab371897d646a5
included a comment that appears to not be accepted

Change-Id: I1e56293e0e75c0440073bff7190b4961cfebc353

3 years agoMerge "Add more nesting features to add_cte()" into main
mike bayer [Fri, 25 Feb 2022 17:48:30 +0000 (17:48 +0000)] 
Merge "Add more nesting features to add_cte()" into main

3 years agoMerge "Implement generic Double and related fixed types" into main
mike bayer [Fri, 25 Feb 2022 17:47:44 +0000 (17:47 +0000)] 
Merge "Implement generic Double and related fixed types" into main

3 years agoblock pypy for now
Mike Bayer [Fri, 25 Feb 2022 17:40:21 +0000 (12:40 -0500)] 
block pypy for now

the most recent pypy 7.3.8 series (3.7 and 3.9 included, likely
3.8 as well) have installed a 9 year old version of SQLite,
and additionally seem to have some other behavioral changes
like formatting of exception messages that is breaking
some tests.  as we are waiting on a response at [1]
remove pypy testing for now.

[1] https://foss.heptapod.net/pypy/pypy/-/issues/3690

Change-Id: I66650635111e71241b5c45a778954544c8d2490e

3 years agoImplement generic Double and related fixed types
zeeeeeb [Sat, 12 Feb 2022 19:00:02 +0000 (14:00 -0500)] 
Implement generic Double and related fixed types

Added :class:`.Double`, :class:`.DOUBLE`, :class:`.DOUBLE_PRECISION`
datatypes to the base ``sqlalchemy.`` module namespace, for explicit use of
double/double precision as well as generic "double" datatypes. Use
:class:`.Double` for generic support that will resolve to DOUBLE/DOUBLE
PRECISION/FLOAT as needed for different backends.

Implemented DDL and reflection support for ``FLOAT`` datatypes which
include an explicit "binary_precision" value. Using the Oracle-specific
:class:`_oracle.FLOAT` datatype, the new parameter
:paramref:`_oracle.FLOAT.binary_precision` may be specified which will
render Oracle's precision for floating point types directly. This value is
interpreted during reflection. Upon reflecting back a ``FLOAT`` datatype,
the datatype returned is one of :class:`_types.DOUBLE_PRECISION` for a
``FLOAT`` for a precision of 126 (this is also Oracle's default precision
for ``FLOAT``), :class:`_types.REAL` for a precision of 63, and
:class:`_oracle.FLOAT` for a custom precision, as per Oracle documentation.

As part of this change, the generic :paramref:`_sqltypes.Float.precision`
value is explicitly rejected when generating DDL for Oracle, as this
precision cannot be accurately converted to "binary precision"; instead, an
error message encourages the use of
:meth:`_sqltypes.TypeEngine.with_variant` so that Oracle's specific form of
precision may be chosen exactly. This is a backwards-incompatible change in
behavior, as the previous "precision" value was silently ignored for
Oracle.

Fixes: #5465
Closes: #7674
Pull-request: https://github.com/sqlalchemy/sqlalchemy/pull/7674
Pull-request-sha: 5c68419e5aee2e27bf21a8ac9eb5950d196c77e5

Change-Id: I831f4af3ee3b23fde02e8f6393c83e23dd7cd34d

3 years agoAdd more nesting features to add_cte()
Mike Bayer [Wed, 23 Feb 2022 17:24:31 +0000 (12:24 -0500)] 
Add more nesting features to add_cte()

Added new parameter :paramref:`.HasCTE.add_cte.nest_here` to
:meth:`.HasCTE.add_cte` which will "nest" a given :class:`.CTE` at the
level of the parent statement. This parameter is equivalent to using the
:paramref:`.HasCTE.cte.nesting` parameter, but may be more intuitive in
some scenarios as it allows the nesting attribute to be set simultaneously
along with the explicit level of the CTE.

The :meth:`.HasCTE.add_cte` method also accepts multiple CTE objects.

Fixes: #7759
Change-Id: I263c015f5a3f452cb54819aee12bc9bf2953a7bb

3 years agoFix invalid escape sequence in docs
Gord Thompson [Thu, 24 Feb 2022 19:07:26 +0000 (12:07 -0700)] 
Fix invalid escape sequence in docs

Current version of this code example will emit an
"invalid escape sequence" DeprecationWarning

Change-Id: Id753139b1661f78d6b3ba86b7ada181b693a562e

3 years agoMerge "support cx_Oracle DPI disconnect codes" into main
mike bayer [Thu, 24 Feb 2022 14:44:44 +0000 (14:44 +0000)] 
Merge "support cx_Oracle DPI disconnect codes" into main

3 years agoMerge "support add_cte() for TextualSelect" into main
mike bayer [Thu, 24 Feb 2022 14:42:20 +0000 (14:42 +0000)] 
Merge "support add_cte() for TextualSelect" into main

3 years agosupport cx_Oracle DPI disconnect codes
Mike Bayer [Wed, 23 Feb 2022 18:43:03 +0000 (13:43 -0500)] 
support cx_Oracle DPI disconnect codes

Added support to parse "DPI" error codes from cx_Oracle exception objects
such as ``DPI-1080`` and ``DPI-1010``, both of which now indicate a
disconnect scenario as of cx_Oracle 8.3.

Fixes: #7748
Change-Id: I4a10d606d512c0d7f9b4653c47ea5734afffb8a5

3 years agoAdd missing query before trying to print (#7665)
Mike Knudson [Wed, 23 Feb 2022 20:51:50 +0000 (13:51 -0700)] 
Add missing query before trying to print (#7665)

The documentation had a print before a query was run.

3 years agoFix signature for modified_json example (#7709)
Arthur Rio [Wed, 23 Feb 2022 20:50:25 +0000 (13:50 -0700)] 
Fix signature for modified_json example (#7709)

3 years agofix typo (#7747)
Yuki Nishimine [Wed, 23 Feb 2022 20:49:13 +0000 (05:49 +0900)] 
fix typo (#7747)

3 years agosupport add_cte() for TextualSelect
Mike Bayer [Wed, 23 Feb 2022 17:50:36 +0000 (12:50 -0500)] 
support add_cte() for TextualSelect

Fixed issue where the :meth:`.HasCTE.add_cte` method as called upon a
:class:`.TextualSelect` instance was not being accommodated by the SQL
compiler. The fix additionally adds more "SELECT"-like compiler behavior to
:class:`.TextualSelect` including that DML CTEs such as UPDATE and INSERT
may be accommodated.

Fixes: #7760
Change-Id: Id97062d882e9b2a81b8e31c2bfaa9cfc5f77d5c1

3 years agodisable pyright from pep 484
Mike Bayer [Wed, 23 Feb 2022 19:02:07 +0000 (14:02 -0500)] 
disable pyright from pep 484

new version of pyright is suddenly emitting an
error that makes no sense for a particular line of code,
breaking builds.  As we already have mypy which is generally
more conservative in its checking, disable pyright from CI
for now until it changes its behaviors less often.

Change-Id: I862de1b2c8a180df95c74c1c6dafa96d86c36ef1

3 years agoA small step toward modernizing ORM docs
Gord Thompson [Sun, 20 Feb 2022 22:02:53 +0000 (15:02 -0700)] 
A small step toward modernizing ORM docs

(as described in issue 7659)

Change-Id: I37cf4899721092c5714ed5af4cb8617b06dcd236

3 years agolimit new constructor scan thing for composites to dataclasses only
Mike Bayer [Tue, 22 Feb 2022 02:26:42 +0000 (21:26 -0500)] 
limit new constructor scan thing for composites to dataclasses only

Fixes: #7753
Change-Id: Ibf92fa34097a7d6b39dc71c72253034e314bd6a1

3 years agoundefer column name sooner to accommodate composites
Mike Bayer [Mon, 21 Feb 2022 21:56:16 +0000 (16:56 -0500)] 
undefer column name sooner to accommodate composites

This was from adding composite class introspection as a
means of determining column name, cols need to have their
normal attribute name set up already.

Fixes: #7751
Change-Id: I1fe61c135af9b1bf9bc289f683640e63bcc69045

3 years agoMerge "Revert SQLAlchemy warnings to warnings.py" into main
mike bayer [Mon, 21 Feb 2022 16:06:41 +0000 (16:06 +0000)] 
Merge "Revert SQLAlchemy warnings to warnings.py" into main

3 years agoRevert SQLAlchemy warnings to warnings.py
Federico Caselli [Sun, 20 Feb 2022 11:03:19 +0000 (12:03 +0100)] 
Revert SQLAlchemy warnings to warnings.py

Configuring the warning filters in pyproject breaks tests if
no sqlalchemy is installed in the env, since the filters are
processed before loading conftest.  It also may interfere
with coverage.

Revises Ia9715533b01f72aa5fdcf6a27ce75b76f829fa43
aba3ab247da4628e4e7baf993702e2efaccbc547

Change-Id: I51448a6a014f31d3088dce54cd20d1e683500f8c

3 years agoMerge "improve reflection of inline UNIQUE constraints" into main
mike bayer [Mon, 21 Feb 2022 02:28:57 +0000 (02:28 +0000)] 
Merge "improve reflection of inline UNIQUE constraints" into main

3 years agoimprove reflection of inline UNIQUE constraints
Mike Bayer [Sun, 20 Feb 2022 14:51:22 +0000 (09:51 -0500)] 
improve reflection of inline UNIQUE constraints

Fixed issue where SQLite unique constraint reflection would not work
for an inline UNIQUE constraint where the column name had an underscore
in its name.

Added support for reflecting SQLite inline unique constraints where
the column names are formatted with SQLite "escape quotes" ``[]``
or `` ` ``, which are discarded by the database when producing the
column name.

Fixes: #7736
Change-Id: I635003478dc27193995f7d7a6448f9333a498706

3 years agoremove never-used get_result_cursor_strategy() method
Mike Bayer [Sat, 19 Feb 2022 18:51:22 +0000 (13:51 -0500)] 
remove never-used get_result_cursor_strategy() method

This method I would assume got committed during the
1.4 engine refactor, where we moved from different kinds of
ResultProxy implementations to different strategy
classes instead.   These strategies are set up by
dialects by setting "self.cursor_fetch_strategy"
in the execution context.   The method here was
likely a previous iteration of that which got merged
but was never used.

Change-Id: Iec292428f41c2c245bf7ae78beaa14786c28846c

3 years agoupdates for mariadb connector 1.0.10
Mike Bayer [Sat, 19 Feb 2022 19:11:19 +0000 (14:11 -0500)] 
updates for mariadb connector 1.0.10

Fixed regression in mariadbconnector dialect as of mariadb connector 1.0.10
where the DBAPI no longer pre-buffers cursor.lastrowid. The dialect now
fetches this value proactively for situations where it applies.

test_invalidate_on_results seems to pass for mariadbconnector now.
the driver has likely changed how it buffers result sets.  This is
a major change for them to make in a point release so we might
want to watch this in case they reverse course again.

Fixes: #7738
Change-Id: I9610aae01d1ae42fa92ffbc7123a6948e40ec9dd

3 years agoMerge "pep-484 for pool" into main
mike bayer [Thu, 17 Feb 2022 21:40:58 +0000 (21:40 +0000)] 
Merge "pep-484 for pool" into main

3 years agoclarify SQLAlchemy version 2.0 constructs are not yet available
Mike Bayer [Thu, 17 Feb 2022 20:13:41 +0000 (15:13 -0500)] 
clarify SQLAlchemy version 2.0 constructs are not yet available

Fixes: #7726
Change-Id: I30646b9da5d4de6a075dedb4b42fd00b3ed7d969
(cherry picked from commit 86e42fbc83c78a577c1b7079f0aae7cbac5b29d5)

3 years agopep-484 for pool
Mike Bayer [Wed, 16 Feb 2022 04:43:51 +0000 (23:43 -0500)] 
pep-484 for pool

also extends into some areas of utils, events and others
as needed.

Formalizes a public hierarchy for pool API,
with ManagesConnection -> PoolProxiedConnection /
ConnectionPoolEntry for connectionfairy / connectionrecord,
which are now what's exposed in the event API and other
APIs.  all public API docs moved to the new objects.

Corrects the mypy plugin's check for sqlalchemy-stubs
not being insatlled, which has to be imported using the
dash in the name to be effective.

Change-Id: I16c2cb43b2e840d28e70a015f370a768e70f3581

3 years agoMerge "pep-484 for sqlalchemy.event; use future annotations" into main
mike bayer [Wed, 16 Feb 2022 00:15:54 +0000 (00:15 +0000)] 
Merge "pep-484 for sqlalchemy.event; use future annotations" into main

3 years agopep-484 for sqlalchemy.event; use future annotations
Mike Bayer [Sun, 13 Feb 2022 21:45:18 +0000 (16:45 -0500)] 
pep-484 for sqlalchemy.event; use future annotations

__future__.annotations mode allows us to use non-string
annotations for argument and return types in most cases,
but more importantly it removes a large amount of runtime
overhead that would be spent in evaluating the annotations.

Change-Id: I2f5b6126fe0019713fc50001be3627b664019ede
References: #6810