summaryrefslogtreecommitdiff
path: root/lib/sqlalchemy/engine/reflection.py
Commit message (Collapse)AuthorAgeFilesLines
* Ensure Oracle index w/ col DESC etc. is reflectedMike Bayer2017-08-141-0/+1
| | | | | | | | | | | | | | | | | | | | 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
* Implement comments for tables, columnsFrazer McLean2017-03-171-1/+34
| | | | | | | | | | | | | | 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
* Accept FetchedValue, text() for column "default" valueMike Bayer2017-02-011-17/+17
| | | | | | | | | | | | | Fixed bug whereby the :meth:`.DDLEvents.column_reflect` event would not allow a non-textual expression to be passed as the value of the "default" for the new column, such as a :class:`.FetchedValue` object to indicate a generic triggered default or a :func:`.sql.expression.text` construct. Clarified the documentation in this regard as well. Fixes: #3905 Change-Id: I829796c3e9f87f375149bebee7eef133a6876d4d
* update for 2017 copyrightMike Bayer2017-01-041-1/+1
| | | | Change-Id: I4e8c2aa8fe817bb2af8707410fa0201f938781de
* Add _extend_on deduplicating set for metadata.reflect()Mike Bayer2016-11-231-3/+13
| | | | | | | | | | | | | 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
* spelling: Postgresql -> PostgreSQLVille Skyttä2016-10-081-1/+1
|
* Implemented CHECK constraint reflection for SQLite and PostgreSQLAlex Grönholm2016-06-011-0/+43
| | | | | | Co-Authored-By: Mike Bayer <mike_mp@zzzcomputing.com> Change-Id: Ie6cf2d2958d1c567324db9e08fef2d3186e97350 Pull-request: https://bitbucket.org/zzzeek/sqlalchemy/pull-requests/80
* Support "blank" schema when MetaData.schema is setMike Bayer2016-05-181-0/+1
| | | | | | | | | | | | | 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
|
* - reorganize schema_translate_map to be succinct and gain the performanceMike Bayer2016-01-111-2/+1
| | | | back by using an attrgetter for the default case
* - ensure we use a Connection for effective schema here since Engine doesn'tMike Bayer2016-01-091-1/+2
| | | | have it; keep it simple
* - Multi-tenancy schema translation for :class:`.Table` objects is added.Mike Bayer2016-01-081-1/+2
| | | | | | | | | 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
* - copyright 2015Mike Bayer2015-03-101-1/+1
|
* - restate sort_tables in terms of a more fine grainedMike Bayer2015-01-011-1/+68
| | | | | | | | | | | | | sort_tables_and_constraints function. - The DDL generation system of :meth:`.MetaData.create_all` and :meth:`.Metadata.drop_all` has been enhanced to in most cases automatically handle the case of mutually dependent foreign key constraints; the need for the :paramref:`.ForeignKeyConstraint.use_alter` flag is greatly reduced. The system also works for constraints which aren't given a name up front; only in the case of DROP is a name required for at least one of the constraints involved in the cycle. fixes #3282
* - document / work around that dialect_options isn't necessarily thereMike Bayer2014-12-051-1/+4
|
* - New Oracle DDL features for tables, indexes: COMPRESS, BITMAP.Mike Bayer2014-12-041-1/+9
| | | | | Patch courtesy Gabor Gombas. fixes #3127
* - use provide_metadata for new unique constraint / index testsMike Bayer2014-10-041-1/+14
| | | | | | | | | | | | | | - add a test for PG reflection of unique index without any unique constraint - for PG, don't include 'duplicates_constraint' in the entry if the index does not actually mirror a constraint - use a distinct method for unique constraint reflection within table - catch unique constraint not implemented condition; this may be within some dialects and also is expected to be supported by Alembic tests - migration + changelogs for #3184 - add individual doc notes as well to MySQL, Postgreql fixes #3184
* Merge branch 'reflect-unique-constraints' of ↵Mike Bayer2014-10-041-0/+34
|\ | | | | | | https://bitbucket.org/jerdfelt/sqlalchemy into pr30
| * Reflect unique constraints when reflecting a Table objectJohannes Erdfelt2014-09-171-0/+34
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Calls to reflect a table did not create any UniqueConstraint objects. The reflection core made no calls to get_unique_constraints and as a result, the sqlite dialect would never reflect any unique constraints. MySQL transparently converts unique constraints into unique indexes, but SQLAlchemy would reflect those as an Index object and as a UniqueConstraint. The reflection core will now deduplicate the unique constraints. PostgreSQL would reflect unique constraints as an Index object and as a UniqueConstraint object. The reflection core will now deduplicate the unique indexes.
* | - cyclomatic complexity; break up reflecttable(), goes from E to BMike Bayer2014-09-271-39/+74
|/
* - Added :meth:`.Inspector.get_temp_table_names` andMike Bayer2014-09-171-0/+24
| | | | | | | | | | | | :meth:`.Inspector.get_temp_view_names`; currently, only the SQLite dialect supports these methods. The return of temporary table and view names has been **removed** from SQLite's version of :meth:`.Inspector.get_table_names` and :meth:`.Inspector.get_view_names`; other database backends cannot support this information (such as MySQL), and the scope of operation is different in that the tables can be local to a session and typically aren't supported in remote schemas. fixes #3204
* - An adjustment to table/index reflection such that if an indexMike Bayer2014-09-021-8/+17
| | | | | | | reports a column that isn't found to be present in the table, a warning is emitted and the column is skipped. This can occur for some special system column situations as has been observed with Oracle. fixes #3180
* PEP8 style fixesBrian Jarrett2014-07-131-34/+38
|
* - break up the <authors> copyright comment as part of a passMike Bayer2014-07-091-1/+2
| | | | to get all flake8 passing
* Documentation fix-up: "its" vs. "it's"pr/91Matthias Urlichs2014-05-111-1/+1
| | | | | | | | | Removed ungrammatical apostrophes from documentation, replacing "it's" with "its" where appropriate (but in a few cases with "it is" when that read better). While doing that, I also fixed a couple of minor typos etc. as I noticed them.
* - further refine this so that the ordering of columns is maintained asMike Bayer2014-01-201-8/+1
| | | | | sent to the primary key constraint; existing tests in the PG dialect confirm this.
* - simplify the mechanics of PrimaryKeyConstraint with regards to reflection;Mike Bayer2014-01-201-10/+15
| | | | | | | | | | | | reflection now updates the PKC in place. - support the use case of the empty PrimaryKeyConstraint in order to specify constraint options; the columns marked as primary_key=True will now be gathered into the columns collection, rather than being ignored. [ticket:2910] - add validation such that column specification should only take place in the PrimaryKeyConstraint directly, or by using primary_key=True flags; if both are present, they have to match exactly, otherwise the condition is assumed to be ambiguous, and a warning is emitted; the old behavior of using the PKC columns only is maintained.
* - some test fixesMike Bayer2014-01-191-26/+23
| | | | - clean up some shenanigans in reflection
* - implement kwarg validation and type system for dialect-specificMike Bayer2014-01-181-1/+1
| | | | | arguments; [ticket:2866] - add dialect specific kwarg functionality to ForeignKeyConstraint, ForeignKey
* - happy new yearMike Bayer2014-01-051-1/+1
|
* - reflection of unique constraints backported to 0.8.4 [ticket:1443]Mike Bayer2013-12-031-1/+1
|
* - remove informix dialect, moved out to ↵Mike Bayer2013-11-171-1/+1
| | | | | | https://bitbucket.org/zzzeek/sqlalchemy_informixdb - remove informix, maxdb, access symbols from tests etc.
* Fix cross referencespr/44Vraj Mohan2013-11-141-1/+1
|
* #2183: Metadata.reflect() foreign keys include options when the dialect ↵ijl2013-10-131-1/+6
| | | | exposes it
* plus some more adjustments for mysql, or in general if an Index refers toMike Bayer2013-08-281-1/+9
| | | | in-python only cols
* Fixed bug where using the ``column_reflect`` event to change the ``.key``Mike Bayer2013-08-281-6/+17
| | | | | | of the incoming :class:`.Column` would prevent primary key constraints, indexes, and foreign key constraints from being correctly reflected. Also in 0.8.3. [ticket:2811]
* - A rework to the way that "quoted" identifiers are handled, in thatMike Bayer2013-08-271-1/+48
| | | | | | | | | | | | | | | | instead of relying upon various ``quote=True`` flags being passed around, these flags are converted into rich string objects with quoting information included at the point at which they are passed to common schema constructs like :class:`.Table`, :class:`.Column`, etc. This solves the issue of various methods that don't correctly honor the "quote" flag such as :meth:`.Engine.has_table` and related methods. The :class:`.quoted_name` object is a string subclass that can also be used explicitly if needed; the object will hold onto the quoting preferences passed and will also bypass the "name normalization" performed by dialects that standardize on uppercase symbols, such as Oracle, Firebird and DB2. The upshot is that the "uppercase" backends can now work with force-quoted names, such as lowercase-quoted names and new reserved words. [ticket:2812]
* - A large refactoring of the ``sqlalchemy.sql`` package has reorganizedMike Bayer2013-08-121-2/+2
| | | | | | | | | | | | | | | | | | | | | | the import structure of many core modules. ``sqlalchemy.schema`` and ``sqlalchemy.types`` remain in the top-level package, but are now just lists of names that pull from within ``sqlalchemy.sql``. Their implementations are now broken out among ``sqlalchemy.sql.type_api``, ``sqlalchemy.sql.sqltypes``, ``sqlalchemy.sql.schema`` and ``sqlalchemy.sql.ddl``, the last of which was moved from ``sqlalchemy.engine``. ``sqlalchemy.sql.expression`` is also a namespace now which pulls implementations mostly from ``sqlalchemy.sql.elements``, ``sqlalchemy.sql.selectable``, and ``sqlalchemy.sql.dml``. Most of the "factory" functions used to create SQL expression objects have been moved to classmethods or constructors, which are exposed in ``sqlalchemy.sql.expression`` using a programmatic system. Care has been taken such that all the original import namespaces remain intact and there should be no impact on any existing applications. The rationale here was to break out these very large modules into smaller ones, provide more manageable lists of function names, to greatly reduce "import cycles" and clarify the up-front importing of names, and to remove the need for redundant functions and documentation throughout the expression package.
* these notes about **kw are incorrect, we are talking about the return value hereMike Bayer2013-06-091-8/+0
|
* - get_unique_constraints() pull requestMike Bayer2013-06-091-0/+2
| | | | | | - version (0.9 for now) - changelog - move the test into the test suite so that all dialects can take advantage of it
* Add basic support of unique constraints reflectionpr/4Roman Podolyaka2013-06-091-0/+20
| | | | | | | | | | | | Inspection API already supports reflection of table indexes information and those also include unique constraints (at least for PostgreSQL and MySQL). But it could be actually useful to distinguish between indexes and plain unique constraints (though both are implemented in the same way internally in RDBMS). This change adds a new method to Inspection API - get_unique_constraints() and implements it for SQLite, PostgreSQL and MySQL dialects.
* do a sweep of some obvious 3kismsMike Bayer2013-05-261-6/+5
|
* that's all of engineMike Bayer2013-05-041-2/+6
|
* - the raw 2to3 runMike Bayer2013-04-271-9/+9
| | | | - went through examples/ and cleaned out excess list() calls
* happy new year (see #2645)Diana Clarke2013-01-011-1/+1
|
* fixing broken links (see #2625)Diana Clarke2012-12-051-8/+8
|
* just a pep8 pass of lib/sqlalchemy/engine/Diana Clarke2012-11-191-18/+30
|
* - fix the fixture here that wasn't creating consistentlyMike Bayer2012-10-011-9/+24
| | | | | | | - rewrite --dropfirst to be more industrial strength, includes views - fix order_by="foreign_key" to maintain the same ordering as metadata.sorted_tables. Not ideal that this was the other way throughout 0.7 but this is still a little-used method, in contrast to metadata.sorted_tables.
* - [bug] Adjusted column default reflection code toMike Bayer2012-09-231-1/+1
| | | | | | | | convert non-string values to string, to accommodate old SQLite versions that don't deliver default info as a string. [ticket:2265] - factor sqlite column reflection to be like we did for postgresql, in a separate method.
* - update engine docstrings due to moveMike Bayer2012-08-131-4/+4
| | | | - struggle with Operators class autodoc