summaryrefslogtreecommitdiff
path: root/lib/sqlalchemy
Commit message (Collapse)AuthorAgeFilesLines
* Merge "test single and double quote inspection scenarios"2020_tutorialmike bayer2020-07-134-20/+166
|\
| * test single and double quote inspection scenariosMike Bayer2020-07-134-20/+166
| | | | | | | | | | | | | | | | | | | | | | Applied a sweep through all included dialects to ensure names that contain single or double quotes are properly escaped when querying system tables, for all :class:`.Inspector` methods that accept object names as an argument (e.g. table names, view names, etc). SQLite and MSSQL contained two quoting issues that were repaired. Fixes: #5456 Change-Id: I3bc98806f5166f3d82275650079ff561446f2aef
* | Merge "more docs for autocommit isolation level"mike bayer2020-07-136-14/+25
|\ \
| * | more docs for autocommit isolation levelMike Bayer2020-07-126-14/+25
| |/ | | | | | | | | | | | | | | this concept is not clear that we offer real DBAPI autocommit everywhere. backport 1.3 with edits as well Change-Id: I2e8328b7fb6e1cdc5453ab29c94276f60c7ca149
* | Merge "Make call-count profiling tests on osx have their own platform key"mike bayer2020-07-133-0/+5
|\ \ | |/ |/|
| * Make call-count profiling tests on osx have their own platform keyFederico Caselli2020-07-113-0/+5
| | | | | | | | | | | | | | They previously would use the linux profiles, but recently some discrepancies in the function call count on osx would make the tests fail. Change-Id: Ifdfdca1676972de4179f59cdaae196f6805d4a21
* | Further corrections to session docsMike Bayer2020-07-111-79/+54
| | | | | | | | | | | | | | | | | | | | | | many more to come. One issue is that references to documentation sections inside of decorator-configured deprecation warnings will also generate a meaningless token when the runtime warning is emitted. It would be nice to improve upon this somehow. Change-Id: I16b214b3d310850bbfb0d9ade70235f5a9735eba
* | Merge "Convert remaining ORM APIs to support 2.0 style"mike bayer2020-07-1118-836/+1230
|\ \ | |/ |/|
| * Convert remaining ORM APIs to support 2.0 styleMike Bayer2020-07-1118-836/+1230
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This is kind of a mixed bag of all kinds to help get us to 1.4 betas. The documentation stuff is a work in progress. Lots of other relatively small changes to APIs and things. More commits will follow to continue improving the documentation and transitioning to the 1.4/2.0 hybrid documentation. In particular some refinements to Session usage models so that it can match Engine's scoping / transactional patterns, and a decision to start moving away from "subtransactions" completely. * add select().from_statement() to produce FromStatement in an ORM context * begin referring to select() that has "plugins" for the few edge cases where select() will have ORM-only behaviors * convert dynamic.AppenderQuery to its own object that can use select(), though at the moment it uses Query to support legacy join calling forms. * custom query classes for AppenderQuery are replaced by do_orm_execute() hooks for custom actions, a separate gerrit will document this * add Session.get() to replace query.get() * Deprecate session.begin->subtransaction. propose within the test suite a hypothetical recipe for apps that rely on this pattern * introduce Session construction level context manager, sessionmaker context manager, rewrite the whole top of the session_transaction.rst documentation. Establish context manager patterns for Session that are identical to engine * ensure same begin_nested() / commit() behavior as engine * devise all new "join into an external transaction" recipe, add test support for it, add rules into Session so it just works, write new docs. need to ensure this doesn't break anything * vastly reduce the verbosity of lots of session docs as I dont think people read this stuff and it's difficult to keep current in any case * constructs like case(), with_only_columns() really need to move to *columns, add a coercion rule to just change these. * docs need changes everywhere I look. in_() is not in the Core tutorial? how do people even know about it? Remove tons of cruft from Select docs, etc. * build a system for common ORM options like populate_existing and autoflush to populate from execution options. * others? Change-Id: Ia4bea0f804250e54d90b3884cf8aab8b66b82ecf
* | Merge "Improvements to test_computed_col_default_not_set"mike bayer2020-07-091-6/+5
|\ \
| * | Improvements to test_computed_col_default_not_setRafi Shamim2020-07-091-6/+5
| |/ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | <!-- Provide a general summary of your proposed changes in the Title field above --> ### Description <!-- Describe your changes in detail --> - Update the test so it looks at computed_default_table instead of computed_column_table. - Stop inspecting autoincrement; instead directly check for default/non-default values for the relevant columns. Fixes: #5414 ### 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 - [x] 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: #5417 Pull-request: https://github.com/sqlalchemy/sqlalchemy/pull/5417 Pull-request-sha: 5918af6abb991e6d2322ea4252e56d456da628dc Change-Id: Id9484ae7f297735345016be5b7461325825503da
* | Limit init_subclass test above python 3.6Mike Bayer2020-07-081-0/+7
|/ | | | | | | | The commit for I1654befe9eb1c8b8e7fc0784bdbe64284614f0ea #5357 runs the test on all Python 3 versions, however we need to limit at least python 3.6 for this. Change-Id: Ie86b78bbfd8c7bd013ff9aa7f8905328d792c1b3
* Merge remote-tracking branch 'origin/pr/5439'Mike Bayer2020-07-081-0/+3
|\ | | | | | | Change-Id: Ibab5889b14c546a8c43c5eaf88ed5d1f53713880
| * resolves #3757RamonWill2020-07-041-0/+3
| |
* | Merge "Add future=True to create_engine/Session; unify select()"mike bayer2020-07-0824-421/+661
|\ \
| * | Add future=True to create_engine/Session; unify select()Mike Bayer2020-07-0824-421/+661
| |/ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Several weeks of using the future_select() construct has led to the proposal there be just one select() construct again which features the new join() method, and otherwise accepts both the 1.x and 2.x argument styles. This would make migration simpler and reduce confusion. However, confusion may be increased by the fact that select().join() is different Current thinking is we may be better off with a few hard behavioral changes to old and relatively unknown APIs rather than trying to play both sides within two extremely similar but subtly different APIs. At the moment, the .join() thing seems to be the only behavioral change that occurs without the user taking any explicit steps. Session.execute() will still behave the old way as we are adding a future flag. This change also adds the "future" flag to Session() and session.execute(), so that interpretation of the incoming statement, as well as that the new style result is returned, does not occur for existing applications unless they add the use of this flag. The change in general is moving the "removed in 2.0" system further along where we want the test suite to fully pass even if the SQLALCHEMY_WARN_20 flag is set. Get many tests to pass when SQLALCHEMY_WARN_20 is set; this should be ongoing after this patch merges. Improve the RemovedIn20 warning; these are all deprecated "since" 1.4, so ensure that's what the messages read. Make sure the inforamtion link is on all warnings. Add deprecation warnings for parameters present and add warnings to all FromClause.select() types of methods. Fixes: #5379 Fixes: #5284 Change-Id: I765a0b912b3dcd0e995426427d8bb7997cbffd51 References: #5159
* | Merge "ensure we unwrap desc() /label() all the way w/ order by"mike bayer2020-07-071-1/+19
|\ \
| * | ensure we unwrap desc() /label() all the way w/ order byMike Bayer2020-07-071-1/+19
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The deprecated logic to move order_by expressions up into the columns clause needed adjustment to accommodate for a more deeply-wrapped structure when desc() + label() are combined in an order by column. This structure now comes from coercions in 1.4. it's not clear to me at the moment why it's different from 1.3 but this shouldn't really matter. Fixes: #5443 Change-Id: If909a86f715992318d7aa283603197f7711f1d3b
* | | Merge "Add **kw support to DeclarativeMeta.__init__"mike bayer2020-07-071-1/+1
|\ \ \ | |/ / |/| |
| * | Add **kw support to DeclarativeMeta.__init__EwenGillies2020-07-061-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Added a ``**kw`` argument to the :meth:`.DeclarativeMeta.__init__` method. This allows a class to support the :pep:`487` metaclass hook ``__init_subclass__``. Pull request courtesy Ewen Gillies. Fixes: #5357 Closes: #5363 Pull-request: https://github.com/sqlalchemy/sqlalchemy/pull/5363 Pull-request-sha: 0ad05a768316cba03a4d312ab39d3e8fbca7ac54 Change-Id: I1654befe9eb1c8b8e7fc0784bdbe64284614f0ea
* | | Merge "added semicolon (;) to improve warning message clarity"mike bayer2020-07-061-1/+1
|\ \ \
| * | | added semicolon (;) to improve warning message clarityjonathan vanasco2020-06-301-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | ### Description Added a semicolon to improve the clarity of warning message. I actually had a table named `backend`, and thought it was involved! While updating the code, I noticed no test that directly tests for this warning message. There are tests for the `Can't sort tables for DROP;` prefix of this message and the `exc.CircularDependencyError`; and some tests for the `exc.CircularDependencyError` message itself. I couldn't find any test for this particular message though. (Just thought I'd bring that up) No issue created, because this is minor. Closes: #5431 Pull-request: https://github.com/sqlalchemy/sqlalchemy/pull/5431 Pull-request-sha: 87fb5733ff4fc1a13dd94277716814ea852f654c Change-Id: I87a504d30a7dd5155c34f7d7f30b2116d0d3cd3f
* | | | Ensure synchronize_session works with lambda statementsMike Bayer2020-07-051-6/+31
| |/ / |/| | | | | | | | | | | | | | | | | | | | | | | | | | | | | A few places have logic that assumes the top-level statement is the actual UPDATE or DELETE which is not the case with a lambda. Ensure the correct object is used. This fixes issues specific to both "fetch" strategy as well as "evaluate" strategy. Fixes: #5442 Change-Id: Ic9cc01c696c3c338d5bc79688507e6717c4c169b
* | | Document pyodbc built-in poolingMike Bayer2020-07-051-0/+26
| |/ |/| | | | | | | | | | | | | | | PyODBC apparently pools connections by default and this is a module-wide setting only. Documenent that this happens and how to disable it. Fixes: #5440 Change-Id: I415bda7beb2211c66991b6c804b0ddb4d79e427f
* | introduce deferred lambdasMike Bayer2020-07-0321-103/+884
|/ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The coercions system allows us to add in lambdas as arguments to Core and ORM elements without changing them at all. By allowing the lambda to produce a deterministic cache key where we can also cheat and yank out literal parameters means we can move towards having 90% of "baked" functionality in a clearer way right in Core / ORM. As a second step, we can have whole statements inside the lambda, and can then add generation with __add__(), so then we have 100% of "baked" functionality with full support of ad-hoc literal values. Adds some more short_selects tests for the moment for comparison. Other tweaks inside cache key generation as we're trying to approach a certain level of performance such that we can remove the use of "baked" from the loader strategies. As we have not yet closed #4639, however the caching feature has been fully integrated as of b0cfa7379cf8513a821a3dbe3028c4965d9f85bd, we will also add complete caching documentation here and close that issue as well. Closes: #4639 Fixes: #5380 Change-Id: If91f61527236fd4d7ae3cad1f24c38be921c90ba
* Merge "Rename Table.tometadata to to_metadata"mike bayer2020-06-294-18/+72
|\
| * Rename Table.tometadata to to_metadataGord Thompson2020-06-294-18/+72
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Renamed the :meth:`_schema.Table.tometadata` method to :meth:`_schema.Table.to_metadata`. The previous name remains with a deprecation warning. Updated the "decorate" utility function to support decoration of functions that include non-builtins as default values. Moves test for deprecated "databases" package into test/dialect/test_deprecations.py Fixes: #5413 Fixes: #5426 Change-Id: I6ed899871c935f9e46360127c17ccb7cf97cea6e
* | Include DATETIME / DateTime with the MySQL TIMESTAMP examplesMike Bayer2020-06-291-3/+22
| | | | | | | | | | | | | | | | | | To eliminate any remaining confusion, clarify that DATETIME (as well as DateTime) and TIMESTAMP are treated similarly with the MySQL dialect regarding ON UPDATE. Change-Id: I222522440706902d5d2d11e670e76f16000438e0 References: #5427
* | Merge "Remove _generate_path_cache_key()"mike bayer2020-06-293-129/+7
|\ \
| * | Remove _generate_path_cache_key()Mike Bayer2020-06-293-129/+7
| |/ | | | | | | | | | | | | | | | | | | loader options can now make a deterministic cache key based on the structure they are given, and this accommodates for aliased classes as well so that these cache keys are now "safe". Have baked query call upon the regular cache key method. Change-Id: Iaa2ef4064cfb16146f415ca73080f32003dd830d
* | Merge "Provide example for exists"mike bayer2020-06-291-1/+9
|\ \
| * | Provide example for existsFederico Caselli2020-06-271-1/+9
| | | | | | | | | | | | | | | | | | Fixes: #5423 Change-Id: I716f8de17c49d7eefbbce5ddd9da203bfc9fe47f
* | | Docuemnt current workarounds for MySQL TIMESTAMPMike Bayer2020-06-292-1/+73
| |/ |/| | | | | | | | | | | | | | | | | | | MySQL 8 no longer generates the DEFAULT or ON UPDATE clauses for TIMESTAMP by default, hence users will begin to hit this regularly. add warnings that this non-standard SQL is not accommodated by server_onupdate and docuemnt the workaround used in issues such as #4652. Fixes: #5427 Change-Id: Ie048dcc91c648dd0b80ed395208c1d665b6c968b
* | Merge "ORM executemany returning"mike bayer2020-06-286-49/+156
|\ \ | |/ |/|
| * ORM executemany returningMike Bayer2020-06-276-49/+156
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Build on #5401 to allow the ORM to take advanage of executemany INSERT + RETURNING. Implemented the feature updated tests to support INSERT DEFAULT VALUES, needed to come up with a new syntax for compiler INSERT INTO table (anycol) VALUES (DEFAULT) which can then be iterated out for executemany. Added graceful degrade to plain executemany for PostgreSQL <= 8.2 Renamed EXECUTEMANY_DEFAULT to EXECUTEMANY_PLAIN Fix issue where unicode identifiers or parameter names wouldn't work with execute_values() under Py2K, because we have to encode the statement and therefore have to encode the insert_single_values_expr too. Correct issue from #5401 to support executemany + return_defaults for a PK that is explicitly pre-generated, meaning we aren't actually getting RETURNING but need to return it from compiled_parameters. Fixes: #5263 Change-Id: Id68e5c158c4f9ebc33b61c06a448907921c2a657
* | Merge "Fix a wide variety of typos and broken links"mike bayer2020-06-2649-444/+462
|\ \ | |/ |/|
| * Fix a wide variety of typos and broken linksaplatkouski2020-06-2549-444/+462
| | | | | | | | | | | | | | | | | | | | | | | | Note the PR has a few remaining doc linking issues listed in the comment that must be addressed separately. Signed-off-by: aplatkouski <5857672+aplatkouski@users.noreply.github.com> Closes: #5371 Pull-request: https://github.com/sqlalchemy/sqlalchemy/pull/5371 Pull-request-sha: 7e7d233cf3a0c66980c27db0fcdb3c7d93bc2510 Change-Id: I9c36e8d8804483950db4b42c38ee456e384c59e3
* | Merge "Default psycopg2 executemany mode to "values_only""mike bayer2020-06-2614-241/+373
|\ \ | |/ |/|
| * Default psycopg2 executemany mode to "values_only"Mike Bayer2020-06-2514-241/+373
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The psycopg2 dialect now defaults to using the very performant ``execute_values()`` psycopg2 extension for compiled INSERT statements, and also impements RETURNING support when this extension is used. This allows INSERT statements that even include an autoincremented SERIAL or IDENTITY value to run very fast while still being able to return the newly generated primary key values. The ORM will then integrate this new feature in a separate change. Implements RETURNING for insert with executemany Adds support to return_defaults() mode and inserted_primary_key to support mutiple INSERTed rows, via return_defauls_rows and inserted_primary_key_rows accessors. within default execution context, new cached compiler getters are used to fetch primary keys from rows inserted_primary_key now returns a plain tuple. this is not yet a row-like object however this can be added. Adds distinct "values_only" and "batch" modes, as "values" has a lot of benefits but "batch" breaks cursor.rowcount psycopg2 minimum version 2.7 so we can remove the large number of checks for very old versions of psycopg2 simplify tests to no longer distinguish between native and non-native json Fixes: #5401 Change-Id: Ic08fd3423d4c5d16ca50994460c0c234868bd61c
* | Merge "Use index name to determine if an index is for the PK"mike bayer2020-06-251-14/+15
|\ \
| * | Use index name to determine if an index is for the PKMike Bayer2020-06-251-14/+15
| |/ | | | | | | | | | | | | | | | | | | | | | | Fixed bug in Oracle dialect where indexes that contain the full set of primary key columns would be mistaken as the primary key index itself, which is omitted, even if there were multiples. The check has been refined to compare the name of the primary key constraint against the index name itself, rather than trying to guess based on the columns present in the index. Fixes: #5421 Change-Id: I47c2ccdd0b13977cfd9ef249d4de06371c4fb241
* | Use time.perf_counter() for cache time measurementMike Bayer2020-06-244-4/+5
|/ | | | | | See https://twitter.com/raymondh/status/1275937373080023040 Change-Id: Iaa0abb0c433ccedfbd88d00e3970120242ba379b
* Propose using RETURNING for bulk updates, deletesMike Bayer2020-06-2311-101/+360
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This patch makes several improvements in the area of bulk updates and deletes as well as the new session mechanics. RETURNING is now used for an UPDATE or DELETE statement emitted for a diaelct that supports "full returning" in order to satisfy the "fetch" strategy; this currently includes PostgreSQL and SQL Server. The Oracle dialect does not support RETURNING for more than one row, so a new dialect capability "full_returning" is added in addition to the existing "implicit_returning", indicating this dialect supports RETURNING for zero or more rows, not just a single identity row. The "fetch" strategy will gracefully degrade to the previous SELECT mechanics for dialects that do not support RETURNING. Additionally, the "fetch" strategy will attempt to use evaluation for the VALUES that were UPDATEd, rather than just expiring the updated attributes. Values should be evalutable in all cases where the value is not a SQL expression. The new approach also incurs some changes in the session.execute mechanics, where do_orm_execute() event handlers can now be chained to each return results; this is in turn used by the handler to detect on a per-bind basis if the fetch strategy needs to do a SELECT or if it can do RETURNING. A test suite is added to test_horizontal_shard that breaks up a single UPDATE or DELETE operation among multiple backends where some are SQLite and don't support RETURNING and others are PostgreSQL and do. The session event mechanics are corrected in terms of the "orm pre execute" hook, which now receives a flag "is_reentrant" so that the two ORM implementations for this can skip on their work if they are being called inside of ORMExecuteState.invoke(), where previously bulk update/delete were calling its SELECT a second time. In order for "fetch" to get the correct identity when called as pre-execute, it also requests the identity_token for each mapped instance which is now added as an optional capability of a SELECT for ORM columns. the identity_token that's placed by horizontal_sharding is now made available within each result row, so that even when fetching a merged result of plain rows we can tell which row belongs to which identity token. The evaluator that takes place within the ORM bulk update and delete for synchronize_session="evaluate" now supports the IN and NOT IN operators. Tuple IN is also supported. Fixes: #1653 Change-Id: I2292b56ae004b997cef0ba4d3fc350ae1dd5efc1
* Merge "Apply dialect_options copy fix"mike bayer2020-06-201-3/+29
|\
| * Apply dialect_options copy fixGord Thompson2020-06-181-3/+29
| | | | | | | | | | Fixes: #5276 Change-Id: Ic608310d4a85934fc9fa4d72daef66323c6e2525
* | Merge "Added reflection method :meth:`.Inspector.get_sequence_names`"mike bayer2020-06-198-85/+219
|\ \
| * | Added reflection method :meth:`.Inspector.get_sequence_names`Federico Caselli2020-06-038-85/+219
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Added new reflection method :meth:`.Inspector.get_sequence_names` which returns all the sequences defined. Support for this method has been added to the backend that support :class:`.Sequence`: PostgreSql, Oracle, MSSQL and MariaDB >= 10.3. Fixes: #2056 Change-Id: I0949696a39aa28c849edf2504779241f7443778a
* | | Merge "perf tweaks"mike bayer2020-06-194-49/+59
|\ \ \
| * | | perf tweaksMike Bayer2020-06-194-49/+59
| | |/ | |/| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | - avoid abc checks in distill_20 - ColumnEntity subclasses are unique to their compile state and have no querycontext specific state. They can do a simple memoize of their fetch_column without using attributes, and they can memoize their _getter() too so that it goes into the cache, just like instance_processor() does. - unify ORMColumnEntity and RawColumnEntity for the row processor part, add some test coverage for the case where it is used in a from_statement - do a faster generate if there are no memoized entries - query._params is always immutabledict Change-Id: I1e2dfe607a1749b5b434fc11f9348ee631501dfa
* | | Add note indicating order of join() calls are importantMike Bayer2020-06-191-0/+13
|/ / | | | | | | | | Fixes: #5406 Change-Id: I186792b32bd156d5ddf256dcd018af32ad5b515e