On Python 3, some functions like range() don't try to call the __int__()
method to cast an object to integer, but try instead the __index__()
method.
Add an __index__() method to mimick correctly the int type on Python 3.
Change-Id: I8df116d80e201778714a59367600eaef644266ed
There are two changes which have to go together to pass the gate
tests:
1. Update pbr and mock requirements from global-requirements
mock 1.2 supports py26 again so make that the minimum version. The
same change is being made in g-r with:
Ic6b9e18eaec9c81bbbbc57129e024904be928e09
Sync up with latest pbr in global-requirements while we're at it.
Closes-Bug: #1474925
2. Fix the importpath module to work with python >= 3.3 where the
__import__ built-in is raising an ImportError on a temporary file
that is added to the system path.
Closes-Bug: #1475339
Change-Id: Ie98938ba75f3983094dd540b7d26a7ec46be4f6e
In order to raise the cap on pbr we need to update
the dependent versions of the flake8 related packages
for the pep8 job since they have capped pbr.
A couple of simple hacking issues are fixed, the rest
are ignored.
Change-Id: Icddb5bf284da7b6463ebcfc7512726149ffe6085
Lift the requirements to support SQLAlchemy 1.0. Two tests
were calling upon revised APIs and required adjustment.
Change-Id: Ic91a91bb3c915027b522eace302f2ed074233294
Under Python 2.6 a setuptools warning is produced when
the migrate runner runs. Since migrate invokes its own
commandline client from tests in a separate shell, the
fixture we're using to do that must be told not to complain
about this stderr.
Change-Id: Ib5823754d6ffabe954665f2a7529ed0e56591ebf
The ibmdb2 code calls _index_identifier() when it handles index name. This
method only exists from sqlalchemy 0.6.5 to 0.7.*. Nova code change
https://review.openstack.org/#/c/153123/ attempts to drop a db constraint and
it fails to sync nova db with sqlalchemy 0.9.8 running against db2. Need to let
ibmdb2 code identify sqlalchemy version and call the correct method to handle
index name.
Closes-Bug: 1428477
Change-Id: Ie6333f9cea0209c1ea290356873a1a1bcf409bed
This implements the ability to drop foreign keys
with sqlite. It's basically the same implementation
used for dropping unique constraints so the common
code is refactored.
The existing FKey test that was skipping sqlite is
no longer skipped to show this works.
Change-Id: Idaaf4229e34af4c21c3bcead4b4e22491d24238e
Closes-Bug: #1423955
Regular expression does not match correctly against statements that contain
comments at their start. So strip those comments first (and whitespaces, while
we are at it).
Change-Id: Iad9b544bf995374d76cab1e125658aae2f8511f4
Closes-Bug: #1410494
Now that we don't run SQL script with a single .execute() call,
transaction management statements (BEGIN, COMMIT, END) fail with
operational error. Ignore them if occurred in a script.
All in all, transactions are managed by SQLAlchemy-migrate itself, so
there is no reason for the calling code to pass those statements in a
SQL script. Warn user about the statements that are ignored.
The ideal response to such a warning from library users is removing
those redundant transaction management statements from their scripts.
Note: ROLLBACK is not ignored even though it's one of transaction
management statements because its usage in migration scripts is insane
anyway, and we're better fail on it and not (almost) silently ignore it.
Change-Id: Ie4179c0e9341d42656d66821aaac23f8dcd33927
Closes-bug: 1368391
Commit 8d6ce64cd08c0598963a92844495782997cd59f3 started using the native
quote attribute built into sqlalchemy 0.9 but missed the changes to the
ibmdb2 changeset, so alter table statements fail for DB2 on sqlalchemy
>= 0.9 (tested against 0.9.8).
This fixes the same issue for the ibmdb2 changeset.
Change-Id: Ia3fa6c3090b5eab29ed7746f4795d502990b8a2f
The changeset module was adding a warnings filter on import. This
affects all applications that wind up importing it. A library
shouldn't modify the warnings filters unless asked.
Closes-Bug: #1407736
Change-Id: I893f8be48efd3d3642e977ab587c9e6dc867258b
Some drivers [f.e. MySQL Connector] do not like multiple statements
being passed to .execute(). They require either passing multi=True
parameter to .execute() that is not DB-API 2.0 defined, or executing
those statements one by one.
For that patch, I've chosen the second option to stay away from driver
specific hacks.
Also removed SQLite hack that seems to be related to the same multiple
statements issue.
blueprint enable-mysql-connector
Change-Id: Ic6d53ed1fef8aee9471f3540f06b39cd5ee4ef82
If SQL script failed, we don't currently log the failure anywhere, so
users have hard time debugging an issue, if anything arises.
Let's log the failure before proceeding with rollback.
Change-Id: Ic92b1403c00bb238a68265a15150a4be6f6b2346
The ibmdb2 unique constraint code was accessing the private _all_cols
member var in iterating over columns which breaks in sqlalchemy 0.9 so
fix up the code to not use internals of sqlalchemy.
UniqueConstraint in sqlalchemy extends ColumnCollectionConstraint
which implements __iter__ to generate a tuple of the columns in
the constraint, so we just iterate over the constraint as the fix.
This is based on a patch from Rahul Priyadarshi in ibm-db-sa issue
158:
https://code.google.com/p/ibm-db/issues/detail?id=158
Co-Authored-By: Rahul Priyadarshi <rahul.priyadarshi@in.ibm.com>
Change-Id: I0f06f6314c382e83573d762abe5981db0a02a83a
Removes `six` from the locals().copy() so that it won't be templated into
manage.py. Currently manage.py is mis-templated and is failing.
Change-Id: Ib3b7c7caac998fbaa45c3370547c9b8bf13abe41
Closes-Bug: 171
oslo-incubator commit 3f503faac for making sqlite work with dropping
unique constraints in database migrations. This was made in
oslo-incubator since at the time sqlalchemy-migrate was not in
stackforge. Now that we can update sqlalchemy-migrate, move the patch
over from oslo.
This change also adds the support for the case that a unique constraint
is dropped because the column it's on is dropped.
Note that there are already unit tests that cover dropping a unique
constraint directly and implicitly via dropping a column that is in
the unique constraint.
Related-Bug: #1307266
Change-Id: I5ee8082a83aebf66f6e1dacb093ed79e13f73f5e
Brief summary of the modifications:
* Use six for compatibility with both Python 2 and 3;
* Replace UserDict.DictMixin with collections.MutableMapping;
* Fix relative imports;
* Use test-requirements.txt for requirements that are common to both Python 2
and 3, and test-requirements-py{2,3}.txt for version-specific requirements;
* Miscellaneous fixes.
* Use a specific test_db_py3.cfg file for Python 3, that only runs tests on
sqlite.
Thanks to Victor Stinner who co-wrote this patch.
Change-Id: Ia6dc536c39d274924c21fd5bb619e8e5721e04c4
Co-Authored-By: Victor Stinner <victor.stinner@enovance.com>
The assert_() method is deprecated and can be safely replaced by assertTrue().
This patch makes sure that running the tests does not fill the screen with
warnings.
Change-Id: I8966b7f7a44f1573a4d2c398717bfc68ae40b197
AbstractType not longer exists in the class hierarchy for types.
TypeEngine was its direct descendant, so use that instead.
Change-Id: Idbfaee4b0d3acbc4795913ddf2ab4e1c9b6d065c
There's no script_path param in the current version of
scripttest. This patch fixes that by removing the param,
which by the way isn't useful.
Change-Id: Ic78cea25bb472702473e98b48a8ff74c01545aa3
In SQLA 0.9 there is now a native .quote attribute on many objects.
Conditionally use this instead of the old method if the attribute
exists, to remove deprecation messages (and prepare for when the
other way will be fully removed).
Change-Id: I3c5fada13e044c1c4102acc0455226ce1524f2e2
Problem:
* Some python code was auto generated and exec'ed in that
package.
* The python code that was problematic had a 'Table' definition
* The generated code imports '*' from sqlalchemy
* One among the 'Column' was defined as an 'INTEGER' type, which
points to sqlalchemy.sql.sqltypes.INTEGER
* The INTEGER class was initialised with a parameter display_width
which contradicts with sqlalchemy.sql.sqltypes.INTEGER.__init__,
which does not accept any parameters
* The 'INTEGER' class should have been imported from mysql dialects'
type module
Solution:
* While generating, in the header part, I am now checking if any of
the column.type.__class__.__name__ has 'dialects' in it.
* If I find any, I am adding the import rule such that the type is
imported from the dialects' type.
This patch has been tested with SQLA 0.9.3, for which it fixes the
unit tests, and with SQLA 0.8.2, which doesn't have (new) problems
with this patch.
Change-Id: Ie0e09b45388462629100017bea3ea8a314d148d8
Since ibm_db_sa is not part of sqlalchemy, we need to handle the
conditional import of the module in visitor.py so we don't get an
ImportError if ibm_db_sa is not available.
Closes-Bug: #1287229
Change-Id: Ida070b629ce3b9be727ae49973bb6a71543c1dcf
This patch fixes get_constraint_name in the
ANSIConstraintCommon class. It's part of the
fixes needed for SQLA 0.9.x compat.
Change-Id: I1f1648af48f459bd18f99bb42fa9a272186fb37d
Remove all trailing spaces and tabs in every file in the project.
People have editors configured to do this, which causes them to
accidentally make little whitespace changes in unrelated commits,
which makes those commits harder to review. Better to fix them all
at once.
Change-Id: I17d89f55f41d8599e0ab1a31f646cd161289703e
This patch adds the initial support for DB2 10.5 to migrate. It
includes:
1. The dialect implementation for DB2.
2. The dialect registration with the visitor.
3. Code to parse the engine name in version.py.
4. A new dependency on ibm_db_sa in test-requirements.txt.
5. A connection string in test_db.cfg for ibm_db_sa.
Part of blueprint add-db2-support
Co-authored-by: Sheng Bo Hou <sbhou@cn.ibm.com>
Co-authored-by: Thuy Christenson <thuy@us.ibm.com>
Co-authored-by: Rahul Priyadarshi <rahul.priyadarshi@in.ibm.com>
Change-Id: I745ec615487b1b06c5d1a09ea316f376d66ee4c0
Fixes:
File ".../versioning/version.py", line 30, in __init__
if self < 0:
OverflowError: Python int too large to convert to C long
Don't use __cmp__ which is deprecated and restricted to C
long ints, rather than python's arbitrary precision ints.
Copied from Pádraig Brady's Fedora patch:
http://pkgs.fedoraproject.org/cgit/python-migrate.git/commit/?id=a01bf449
Co-authored-by: Pádraig Brady <pbrady@redhat.com>
Change-Id: I71f349f97507525b2f2edaf034005d67b6cc3987
Version 0.8 of SQLAlchemy added support of indexes
on expressions in addition to plain table columns,
which changed the way indexes are created.
This broke support of dropping columns of composite
indexes for SQLite: due to limitations of ALTER in
SQLite every time a column is dropped, we recreate
the whole table without the given column; if a
column is a part of a composite index, we change the
index definition to omit that column and then indexes
are recreated too.
SQLAlchemy versions starting from 0.8 no more pay
attention to 'columns' attribute of Index instances
when generating DDL for indexes, so when one of columns
of a composite index is dropped, we try to create a
new index on the column that doesn't exist anymore,
which of course fails.
Closes-Bug: #1241038
Change-Id: I777b8ce36e36f49bfb0889908811a063cf1a527b
In addition to running tests with different Python and SQLAlchemy
versions, they should also be run on different DB backends, which
are used in production (PostgreSQL and MySQL).
This patch:
- modifies test_db.cfg to run tests on PostgreSQL and MySQL
(Jenkins Slave credentials are used here, to ensure these
tests are always run by Jenkins gate); if a backend is not
available, test cases will be skipped for it
- concurrency is set to 1 (sharing of the one MySQL or PostgreSQL
DB among different test runner processes would lead to
race conditions)
- fixes tests dropping FK columns in MySQL: in earlier MySQL
versions dropping a column that is a part of a FK constraint
would lead to dropping of the FK too. As of MySQL 5.5 that's
not the case anymore: if one tries to drop such column, he/she
will get a very obscure error (something like "Error on rename
of './openstack_citest/#sql-4af_aa2' to './openstack_citest/tmp_adddropcol'
(errno: 150)") '\nALTER TABLE tmp_adddropcol DROP COLUMN r2').
So the solution if to drop FK constraints first, and only then
the columns it is made up of
Change-Id: I8c5d2874c83e7df46da69969ed54d85437c849e7
In commit 0.7.2-16-gc670d1d the _index_identifier() implementation
was copied from sqlalchemy, as that function was renamed
in sqlalchemy 0.8. Instead handle call the renamed function
when appropriate, to decouple ourselves from the sqlalchemy
implementation.
Change-Id: I97b22c20d96758fc5b6bd55318218edb26c5b5d0