summaryrefslogtreecommitdiff
path: root/lib/sqlalchemy/sql/schema.py
Commit message (Collapse)AuthorAgeFilesLines
* Ensure Oracle index w/ col DESC etc. is reflectedMike Bayer2017-08-141-1/+10
| | | | | | | | | | | | | | | | | | | | Fixed bug where an index reflected under Oracle with an expression like "column DESC" would not be returned, if the table also had no primary key, as a result of logic that attempts to filter out the index implicitly added by Oracle onto the primary key columns. Reworked the "filter out the primary key index" logic in oracle get_indexes() to be clearer. This changeset also adds an internal check to ColumnCollection to accomodate for the case of a column being added twice, as well as adding a private _table argument to Index such that reflection can specify the Table explicitly. The _table argument can become part of public API in a later revision or release if needed. Change-Id: I745711e03b3e450b7f31185fc70e10d3823063fa Fixes: #4042
* Add support for CACHE and ORDER to sequencesDavid Moore2017-07-051-2/+17
| | | | | | | | | | | Added new keywords :paramref:`.Sequence.cache` and :paramref:`.Sequence.order` to :class:`.Sequence`, to allow rendering of the CACHE parameter understood by Oracle and PostgreSQL, and the ORDER parameter understood by Oracle. Pull request courtesy David Moore. Change-Id: I082c3f8ef56ef89dbaad5da9d5695be5313b0614 Pull-request: https://bitbucket.org/zzzeek/sqlalchemy/pull-requests/96
* Don't erase reflected comment in _init_existingEloy Felix2017-06-201-2/+3
| | | | | Change-Id: Ie0b78c79367933486528ca0ba686d4a9f16922b1 Pull-request: https://github.com/zzzeek/sqlalchemy/pull/370
* Raise if ForeignKeyConstraint created with different numbers ofMike Bayer2017-05-251-0/+16
| | | | | | | | | | | | | | | | | | local and remote columns. An :class:`.ArgumentError` is now raised if a :class:`.ForeignKeyConstraint` object is created with a mismatched number of "local" and "remote" columns, which otherwise causes the internal state of the constraint to be incorrect. Note that this also impacts the condition where a dialect's reflection process produces a mismatched set of columns for a foreign key constraint. Downstream DB2 dialect has been reported as potentially causing this scenario. Change-Id: Id51c34a6c43749bb582639f9c1dc28723482f0e5 Fixes: #3949 References: #3998
* Allow metadata.reflect() to recover from unreflectable tablesMike Bayer2017-05-221-1/+4
| | | | | | | | | | | | | Added support for views that are unreflectable due to stale table definitions, when calling :meth:`.MetaData.reflect`; a warning is emitted for the table that cannot respond to ``DESCRIBE`` but the operation succeeds. The MySQL dialect now raises UnreflectableTableError which is in turn caught by MetaData.reflect(). Reflecting the view standalone raises this error directly. Change-Id: Id8005219d8e073c154cc84a873df911b4a6cf4d6 Fixes: #3871
* - big rewrite of the Sequence documentation:Mike Bayer2017-05-051-20/+28
| | | | | | | | | | | | | | 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)
* - add another note re: 339e2c13b0fc8e95a47d00c0f8fc5afc4b6dff9aMike Bayer2017-05-051-0/+12
| | | | | | | | which clarifies that ForeignKey circumvents this logic as a "convenience". issue #3978 is updated to address trying to make this consistent. Change-Id: I089acaa89f11b7a6310c2bf32916e26eb62ab9c0
* - add a note to MetaData.schema indicating that the TableMike Bayer2017-05-051-0/+13
| | | | | | | will be cataloged in the .tables collection with its fully qualified name. Fixes #3978 Change-Id: I65fa063918efc22658e93c39a0680cb83553dec8
* Apply type processing to untyped preexec default clauseMike Bayer2017-03-301-0/+8
| | | | | | | | | | | | | | | | Fixed bug where a SQL-oriented Python-side column default could fail to be executed properly upon INSERT in the "pre-execute" codepath, if the SQL itself were an untyped expression, such as plain text. The "pre- execute" codepath is fairly uncommon however can apply to non-integer primary key columns with SQL defaults when RETURNING is not used. Tests exist here to ensure typing is applied to a typed expression for default, but in the case of an untyped SQL value, we know the type from the column, so apply this. Change-Id: I5d8b391611c137b9f700115a50a2bf5b30abfe94 Fixes: #3923
* Merge branch 'master' of https://bitbucket.org/jalessio/sqlalchemyMike Bayer2017-03-181-2/+2
|\
| * Fix typos ('expicit' -> 'explicit')Jamie Alessio2017-03-141-2/+2
| |
* | New features from python 2.7Катаев Денис2017-03-171-1/+1
| | | | | | | | | | | | | | After bump minimum supported version to 2.7 (1da9d3752160430c91534a8868ceb8c5ad1451d4), we can use new syntax. Change-Id: Ib064c75a00562e641d132f9c57e5e69744200e05 Pull-request: https://github.com/zzzeek/sqlalchemy/pull/347
* | Implement comments for tables, columnsFrazer McLean2017-03-171-2/+22
|/ | | | | | | | | | | | | | Added support for SQL comments on :class:`.Table` and :class:`.Column` objects, via the new :paramref:`.Table.comment` and :paramref:`.Column.comment` arguments. The comments are included as part of DDL on table creation, either inline or via an appropriate ALTER statement, and are also reflected back within table reflection, as well as via the :class:`.Inspector`. Supported backends currently include MySQL, Postgresql, and Oracle. Co-authored-by: Mike Bayer <mike_mp@zzzcomputing.com> Fixes: #1546 Change-Id: Ib90683850805a2b4ee198e420dc294f32f15d35d
* - document ForeignKeyConstraint columns / elements, fixes #2904Mike Bayer2017-03-071-0/+22
| | | | Change-Id: Ia50a3100d1bd88020c30224932b16aeadd7f4c75
* Only use schema_translate_map on SchemaItem subclassesMike Bayer2017-02-281-1/+5
| | | | | | | | | | | | | Fixed bug in new "schema translate" feature where the translated schema name would be invoked in terms of an alias name when rendered along with a column expression; occurred only when the source translate name was "None". The "schema translate" feature now only takes effect for :class:`.SchemaItem` and :class:`.SchemaType` subclasses, that is, objects that correspond to a DDL-creatable structure in a database. Change-Id: Ie8cb35aeaba2c67efec8c8c57c219e4dd346e44a Fixes: #3924
* Better hide engine passwordValery Yundin2017-01-161-2/+2
| | | | | | | | | | Avoid putting engine password in the exception message in `MetaData.reflect` (since exception messages often appear in logs). Use the same redacted `__repr__` implementation in `TLEngine` as in its base class `Engine` Change-Id: Ic0a7baea917a9c8d87dffdd82ef566673ab08e02 Pull-request: https://github.com/zzzeek/sqlalchemy/pull/327
* Support python3.6Mike Bayer2017-01-131-9/+9
| | | | | | | | | | | Corrects some warnings and adds tox config. Adds DeprecationWarning to the error category. Large sweep for string literals w/ backslashes as this is common in docstrings Co-authored-by: Andrii Soldatenko Fixes: #3886 Change-Id: Ia7c838dfbbe70b262622ed0803d581edc736e085 Pull-request: https://github.com/zzzeek/sqlalchemy/pull/337
* update for 2017 copyrightMike Bayer2017-01-041-1/+1
| | | | Change-Id: I4e8c2aa8fe817bb2af8707410fa0201f938781de
* Add _extend_on deduplicating set for metadata.reflect()Mike Bayer2016-11-231-6/+18
| | | | | | | | | | | | | The "extend_existing" option of :class:`.Table` reflection would cause indexes and constraints to be doubled up in the case that the parameter were used with :meth:`.MetaData.reflect` (as the automap extension does) due to tables being reflected both within the foreign key path as well as directly. A new de-duplicating set is passed through within the :meth:`.MetaData.reflect` sequence to prevent double reflection in this way. Change-Id: Ibf6650c1e76a44ccbe15765fd79df2fa53d6bac7 Fixes: #3861
* Update the Column.nullable docstring for the primary_key=True caseMatt Riedemann2016-10-101-4/+8
| | | | | | | | | | | | | | | | | While reviewing a change that created a new table, the primary_key column value was set to True but nullable was not explicitly set, which led to some confusion over the default behavior for the nullable column value when setting a primary_key. Looking at the docs it's not clear, but the code shows that if nullable is not specified, then nullable = not primary_key, so nullable defaults to False when primary_key is True. This patch adds a simple clarification to the docs so people don't have to check the code. Change-Id: I8553339d56fbae11370c7c6af6d8d4723163be1c Pull-request: https://github.com/zzzeek/sqlalchemy/pull/312
* spelling: Postgresql -> PostgreSQLVille Skyttä2016-10-081-3/+3
|
* - some documentation hitsMike Bayer2016-10-011-5/+15
| | | | Change-Id: I468fe70168804b08cf0d5e8b57e235bca904b1ff
* Check for supports_execution at ClauseElement baseMike Bayer2016-08-311-3/+3
| | | | | | | | | | Raise a more descriptive exception / message when ClauseElement or non-SQLAlchemy objects that are not "executable" are erroneously passed to ``.execute()``; a new exception ObjectNotExecutableError is raised consistently in all cases. Change-Id: I2dd393121e2c7e5b6b9e40286a2f25670876e8e4 Fixes: #3786
* Spelling fixespr/299Ville Skyttä2016-08-081-1/+1
|
* Ensure post-__clause_element__() expression are used in IndexMike Bayer2016-07-311-1/+3
| | | | | | | | | | | The change in Index for 1.1 combined with the fix for ref #3763 still fails to deliver the correct object resolved by __clause_element__() to the list of expressions for compilation. Make sure we use the expression that's been unwrapped from __clause_element__(). Change-Id: Ie1df8db5090de665048331786f0024d52851923f Fixes: #3763
* Index should extract __clause_element__() earlyMike Bayer2016-07-301-1/+4
| | | | | | | | | | | | Fixed bug where :class:`.Index` would fail to extract columns from compound SQL expressions if those SQL expressions were wrapped inside of an ORM-style ``__clause_element__()`` construct. This bug exists in 1.0.x as well, however in 1.1 is more noticeable as hybrid_property @expression now returns a wrapped element. Fixes: #3763 Change-Id: I992536386503a1fb3f2305790abe008d72c44c4a
* Allow Table._reset_exported to silently passMike Bayer2016-07-241-0/+3
| | | | | | | | | | | Fixed bug in :class:`.Table` where the internal method ``_reset_exported()`` would corrupt the state of the object. This method is intended for selectable objects and is called by the ORM in some cases; an erroneous mapper configuration would could lead the ORM to call this on on a :class:`.Table` object. Change-Id: I63fa34ee0cdf16358bb125c556390df79758bcbc Fixes: #3755
* Don't reorder PrimaryKeyConstraint columns if explicitMike Bayer2016-06-201-1/+6
| | | | | | | | | | | Dialed back the "order the primary key columns per auto-increment" described in :ref:`change_mysql_3216` a bit, so that if the :class:`.PrimaryKeyConstraint` is explicitly defined, the order of columns is maintained exactly, allowing control of this behavior when necessary. Change-Id: I9e7902c57a96c15968a6abf53e319acf15680da0 Fixes: #3726
* Skip UniqueConstraint marked by unique=True in tometadataMike Bayer2016-06-021-1/+7
| | | | | | | | | | | | | Fixes an issue where a Column would be copied with unique=True and at the same time the UniqueConstraint would also be copied, leading to duplicate UniqueConstraints in the target table, when tometadata() is used. Imitates the same logic used by index=True/Index to avoid duplicates. For some reason a fix was implemented for Index long ago but never for UniqueConstraint. Change-Id: Ie622ee912a6fb8bf0ea900a8b09d78c7ebc79fc0 Fixes: #3721
* Support "blank" schema when MetaData.schema is setMike Bayer2016-05-181-4/+48
| | | | | | | | | | | | | 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
* - happy new yearMike Bayer2016-01-291-1/+1
|
* - convert keys to str for None not sortable against str on py3kMike Bayer2016-01-121-1/+1
|
* - reorganize schema_translate_map to be succinct and gain the performanceMike Bayer2016-01-111-4/+52
| | | | back by using an attrgetter for the default case
* - Fixed an assertion that would raise somewhat inappropriatelyMike Bayer2015-12-231-3/+7
| | | | | | | | if a :class:`.Index` were associated with a :class:`.Column` that is associated with a lower-case-t :class:`.TableClause`; the association should be ignored for the purposes of associating the index with a :class:`.Table`. fixes #3616
* - a few tweaks to allow "server_defaults" to be a little more linkable;Mike Bayer2015-12-141-2/+10
| | | | | | | remove "undoc members" that was putting some random server_default atributes from ColumnClause (cherry picked from commit 270301890ae87ec32a46bb17889d9776b7de1468)
* Merge branch 'pr204'Mike Bayer2015-10-291-2/+3
|\
| * - convert wrap_callable() to a general purpose update_wrapper-likeMike Bayer2015-10-291-2/+2
| | | | | | | | | | | | function; the caller still passes in the "wrapper" - move tests for wrap_callable() to be generic util tests - changelog for pullreq github:204
| * - wrap ColumnDefault empty arg callables like functools.wraps, setting ↵pr/204Martin J. Hsu2015-10-151-2/+3
| | | | | | | | __name__, __doc__, and __module__
* | - open up autoincrement for columns that have a default; autoinc is usuallyMike Bayer2015-10-081-37/+25
| | | | | | | | "auto" now so True can indicate the dialect would support this
* | - The system by which a :class:`.Column` considers itself to be anMike Bayer2015-10-071-32/+116
|/ | | | | | | | | | | | | | | | | "auto increment" column has been changed, such that autoincrement is no longer implicitly enabled for a :class:`.Table` that has a composite primary key. In order to accommodate being able to enable autoincrement for a composite PK member column while at the same time maintaining SQLAlchemy's long standing behavior of enabling implicit autoincrement for a single integer primary key, a third state has been added to the :paramref:`.Column.autoincrement` parameter ``"auto"``, which is now the default. fixes #3216 - The MySQL dialect no longer generates an extra "KEY" directive when generating CREATE TABLE DDL for a table using InnoDB with a composite primary key with AUTO_INCREMENT on a column that isn't the first column; to overcome InnoDB's limitation here, the PRIMARY KEY constraint is now generated with the AUTO_INCREMENT column placed first in the list of columns.
* - version specs for new Sequence argumentsMike Bayer2015-07-171-0/+15
| | | | - changelog for pullreq github:186
* add CYCLE support to Sequence() and docstrings for NO MINVALUE and NO MAXVALUEpr/186jakeogh2015-06-271-2/+27
|
* add NO MINVALUE and NO MAXVALUE support to Sequence()jakeogh2015-06-271-2/+2
|
* add MAXVALUE support to Sequence()jakeogh2015-06-271-3/+10
|
* add MINVALUE support to Sequence()jakeogh2015-06-271-2/+8
|
* - Repaired the :class:`.ExcludeConstraint` construct to support commonMike Bayer2015-06-161-8/+20
| | | | | | | features that other objects like :class:`.Index` now do, that the column expression may be specified as an arbitrary SQL expression such as :obj:`.cast` or :obj:`.text`. fixes #3454
* - Fixed bug in enhanced constraint-attachment logic introduced inMike Bayer2015-05-021-8/+16
| | | | | | | | | | | :ticket:`3341` where in the unusual case of a constraint that refers to a mixture of :class:`.Column` objects and string column names at the same time, the auto-attach-on-column-attach logic will be skipped; for the constraint to be auto-attached in this case, all columns must be assembled on the target table up front. Added a new section to the migration document regarding the original feature as well as this change. fixes #3411
* - Fixed issue where a :class:`.MetaData` object that used a namingMike Bayer2015-04-101-1/+4
| | | | | | | | convention would not properly work with pickle. The attribute was skipped leading to inconsistencies and failures if the unpickled :class:`.MetaData` object were used to base additional tables from. fixes #3362
* Merge branch 'bb_issue_3084' of https://bitbucket.org/xflr6/sqlalchemy into pr47Mike Bayer2015-04-031-1/+1
|\
| * make sort_tables order deterministicSebastian Bank2015-03-071-1/+1
| |