Commit Graph

310 Commits

Author SHA1 Message Date
Mike Bayer 8c96ae6765 Updates for examples/performance
added --sort option and also --raw option
from 6b3513f56c

Change-Id: I42ef2135db08c87f33b51faed9c8bbff510c9e9b
2020-05-25 23:24:05 -04:00
Mike Bayer d5086c4f58 Consider aliased=True, from_joinpoint as legacy
For a 1.4 / 1.3 merge, rewrite the documentation for
Query.join() to indicate calling forms that are now considered
legacy, including the use of strings in join(), sending a
series of join paths in one call, and using the aliased=True
flag.   update the elementtree examples as well to use aliased()
(they are much simpler to understand this way too) and update
other links.

Also improve docs for aliased() and some other ORM targets
such as PropComparator.

Change-Id: I636e3a9130dc5509e51c2cf60a52f38fcadffbc6
References: #4705
(cherry picked from commit 9f6b67a37e)
2020-05-04 16:04:16 -04:00
Gord Thompson 40f07675e3 Rename py.test to pytest
Change-Id: I431e1ef41e26d490343204a75a5c097768749768
(cherry picked from commit 405fc97170)
2020-04-20 09:08:18 -04:00
Albert Tugushev 30ee4263c0 Remove print statement in favor of print() function in docs and examples
<!-- Provide a general summary of your proposed changes in the Title field above -->

### Description
<!-- Describe your changes in detail -->
Remove print statements

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

- [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: #5166
Pull-request: https://github.com/sqlalchemy/sqlalchemy/pull/5166
Pull-request-sha: 04a7394f71

Change-Id: Ib90a59fac929661a18748c6e44966fb87e3978c6
(cherry picked from commit a836e3df5d)
2020-02-27 19:27:50 -05:00
Mike Bayer e48bcb599b Integrate mapper-level version_id_col with versioned_history
as the versioned_history example supplies an integer version
counter for the purposes of generating an audit trail, this
counter is also suited to be used for optimistic concurrency
detection using the version_id_col feature.   Build upon
the test that was first added in ac54ba0f2d
to provide a flag and some basic documentation.

Fixes: #2861
Change-Id: I50236beae4c49b33ada8fdcc4c524273b4e21c75
(cherry picked from commit 48b37a062a)
2020-01-10 13:19:29 -05:00
Min ho Kim 00e7a0eeae Fix typos
(cherry picked from commit 7e588aadaa)

Change-Id: Ibd2fbf365ed2b8f0d1765ef7271d28ab3a2d073a
2019-07-21 16:30:31 -04:00
Mike Bayer 8b2ad56981 Enable F841
This is a very useful assertion which prevents unused variables
from being set up allows code to be more readable and sometimes
even more efficient.  test suites seem to be where the most
problems are and there do not seem to be documentation examples
that are using this, or at least the linter is not taking effect
within rst blocks.

Change-Id: I2b3341d8dd14da34879d8425838e66a4b9f8e27d
(cherry picked from commit 190e0139e8)
2019-06-21 10:18:17 -04:00
Mike Bayer 047056157c Use py.test for versioned_history tests, nose no longer runs
without warnings under python 3

Fixes: #4697
Change-Id: I46d395d3b6642acd9317e27d6a5723ae5201e877
(cherry picked from commit 0694c7f272)
2019-05-25 09:15:37 -04:00
Mike Bayer d55b04a244 Resolve RST306 issues
The latest flake8 seems to look for these and they are in fact
correctable with a backslash.  Also need to add r to the strings
to avoid W605.

Change-Id: I8045309aa2ad29978ba7e99c45f75bc1457dff3d
(cherry picked from commit 663ed1a077)
2019-05-13 18:40:55 -04:00
Matt Schuchhardt 203de6946e Fix large_resultsets performance example field name
Fixed bug in large_resultsets example case where a re-named "id" variable
due to code reformatting caused the test to fail.  Pull request courtesy
Matt Schuchhardt.

Fixes: #4528
Closes: #4529
Pull-request: https://github.com/sqlalchemy/sqlalchemy/pull/4529
Pull-request-sha: 8f52f10422

Change-Id: Iaca6fd06ec0ede8ff1745d627708ba492a2114c8
2019-03-06 10:34:17 -05:00
Vraj Mohan 0717ce9d1d Reinstate elementtree example
Partially fixes sqlalchemy/sqlalchemy#4426.

Closes: #4441
Pull-request: https://github.com/sqlalchemy/sqlalchemy/pull/4441
Pull-request-sha: ed90f3b77c

Change-Id: Ic32e5d8020073da055b12a6aeb61e698a97dc504
2019-01-16 20:21:48 -05:00
Mike Bayer 1e278de4cc Post black reformatting
Applied on top of a pure run of black -l 79 in
I7eda77fed3d8e73df84b3651fd6cfcfe858d4dc9,  this set of changes
resolves all remaining flake8 conditions for those codes
we have enabled in setup.cfg.

Included are resolutions for all remaining flake8 issues
including shadowed builtins, long lines, import order, unused
imports, duplicate imports, and docstring issues.

Change-Id: I4f72d3ba1380dd601610ff80b8fb06a2aff8b0fe
2019-01-06 18:23:11 -05:00
Mike Bayer 1e1a38e780 Run black -l 79 against all source files
This is a straight reformat run using black as is, with no edits
applied at all.

The black run will format code consistently, however in
some cases that are prevalent in SQLAlchemy code it produces
too-long lines.   The too-long lines will be resolved in the
following commit that will resolve all remaining flake8 issues
including shadowed builtins, long lines, import order, unused
imports, duplicate imports, and docstring issues.

Change-Id: I7eda77fed3d8e73df84b3651fd6cfcfe858d4dc9
2019-01-06 17:34:50 +00:00
Mike Bayer 5851bf1138 Add versioned_update_old_row example
A modification to the "turn UPDATE into INSERT" recipe that
also UPDATEs the previous row.  The example is using timestamps
to maintain a relationship between two objects.

Change-Id: Ifdb8ee73616190384263bbe88c71d9278d616f6b
2018-12-07 14:01:23 -05:00
Mike Bayer c89729cf67 - fix formatting on examples to list the description first, some flake8
Change-Id: I57144a559f20abab02e745d052be5ff84edec7f8
2018-12-07 12:17:59 -05:00
Mike Bayer 71b01adc7b Clarify init_scalar event use case
Since I didn't even realize what this was for when reading the docs,
make it clearer that this is to mirror a Column default and remove
the extra verbiage about the mechanics of INSERTs.

Change-Id: Id2c6a29800f7b723573610e4707aec7e6ea38f5f
2018-09-06 10:44:09 -04:00
Mike Bayer a574b40929 Add Query.lazy_load_from attribute for sharding
Added new attribute :attr:`.Query.lazy_loaded_from` which is populated
with an :class:`.InstanceState` that is using this :class:`.Query` in
order to lazy load a relationship.  The rationale for this is that
it serves as a hint for the horizontal sharding feature to use, such that
the identity token of the state can be used as the default identity token
to use for the query within id_chooser().

Also repaired an issue in the :meth:`.Result.with_post_criteria`
method added in I899808734458e25a023142c2c5bb37cbed869479
for 🎫`4128` where the "unbake subquery loaders" version was calling
the post crtieria functions given the :class:`.Result` as the argument
rather than applying them to the :class:`.Query`.

Change-Id: I3c0919ce7fd151b80fe2f9b5f99f60df31c2d73d
Fixes: #4243
2018-06-04 12:30:05 -04:00
Mike Bayer 2c7f2954f7 Update dogpile.cache example to be compatible with baked query.
Updated the dogpile.caching example to include new structures that
accommodate for the "baked" query system, which is used by default within
lazy loaders and some eager relationship loaders. The dogpile.caching
"relationship_caching" and "advanced" examples were also broken due to
🎫`4256`.  The issue here is also worked-around by the fix in
🎫`4128`.

Note that this recipe requires
I3f86fcb12a6a9a89aa308b335e75c25969bcc30e in order for the
"advanced" example to work.

Change-Id: I9d35417f1d6c1906555583b8225d3da7f81736f7
Fixes: #4258
2018-05-17 12:43:44 -04:00
Mike Bayer 70f8f6a169 - modernize versioning examples
- add new example versioned_rows_w_versionid

Change-Id: I592cd5eb7db50162b4c4ad6191813d9def2b6d7c
2018-05-05 18:21:08 -04:00
Mike Bayer 7541d9b258 - add space invaders example
Change-Id: I439b6012af8c2bd8f555744657b8091ac168242b
2018-04-27 15:05:56 -04:00
Mike Bayer 50d9f1687a Add an identity_token to the identity key
For the purposes of assisting with sharded setups, add a new
member to the identity key that can be customized.  this allows
sharding across databases where the primary key space is shared.

Change-Id: Iae3909f5d4c501b62c10d0371fbceb01abda51db
Fixes: #4137
2017-12-22 11:36:53 -05:00
Mike Bayer 5329fc481e modernize and repair inheritance examples
remarkably, the examples for concrete and single were still
using classical mappings.    Ensure all three examples use
modern declarative patterns, each illustrate the identical set
of query operations.  Use back_populates, flat=True for joins,
etc. ensure flake8 linting, correct links and add a link back
from newly reworked inheritance documentation.

Change-Id: I8465a9badbb0eda804f457ccac599f051ee3c27c
2017-05-16 09:51:06 -04:00
Paul Brown a40467152c fix pep8 errors in association example
(cherry picked from commit 6aad7fb4217ef294f68f693be5b3137c28184949)
2017-03-18 14:42:48 -04:00
Paul Brown 8dad0f93e8 fix pep8 errors in adjacency_list example
(cherry picked from commit ff230f1862892eb2b479ed85e6858a82159b435f)
2017-03-18 14:42:43 -04:00
Carlos García Montoro c703b9ce89 Set autoincrement to False; use sqlite_autoincrement in versioned_history
Ensure that the history table sets autoincrement=False, since these values
are copied in all cases; the flag will emit an error as of 1.1 if the
primary key is composite.   Additionally, use the sqlite_autoincrement flag
so that SQLite uses unique primary key identifiers for new rows even if
some rows have been deleted.

Fixes: #3872
Change-Id: I65912eb394b3b69d7f4e3c098f4f948b0a7a5374
Pull-request: https://bitbucket.org/zzzeek/sqlalchemy/pull-requests/93
2017-01-09 18:00:33 -05:00
Ville Skyttä e5a063a87c spelling: Postgis -> PostGIS 2016-10-08 20:42:50 +03:00
Mike Bayer e28b448137 Add an init_scalar event for attributes
This allows us to build default-setting recipes such
as one that allows us to actively read column-level
defaults.  An example suite is also added.

Change-Id: I7b022d52cc89526132d5bc4201ac27fea4cf088d
Fixes: #1311
2016-06-02 14:41:31 -04:00
Adam Chainz 513a045395 Convert readthedocs link for their .org -> .io migration for hosted projects
As per their email ‘Changes to project subdomains’:

> Starting today, Read the Docs will start hosting projects from subdomains on the domain readthedocs.io, instead of on readthedocs.org. This change addresses some security concerns around site cookies while hosting user generated data on the same domain as our dashboard.

Test Plan: Manually visited all the links I’ve modified.
2016-05-29 14:28:55 +01:00
Mike Bayer 4cec791774 Repair dictlike-polymorphic
dictlike-polymorphic was broken by the change
in 1714e0d6ef.  Use the new
style of inheritance.

Fixes: #3704

Change-Id: I3509ef4bf7772dd6994daf600accf4a2c5eb6973
2016-05-24 16:25:53 -04:00
Mike Bayer 84ba09a7d7 Simplify directed graph example
Changed the "directed graph" example to no longer consider
integer identifiers of nodes as significant; the "higher" / "lower"
references now allow mutual edges in both directions.

Change-Id: Ibfd5b420f0451a6fc746f0bcbbbb062f8f88dc1d
Fixes: #3698
(cherry picked from commit c3de4061fd)
2016-04-26 19:01:22 -05:00
Patrick 4a3205df84 Docstring Fix
Change the docstring in short_selects example to match the code
2016-03-30 21:45:40 +01:00
Mike Bayer d57e5edbcd - Fixed two issues in the "history_meta" example where history tracking
could encounter empty history, and where a column keyed to an alternate
attribute name would fail to track properly.  Fixes courtesy
Alex Fraser.
2015-08-24 10:54:09 -04:00
Mike Bayer e3b46bd624 - Added a new extension suite :mod:sqlalchemy.ext.baked. This
simple but unusual system allows for a dramatic savings in Python
overhead for the construction and processing of orm :class:`.Query`
objects, from query construction up through rendering of a string
SQL statement.
fixes #3054
2015-03-11 20:31:11 -04:00
Mike Bayer 611d88d234 - add a callers option 2015-03-09 15:19:49 -04:00
Mike Bayer 9afe585f45 - pick around gaining modest dings in callcounts here and there 2015-03-09 14:36:23 -04:00
Mike Bayer a421106c9d - random performance whacking vs. 0.9, in particular we have to watch
for the slots-based __getattr__ thing getting hit
2015-03-08 15:32:21 -04:00
Mike Bayer a92f6662b4 - add this for testing 2015-03-08 14:43:42 -04:00
Priit Laes 8ae47dc6e0 Maul the evaulate & friends typo 2014-12-19 19:32:27 +02:00
Mike Bayer 3f1477e2ec - A new series of :class:.Session methods which provide hooks
directly into the unit of work's facility for emitting INSERT
and UPDATE statements has been created.  When used correctly,
this expert-oriented system can allow ORM-mappings to be used
to generate bulk insert and update statements batched into
executemany groups, allowing the statements to proceed at
speeds that rival direct use of the Core.
fixes #3100
2014-12-08 01:10:30 -05:00
Mike Bayer 1b260c7959 Merge branch 'master' into ticket_3100 2014-12-07 17:48:32 -05:00
Mike Bayer de62497b03 - Updated the :ref:examples_versioned_history example such that
mapped columns are re-mapped to
match column names as well as grouping of columns; in particular,
this allows columns that are explicitly grouped in a same-column-named
joined inheritance scenario to be mapped in the same way in the
history mappings, avoiding warnings added in the 0.9 series
regarding this pattern and allowing the same view of attribute
keys.
2014-11-26 14:58:44 -05:00
Mike Bayer a88be57fb7 - formatting 2014-11-26 14:58:32 -05:00
Mike Bayer 2098001ad3 - Fixed a bug in the examples/generic_assocaitions/discriminator_on_association.py
example, where the subclasses of AddressAssociation were not being
mapped as "single table inheritance", leading to problems when trying
to use the mappings further.
2014-11-24 12:33:56 -05:00
Mike Bayer 0c19d765dc bulk_updates 2014-11-06 17:31:14 -05:00
Mike Bayer b9d430af75 - add differentiating examples of list() vs. iteration 2014-09-16 11:57:03 -04:00
Mike Bayer fa7c8f8811 - try to finish up the performance example for now 2014-09-06 13:01:21 -04:00
Mike Bayer d2c05c36a5 - add a test that shows query caching. 2014-09-04 20:55:38 -04:00
Mike Bayer eb81531275 tweak 2014-09-03 20:30:52 -04:00
Mike Bayer cbef6a7d58 refine 2014-09-03 20:07:08 -04:00
Mike Bayer 84d4651f3d Merge branch 'master' into ticket_3100 2014-09-03 19:44:40 -04:00