Commit Graph

278 Commits

Author SHA1 Message Date
Mike Bayer aed2324b4d Add multivalued insert context for defaults
Added a new method :class:`.DefaultExecutionContext.current_parameters`
which is used within a function-based default value generator in
order to retrieve the current parameters being passed to the statement.
The new function differs from the ``.current_parameters`` attribute in
that it also provides for optional grouping of parameters that
correspond to a multi-valued "insert" construct.  Previously it was not
possible to identify the subset of parameters that were relevant to
the function call.

Change-Id: I6894c7b4a2bce3e83c3ade8af0e5b2f8df37b785
Fixes: #4075
2017-09-16 12:52:25 -04:00
Mike Bayer 919b8bc4ac Ensure custom ops have consistent typing behavior, boolean support
Refined the behavior of :meth:`.Operators.op` such that in all cases,
if the :paramref:`.Operators.op.is_comparison` flag is set to True,
the return type of the resulting expression will be
:class:`.Boolean`, and if the flag is False, the return type of the
resulting expression will be the same type as that of the left-hand
expression, which is the typical default behavior of other operators.
Also added a new parameter :paramref:`.Operators.op.return_type` as well
as a helper method :meth:`.Operators.bool_op`.

Change-Id: Ifc8553cd4037d741b84b70a9702cbd530f1a9de0
Fixes: #4063
2017-09-01 12:34:41 -04:00
Mike Bayer 56845d8cc2 include a note about the importance of type coerce for custom ops
Change-Id: Ia7dab65523d6a34fcc92ee785ffe03f7e2a33cfd
2017-09-01 10:52:16 -04:00
Mike Bayer 2db5256143 - modernize the mysql connection timeout docs
Change-Id: Icb0474509539c1eb7536544749f2a48b4972078a
(cherry picked from commit 4ce46fb0a085c1cc739e21881cc25567e663f8dc)
2017-08-22 16:52:10 -04:00
Mike Bayer a66979fe1e - remove intersphinx usage, the overhead of re-fetching
inventory on every build not worth it

Change-Id: I3c4506b246d0f327c4b56afa723975daee984476
2017-07-09 13:02:59 -04:00
Michael Birtwell f8a3f14e4f Flatten operator precedence for comparison operators
The operator precedence for all comparison operators such as LIKE, IS,
IN, MATCH, equals, greater than, less than, etc. has all been merged
into one level, so that expressions which make use of these against
each other will produce parentheses between them.   This suits the
stated operator precedence of databases like Oracle, MySQL and others
which place all of these operators as equal precedence, as well as
Postgresql as of 9.5 which has also flattened its operator precendence.

Co-authored-by: Mike Bayer <mike_mp@zzzcomputing.com>
Fixes: #3999
Change-Id: I3f3d5124a64af0d376361cdf15a97e2e703be56f
Pull-request: https://github.com/zzzeek/sqlalchemy/pull/367
2017-05-25 16:02:13 -04:00
Kataev Denis 42b6ef8ccd Repair formatting throughout documentation
1. Section decorators to [one style](http://docutils.sourceforge.net/docs/ref/rst/restructuredtext.html#sections):
without inset at both side and with same length as text.
2. Fix broken [reference](http://docs.sqlalchemy.org/en/latest/core/type_basics.html#generic-types).
3. Convert tabs to space in some small files.
4. Some python code snippets have python+sql syntax hint.

Change-Id: I39a7a41ef0b0591c6bf1e610748e2b5c19fc5379
Pull-request: https://github.com/zzzeek/sqlalchemy/pull/361
2017-05-22 17:53:09 -04:00
Mike Bayer 7aa50b9b19 - fix broken link
Change-Id: I2f3b5ae29600696b34a6afdddc2f94920febf31d
2017-05-16 09:59:38 -04:00
Mike Bayer 654514c5b2 - big rewrite of the Sequence documentation:
1. Sequence should be associated with MetaData always,
except in the really weird case someone is sharing a Sequence
among multiple metadatas.  Make this a "best practice", end the
confusion of #3951, #3979

2. "optional" is not a thing people use, trim this way down

3. remove confusing language

Change-Id: Iab5aec319da2582092fe2615ee50430f76441aff
(cherry picked from commit a1dcf23e371695d8d3be2e1d7875fad10f16a656)
2017-05-05 15:05:20 -04:00
Mike Bayer 86ef507cc7 Double percent signs based on paramstyle, not dialect
This patch moves the "doubling" of percent signs into
the base compiler and makes it completely a product
of whether or not the paramstyle is format/pyformat or
not.   Without this paramstyle, percent signs
are not doubled across text(), literal_column(), and
column().

Change-Id: Ie2f278ab1dbb94b5078f85c0096d74dbfa049197
Fixes: #3740
2017-04-05 12:18:36 -04:00
Mike Bayer f881dae817 Integrate "pre-ping" into connection pool.
Added native "pessimistic disconnection" handling to the :class:`.Pool`
object.  The new parameter :paramref:`.Pool.pre_ping`, available from
the engine as :paramref:`.create_engine.pool_pre_ping`, applies an
efficient form of the "pre-ping" recipe featured in the pooling
documentation, which upon each connection check out, emits a simple
statement, typically "SELECT 1", to test the connection for liveness.
If the existing connection is no longer able to respond to commands,
the connection is transparently recycled, and all other connections
made prior to the current timestamp are invalidated.

Change-Id: I89700d0075e60abd2250e54b9bd14daf03c71c00
Fixes: #3919
2017-03-20 18:01:23 -04:00
Jamie Alessio 3771af0af4 Fix typos ('expicit' -> 'explicit') 2017-03-14 19:04:03 -07:00
Mike Bayer 1da9d37521 - bump minimum python version to 2.7
- add placeholder 1.2 release documentation, update intro numbers

Change-Id: I9f9969cbb9e95c2f750a5c16798e92c35a5ef6cf
2017-03-10 14:28:49 -05:00
Mike Bayer 74bec18c2a - document ForeignKeyConstraint columns / elements, fixes #2904
Change-Id: Ia50a3100d1bd88020c30224932b16aeadd7f4c75
2017-03-07 14:54:53 -05:00
Mike Bayer 5c26cfcb47 - cte() has moved to HasCTE(), since SelectBase is referred to
a lot just add inherited members so links to things like SelectBase.cte
continue to function

Change-Id: Ib57948d576d2063e10b0f528a5deaf07ea262322
2017-01-28 09:43:40 -05:00
Mike Bayer 0cc5561c93 Merge branch 'fix-example-re' of https://github.com/demoray/sqlalchemy 2017-01-24 17:33:01 -05:00
Mike Bayer 42027de3fc Improve server-side Sequence documentation
Include the metadata argument for the Sequence
and explain the rationale.  Correct inconsistencies
between Core / ORM examples and update language
regarding client side vs. server side Sequence
directive.

Co-authored-by: Stéphane Raimbault <stephane.raimbault@gmail.com>
Change-Id: I65c522acf9bdf25041a5baf2e10be41f0927999a
Pull-request: https://github.com/zzzeek/sqlalchemy/pull/341
2017-01-19 14:43:13 -05:00
Brian 3c0fc9b95f fix example re such that the listen modifier example works 2016-12-17 12:09:13 -05:00
Mike Bayer f9432a0287 Remove the use of the word "fundamental" to describe ColumnElements
The context is unclear if "fundamental" refers to the object's
role within a SELECT composition or within the class hierarchy
of ClauseElement classes.

Change-Id: I10bbf324fc09034cc27398867b7eca6b6f127abe
Fixes: #3793
2016-10-17 12:35:26 -04:00
Ville Skyttä e5a063a87c spelling: Postgis -> PostGIS 2016-10-08 20:42:50 +03:00
Ville Skyttä 8c2c464cb8 spelling: Postgresql -> PostgreSQL 2016-10-08 20:42:50 +03:00
Ville Skyttä e47063bfe0 Spelling fixes 2016-10-08 20:42:50 +03:00
Mike Bayer 9bfd028938 - some documentation hits
Change-Id: I468fe70168804b08cf0d5e8b57e235bca904b1ff
2016-10-01 09:42:21 -04:00
Mike Bayer 0cc8267286 - clarify documentation on timezone flag, since Oracle has both
DATE / TIMESTAMP separately the timezone flag will not bump the
type to TIMESTAMP WITH TIMEZONE on that backend.

Change-Id: I185992093472e1620b8cf84872631a4d48f8edc3
2016-09-22 11:08:09 -04:00
Mike Bayer b33caa6418 Add additional documentation re: JSONEncodedDict
Add an example of how to use coerce_compared_value()
specific to JSONEncodedDict, as this example class
is frequently dropped into applications.

Change-Id: I61639ac03dc5a37673ee8201b99a3c36ab944f00
Fixes: #3742
2016-07-07 16:00:18 -04:00
Kristian Perkins ae13473895 fixed typo 2016-07-03 13:59:47 +10:00
Mike Bayer 13f9578082 - update alembic link
Change-Id: I5ac6ba8234873fdd19bee6c1decd311a9cb4d55e
2016-06-18 09:35:54 -04:00
mike bayer 5c80400ec7 Merge "Add TABLESAMPLE clause support." 2016-06-15 15:17:10 -04:00
saarni 20f2f5b169 Add TABLESAMPLE clause support.
The TABLESAMPLE clause allows randomly selecting an approximate percentage
of rows from a table. At least DB2, Microsoft SQL Server and recent
Postgresql support this standard clause.

Fixes: #3718
Change-Id: I3fb8b9223e12a57100df30876b461884c58d72fa
Pull-request: https://github.com/zzzeek/sqlalchemy/pull/277
2016-06-15 14:42:08 -04:00
Mike Bayer 51e4512abd Interpret lateral, alias as from clauses
Also add doc members for Lateral.

Change-Id: Ic801c296377ce84230139c6a43ecb3e93a852832
2016-06-15 14:36:24 -04:00
Phillip Cloud d34063aa32 Support range specification in window function
Fixes: #3049
Co-authored-by: Mike Bayer <mike_mp@zzzcomputing.com>
Change-Id: Ie572095c3e25f70a1e72e1af6858e5edd89fd25e
Pull-request: https://github.com/zzzeek/sqlalchemy/pull/264
2016-06-07 15:17:22 -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 c124fa36d5 Support "blank" schema when MetaData.schema is set
Previously, it was impossible to have a Table that has
None for a schema name when the "schema" parameter on
MetaData was set.  A new symbol sqlalchemy.schema.BLANK_SCHEMA
is added which indicates that the schema name should unconditionally
be set to None.  In particular, this value must be passed within
cross-schema foreign key reflection, so that a Table which
is in the "default" schema can be represented properly.

Fixes: #3716
Change-Id: I3d24f99c22cded206c5379fd32a225e74edb7a8e
2016-05-18 11:43:38 -04:00
Mike Bayer 7f08d8c93a Add close_with_result to pessimistic connection example
For connectionless execution, the recipe here will fail unless
the should_close_with_result flag is temporarily set to False.

Change-Id: Ib77b4439e8361b24478108c413b1ba720a68350f
Fixes: #3712
2016-05-12 07:54:14 -04:00
Jeffrey Finkelstein c31833e997 Adds parentheses around print statements in docs. 2016-05-03 21:02:29 -04:00
Mike Bayer fb9d481e89 - Added :meth:.Select.lateral and related constructs to allow
for the SQL standard LATERAL keyword, currently only supported
by Postgresql.  fixes #2857
2016-03-29 17:56:02 -04:00
Mike Bayer e5f1a3fb7d - CTE functionality has been expanded to support all DML, allowing
INSERT, UPDATE, and DELETE statements to both specify their own
WITH clause, as well as for these statements themselves to be
CTE expressions when they include a RETURNING clause.
fixes #2551
2016-02-11 12:27:28 -05:00
Ruilin Huang 4b9f6f407c fix %x string format to compatible with Python 3.5 2016-01-27 08:21:59 +00:00
xghrl 324e532d60 fix %x string format to compatible with Python 3.5 2016-01-27 08:10:06 +00:00
Mike Bayer 1f7a1f777d - A deep improvement to the recently added :meth:.TextClause.columns
method, and its interaction with result-row processing, now allows
the columns passed to the method to be positionally matched with the
result columns in the statement, rather than matching on name alone.
The advantage to this includes that when linking a textual SQL statement
to an ORM or Core table model, no system of labeling or de-duping of
common column names needs to occur, which also means there's no need
to worry about how label names match to ORM columns and so-forth.  In
addition, the :class:`.ResultProxy` has been further enhanced to
map column and string keys to a row with greater precision in some
cases.  fixes #3501
- reorganize the initialization of ResultMetaData for readability
and complexity; use the name "cursor_description", define the
task of "merging" cursor_description with compiled column information
as its own function, and also define "name extraction" as a separate task.
- fully change the name we use in the "ambiguous column" error to be the
actual name that was ambiguous, modify the C ext also
2016-01-14 18:06:26 -05:00
Mike Bayer d03477d4b7 - fix link to types in metadata, fixes #3618
- fix "version" got whacked into "f" in core tutorial
- fix short underline in automap
- fix unmatched boldface in session events
2016-01-10 11:48:53 -05:00
Mike Bayer ddba8b0e7f Merge remote-tracking branch 'origin/pr/225' 2016-01-10 10:31:51 -05:00
Mike Bayer 89facbed88 - Multi-tenancy schema translation for :class:.Table objects is added.
This supports the use case of an application that uses the same set of
:class:`.Table` objects in many schemas, such as schema-per-user.
A new execution option
:paramref:`.Connection.execution_options.schema_translate_map` is
added. fixes #2685
- latest tox doesn't like the {posargs} in the profile rerunner
2016-01-08 22:12:25 -05:00
Mike Bayer c8b7729338 - Added a new entrypoint system to the engine to allow "plugins" to
be stated in the query string for a URL.   Custom plugins can
be written which will be given the chance up front to alter and/or
consume the engine's URL and keyword arguments, and then at engine
create time will be given the engine itself to allow additional
modifications or event registration.  Plugins are written as a
subclass of :class:`.CreateEnginePlugin`; see that class for
details.
fixes #3536
2016-01-06 17:20:57 -05:00
Mike Bayer a80bb4e5aa - Added :class:.mysql.JSON for MySQL 5.7. The JSON type provides
persistence of JSON values in MySQL as well as basic operator support
of "getitem" and "getpath", making use of the ``JSON_EXTRACT``
function in order to refer to individual paths in a JSON structure.
fixes #3547
- Added a new type to core :class:`.types.JSON`.  This is the
base of the PostgreSQL :class:`.postgresql.JSON` type as well as that
of the new :class:`.mysql.JSON` type, so that a PG/MySQL-agnostic
JSON column may be used.  The type features basic index and path
searching support.
fixes #3619
- reorganization of migration docs etc. to try to refer both to
the fixes to JSON that helps Postgresql while at the same time
indicating these are new features of the new base JSON type.
- a rework of the Array/Indexable system some more, moving things
that are specific to Array out of Indexable.
- new operators for JSON indexing added to core so that these can
be compiled by the PG and MySQL dialects individually
- rename sqltypes.Array to sqltypes.ARRAY - as there is no generic
Array implementation, this is an uppercase type for now, consistent
with the new sqltypes.JSON type that is also not a generic implementation.
There may need to be some convention change to handle the case of
datatypes that aren't generic, rely upon DB-native implementations,
but aren't necessarily all named the same thing.
2016-01-06 12:47:48 -05:00
Jeff Widman 56b76ce7a8 Update SQLAlchemy-Migrate link to the new repo 2015-12-24 02:17:02 -08:00
Jeff Widman 30be49c157 Make docs listing of param order for event.listen match the code 2015-12-17 05:54:50 -08:00
Mike Bayer 8a24da6c10 - hyperlink default-related parameters
(cherry picked from commit 9f6f34bc8f)
2015-12-15 18:31:56 -05:00
Mike Bayer 80bbf13959 - a few tweaks to allow "server_defaults" to be a little more linkable;
remove "undoc members" that was putting some random server_default
atributes from ColumnClause

(cherry picked from commit 270301890a)
2015-12-14 18:02:14 -05:00
Mike Bayer d533b8e922 - The ORM and Core tutorials, which have always been in doctest format,
are now exercised within the normal unit test suite in both Python
2 and Python 3.
- remove the old testdocs.py runner and replace with test/base/test_tutorials.py
- use pytest's unicode fixer so that we can test for unicode strings
in both py2k/3k
- use py3k format overall for prints, exceptions
- add other fixers to guarantee deterministic results
- add skips and ellipses to outputs that aren't worth matching
2015-12-10 17:09:47 -05:00