summaryrefslogtreecommitdiff
path: root/test/sql/test_metadata.py
Commit message (Collapse)AuthorAgeFilesLines
* Deprecate FromClause.count()Mike Bayer2016-06-141-12/+0
| | | | | | | | | | | count() here is misleading in that it not only counts from an arbitrary column in the table, it also does not make accommodations for DISTINCT, JOIN, etc. as the ORM-level function does. Core should not be attempting to provide a function like this. Change-Id: I9916fc51ef744389a92c54660ab08e9695b8afc2 Fixes: #3724
* Skip UniqueConstraint marked by unique=True in tometadataMike Bayer2016-06-021-0/+28
| | | | | | | | | | | | | 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-1/+4
| | | | | | | | | | | | | 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
* - rework ColumnCollection to no longer persist "all_col_set"; we don'tMike Bayer2016-01-261-0/+19
| | | | | | | | | | | | | need this collection except in the extend/update uses where we create it ad-hoc. simplifies pickling. Compatibility with 1.0 should be OK as ColumnColleciton uses __getstate__ in any case and the __setstate__ contract hasn't changed. - Fixed bug in :class:`.Table` metadata construct which appeared around the 0.9 series where adding columns to a :class:`.Table` that was unpickled would fail to correctly establish the :class:`.Column` within the 'c' collection, leading to issues in areas such as ORM configuration. This could impact use cases such as ``extend_existing`` and others. fixes #3632
* - calling str() on a core sql construct has been made more "friendly",Mike Bayer2016-01-191-1/+2
| | | | | | | | | | when the construct contains non-standard sql elements such as returning, array index operations, or dialect-specific or custom datatypes. a string is now returned in these cases rendering an approximation of the construct (typically the postgresql-style version of it) rather than raising an error. fixes #3631 - add within_group to top-level imports - add eq_ignore_whitespace to sqlalchemy.testing imports
* - Fixed an assertion that would raise somewhat inappropriatelyMike Bayer2015-12-231-0/+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
* - fix missing argument in TypeDecorator.copy(), fixes #3584, references #2919Mike Bayer2015-11-131-1/+15
|
* - open up autoincrement for columns that have a default; autoinc is usuallyMike Bayer2015-10-081-12/+7
| | | | "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-0/+122
| | | | | | | | | | | | | | | | | "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.
* Merge remote-tracking branch 'origin/pr/163' into pr163Mike Bayer2015-04-121-1/+1
|\
| * PEP8 cleanup in /test/sqlEric Streeper2015-03-181-1/+1
| |
* | - Fixed issue where a :class:`.MetaData` object that used a namingMike Bayer2015-04-101-0/+13
| | | | | | | | | | | | | | | | 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
* | make sort_tables order deterministicSebastian Bank2015-03-071-0/+15
|/
* - The :class:`.CheckConstraint` construct now supports namingMike Bayer2015-01-301-0/+21
| | | | | | | | | | conventions that include the token ``%(column_0_name)s``; the constraint expression is scanned for columns. Additionally, naming conventions for check constraints that don't include the ``%(constraint_name)s`` token will now work for :class:`.SchemaType`- generated constraints, such as those of :class:`.Boolean` and :class:`.Enum`; this stopped working in 0.9.7 due to :ticket:`3067`. fixes #3299
* - Fixed bug in 0.9's foreign key setup system, such thatMike Bayer2015-01-281-0/+92
| | | | | | | | | | | | | | the logic used to link a :class:`.ForeignKey` to its parent could fail when the foreign key used "link_to_name=True" in conjunction with a target :class:`.Table` that would not receive its parent column until later, such as within a reflection + "useexisting" scenario, if the target column in fact had a key value different from its name, as would occur in reflection if column reflect events were used to alter the .key of reflected :class:`.Column` objects so that the link_to_name becomes significant. Also repaired support for column type via FK transmission in a similar way when target columns had a different key and were referenced using link_to_name. fixes #3298
* - Added a new accessor :attr:`.Table.foreign_key_constraints`Mike Bayer2015-01-011-0/+40
| | | | | to complement the :attr:`.Table.foreign_keys` collection, as well as :attr:`.ForeignKeyConstraint.referred_table`.
* - enhance only_on() to work with compound specsMike Bayer2014-12-061-1/+2
| | | | - fix "temporary_tables" requirement
* Merge remote-tracking branch 'origin/pr/151' into pr151Mike Bayer2014-12-011-0/+2
|\
| * Merge branch 'master' into fdbsql-testsScott Dugas2014-11-031-3/+83
| |\ | | | | | | | | | | | | Conflicts: lib/sqlalchemy/testing/exclusions.py
| * | Added requirement for temporary tablesScott Dugas2014-10-301-0/+1
| | |
| * | require check constraints for testsScott Dugas2014-10-231-0/+1
| | |
* | | - Fixed bug in :meth:`.Table.tometadata` method where theMike Bayer2014-11-291-0/+40
| | | | | | | | | | | | | | | | | | | | | | | | :class:`.CheckConstraint` associated with a :class:`.Boolean` or :class:`.Enum` type object would be doubled in the target table. The copy process now tracks the production of this constraint object as local to a type object. fixes #3260
* | | - The behavioral contract of the :attr:`.ForeignKeyConstraint.columns`Mike Bayer2014-11-251-0/+44
| |/ |/| | | | | | | | | | | | | collection has been made consistent; this attribute is now a :class:`.ColumnCollection` like that of all other constraints and is initialized at the point when the constraint is associated with a :class:`.Table`. fixes #3243
* | - changelog for pullreq github:139Mike Bayer2014-10-211-0/+36
| | | | | | | | | | - add support for self-referential foreign keys to move over as well when the table name is changed.
* | Merge remote-tracking branch 'origin/pr/139' into pr139Mike Bayer2014-10-211-0/+44
|\ \
| * | add simple tests for new name argument for Table.tometadata()pr/139ndparker2014-10-041-0/+44
| | |
* | | - "column already assigned" message has been updated in 7f82c55fMike Bayer2014-09-251-1/+1
|/ /
* | - use compat.u for python3.2, fixes #3198Mike Bayer2014-09-151-2/+2
|/
* - don't add the parent attach event within _on_table_attachMike Bayer2014-08-151-0/+14
| | | | | if we already have a table; this prevents reentrant calls and we aren't supporting columns/etc being moved around between different parents
* - The ``info`` parameter has been added to the constructor forMike Bayer2014-08-131-0/+65
| | | | | | | | | | | :class:`.SynonymProperty` and :class:`.ComparableProperty`. - The ``info`` parameter has been added as a constructor argument to all schema constructs including :class:`.MetaData`, :class:`.Index`, :class:`.ForeignKey`, :class:`.ForeignKeyConstraint`, :class:`.UniqueConstraint`, :class:`.PrimaryKeyConstraint`, :class:`.CheckConstraint`. fixes #2963
* - update the flake8 rules againMike Bayer2014-07-181-423/+521
| | | | - apply autopep8 + manual fixes to most of test/sql/
* - wrestle with conv() and tests some moreMike Bayer2014-07-141-4/+24
|
* - allow the compilation rule that gets the formatted nameMike Bayer2014-07-141-0/+19
| | | | | to again have the chance to veto rendering, as the naming convention can make the decision that the name is "none" or not now.
* - Fix bug in naming convention feature where using a checkMike Bayer2014-07-141-6/+80
| | | | | | | | | | | | | constraint convention that includes ``constraint_name`` would then force all :class:`.Boolean` and :class:`.Enum` types to require names as well, as these implicitly create a constraint, even if the ultimate target backend were one that does not require generation of the constraint such as Postgresql. The mechanics of naming conventions for these particular constraints has been reorganized such that the naming determination is done at DDL compile time, rather than at constraint/table construction time. fixes #3067
* - Added a "str()" step to the dialect_kwargs iteration forMike Bayer2014-07-141-0/+13
| | | | | | | Python version < 2.6.5, working around the "no unicode keyword arg" bug as these args are passed along as keyword args within some reflection processes. fixes #3123
* - Fixed bug in :class:`.Enum` and other :class:`.SchemaType`Mike Bayer2014-07-131-0/+57
| | | | | | | subclasses where direct association of the type with a :class:`.MetaData` would lead to a hang when events (like create events) were emitted on the :class:`.MetaData`. fixes #3124
* - The :paramref:`.Column.nullable` flag is implicitly set to ``False``Mike Bayer2014-06-201-0/+18
| | | | | | | | | when that :class:`.Column` is referred to in an explicit :class:`.PrimaryKeyConstraint` for that table. This behavior now matches that of when the :class:`.Column` itself has the :paramref:`.Column.primary_key` flag set to ``True``, which is intended to be an exactly equivalent case. fixes #3023
* Fix many typos throughout the codebasepr/85Alex Gaynor2014-04-261-1/+1
| | | | Found using: https://github.com/intgr/topy
* - Liberalized the contract for :class:`.Index` a bit in that you canMike Bayer2014-04-191-2/+69
| | | | | | | specify a :func:`.text` expression as the target; the index no longer needs to have a table-bound column present if the index is to be manually added to the table, either via inline declaration or via :meth:`.Table.append_constraint`. fixes #3028
* - Fixed bug in new :meth:`.DialectKWArgs.argument_for` method whereMike Bayer2014-04-151-0/+11
| | | | | adding an argument for a construct not previously included for any special arguments would fail. fixes #3024
* :paramref:`.MetaData.naming_convention` feature will now alsoMike Bayer2014-03-121-0/+17
| | | | | | apply to :class:`.CheckConstraint` objects that are associated directly with a :class:`.Column` instead of just on the :class:`.Table`.
* - Fixed bug in new :paramref:`.MetaData.naming_convention` featureMike Bayer2014-03-121-1/+37
| | | | | | | | | where the name of a check constraint making use of the `"%(constraint_name)s"` token would get doubled up for the constraint generated by a boolean or enum type, and overall duplicate events would cause the `"%(constraint_name)s"` token to keep compounding itself. fixes #2991
* - Support has been added for pytest to run tests. This runnerMike Bayer2014-03-031-11/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | is currently being supported in addition to nose, and will likely be preferred to nose going forward. The nose plugin system used by SQLAlchemy has been split out so that it works under pytest as well. There are no plans to drop support for nose at the moment and we hope that the test suite itself can continue to remain as agnostic of testing platform as possible. See the file README.unittests.rst for updated information on running tests with pytest. The test plugin system has also been enhanced to support running tests against mutiple database URLs at once, by specifying the ``--db`` and/or ``--dburi`` flags multiple times. This does not run the entire test suite for each database, but instead allows test cases that are specific to certain backends make use of that backend as the test is run. When using pytest as the test runner, the system will also run specific test suites multiple times, once for each database, particularly those tests within the "dialect suite". The plan is that the enhanced system will also be used by Alembic, and allow Alembic to run migration operation tests against multiple backends in one run, including third-party backends not included within Alembic itself. Third party dialects and extensions are also encouraged to standardize on SQLAlchemy's test suite as a basis; see the file README.dialects.rst for background on building out from SQLAlchemy's test platform.
* - The new dialect-level keyword argument system for schema-levelMike Bayer2014-02-251-0/+133
| | | | | | | | | constructs has been enhanced in order to assist with existing schemes that rely upon addition of ad-hoc keyword arguments to constructs. - To suit the use case of allowing custom arguments at construction time, the :meth:`.DialectKWArgs.argument_for` method now allows this registration. fixes #2962
* - Fixed regression in new "naming convention" feature where conventionsMike Bayer2014-02-051-2/+20
| | | | | would fail if the referred table in a foreign key contained a schema name. Pull request courtesy Thomas Farvour. pullreq github:67
* - The behavior of :meth:`.Table.tometadata` has been adjusted such thatMike Bayer2014-02-021-168/+308
| | | | | | | | | | | | | | | | | | | | | | | | the schema target of a :class:`.ForeignKey` will not be changed unless that schema matches that of the parent table. That is, if a table "schema_a.user" has a foreign key to "schema_b.order.id", the "schema_b" target will be maintained whether or not the "schema" argument is passed to :meth:`.Table.tometadata`. However if a table "schema_a.user" refers to "schema_a.order.id", the presence of "schema_a" will be updated on both the parent and referred tables. This is a behavioral change hence isn't likely to be backported to 0.8; it is assumed that the previous behavior is pretty buggy however and that it's unlikely anyone was relying upon it. Additionally, a new parameter has been added :paramref:`.Table.tometadata.referred_schema_fn`. This refers to a callable function which will be used to determine the new referred schema for any :class:`.ForeignKeyConstraint` encountered in the tometadata operation. This callable can be used to revert to the previous behavior or to customize how referred schemas are treated on a per-constraint basis. [ticket:2913] - rework the tests in test.sql.test_metadata, all the "tometadata" tests now under new class ToMetaDataTest
* - Added a new feature which allows automated naming conventions to beMike Bayer2014-02-011-8/+74
| | | | | | | | | | | | | | | | applied to :class:`.Constraint` and :class:`.Index` objects. Based on a recipe in the wiki, the new feature uses schema-events to set up names as various schema objects are associated with each other. The events then expose a configuration system through a new argument :paramref:`.MetaData.naming_convention`. This system allows production of both simple and custom naming schemes for constraints and indexes on a per-:class:`.MetaData` basis. [ticket:2923] commit 7e65e52c086652de3dd3303c723f98f09af54db8 Author: Mike Bayer <mike_mp@zzzcomputing.com> Date: Sat Feb 1 15:09:04 2014 -0500 - first pass at new naming approach
* - simplify the mechanics of PrimaryKeyConstraint with regards to reflection;Mike Bayer2014-01-201-1/+72
| | | | | | | | | | | | 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.
* - alter behavior such that dialect_kwargs is still immutable, butMike Bayer2014-01-191-18/+48
| | | | | | now represents exactly the kwargs that were passed, and not the defaults. the defaults are still in dialect_options. This allows repr() schemes such as that of alembic to not need to look through and compare for defaults.
* - some test fixesMike Bayer2014-01-191-12/+5
| | | | - clean up some shenanigans in reflection