Commit dbd86e81 authored by Thomas Goirand's avatar Thomas Goirand

Merge tag '0.12.0' into debian/stein

sqlalchemy-migrate 0.12.0 release

meta:version: 0.12.0
meta:diff-start: -
meta:series: independent
meta:release-type: release
meta:pypi: no
meta:first: no
meta:release:Author: Matt Riedemann <mriedem.os@gmail.com>
meta:release:Commit: Matt Riedemann <mriedem.os@gmail.com>
meta:release:Change-Id: Ic3cb5184d5cc65982e90430b94fbd13beaa4c921
meta:release:Code-Review+2: Jean-Philippe Evrard <jean-philippe@evrard.me>
meta:release:Code-Review+2: Sean McGinnis <sean.mcginnis@gmail.com>
meta:release:Workflow+1: Sean McGinnis <sean.mcginnis@gmail.com>
parents 92b9de8c 8acab2cd
.eggs/
AUTHORS
ChangeLog
.tox
......
sqlalchemy-migrate
SQLAlchemy Migrate
==================
Fork from http://code.google.com/p/sqlalchemy-migrate/ to get it working with
......
......@@ -159,8 +159,7 @@ class ANSISchemaChanger(AlterTableVisitor, SchemaGenerator):
def visit_table(self, table):
"""Rename a table. Other ops aren't supported."""
self.start_alter_table(table)
q = util.safe_quote(table)
self.append("RENAME TO %s" % self.preparer.quote(table.new_name, q))
self.append("RENAME TO %s" % self.preparer.quote(table.new_name))
self.execute()
def visit_index(self, index):
......@@ -170,19 +169,19 @@ class ANSISchemaChanger(AlterTableVisitor, SchemaGenerator):
self.append("ALTER INDEX %s RENAME TO %s" % (
self.preparer.quote(
self._validate_identifier(
index.name, True), index.quote),
index.name, True)),
self.preparer.quote(
self._validate_identifier(
index.new_name, True), index.quote)))
index.new_name, True))))
elif hasattr(self, '_index_identifier'):
# SA >= 0.6.5, < 0.8
self.append("ALTER INDEX %s RENAME TO %s" % (
self.preparer.quote(
self._index_identifier(
index.name), index.quote),
index.name)),
self.preparer.quote(
self._index_identifier(
index.new_name), index.quote)))
index.new_name))))
else:
# SA >= 0.8
class NewName(object):
......@@ -229,8 +228,7 @@ class ANSISchemaChanger(AlterTableVisitor, SchemaGenerator):
def start_alter_column(self, table, col_name):
"""Starts ALTER COLUMN"""
self.start_alter_table(table)
q = util.safe_quote(table)
self.append("ALTER COLUMN %s " % self.preparer.quote(col_name, q))
self.append("ALTER COLUMN %s " % self.preparer.quote(col_name))
def _visit_column_nullable(self, table, column, delta):
nullable = delta['nullable']
......@@ -253,8 +251,7 @@ class ANSISchemaChanger(AlterTableVisitor, SchemaGenerator):
def _visit_column_name(self, table, column, delta):
self.start_alter_table(table)
q = util.safe_quote(table)
col_name = self.preparer.quote(delta.current_name, q)
col_name = self.preparer.quote(delta.current_name)
new_name = self.preparer.format_column(delta.result_column)
self.append('RENAME COLUMN %s TO %s' % (col_name, new_name))
......
......@@ -61,7 +61,7 @@ class FBSchemaChanger(ansisql.ANSISchemaChanger):
def _visit_column_name(self, table, column, delta):
self.start_alter_table(table)
col_name = self.preparer.quote(delta.current_name, table.quote)
col_name = self.preparer.quote(delta.current_name)
new_name = self.preparer.format_column(delta.result_column)
self.append('ALTER COLUMN %s TO %s' % (col_name, new_name))
......
......@@ -108,8 +108,7 @@ class IBMDBSchemaChanger(IBMDBSchemaGenerator, ansisql.ANSISchemaChanger):
"""Rename a table; #38. Other ops aren't supported."""
self._rename_table(table)
q = util.safe_quote(table)
self.append("TO %s" % self.preparer.quote(table.new_name, q))
self.append("TO %s" % self.preparer.quote(table.new_name))
self.execute()
self.append("COMMIT")
self.execute()
......@@ -121,9 +120,9 @@ class IBMDBSchemaChanger(IBMDBSchemaGenerator, ansisql.ANSISchemaChanger):
if hasattr(self, '_index_identifier'):
# SA >= 0.6.5, < 0.8
old_name = self.preparer.quote(
self._index_identifier(index.name), index.quote)
self._index_identifier(index.name))
new_name = self.preparer.quote(
self._index_identifier(index.new_name), index.quote)
self._index_identifier(index.new_name))
else:
# SA >= 0.8
class NewName(object):
......@@ -148,11 +147,10 @@ class IBMDBSchemaChanger(IBMDBSchemaGenerator, ansisql.ANSISchemaChanger):
def _run_subvisit(self, delta, func, start_alter=True):
"""Runs visit method based on what needs to be changed on column"""
table = delta.table
q = util.safe_quote(table)
if start_alter:
self.start_alter_table(table)
ret = func(table,
self.preparer.quote(delta.current_name, q),
self.preparer.quote(delta.current_name),
delta)
self.execute()
self._reorg_table(self.preparer.format_table(delta.table))
......@@ -314,8 +312,7 @@ class IBMDBConstraintDropper(ansisql.ANSIConstraintDropper,
if hasattr(self, '_index_identifier'):
# SA >= 0.6.5, < 0.8
index_name = self.preparer.quote(
self._index_identifier(constraint.name),
constraint.quote)
self._index_identifier(constraint.name))
else:
# SA >= 0.8
index_name = self._prepared_index_name(constraint)
......
......@@ -37,8 +37,7 @@ class MySQLSchemaChanger(MySQLSchemaGenerator, ansisql.ANSISchemaChanger):
first = primary_keys.pop(0)
if first.name == delta.current_name:
colspec += " AUTO_INCREMENT"
q = util.safe_quote(table)
old_col_name = self.preparer.quote(delta.current_name, q)
old_col_name = self.preparer.quote(delta.current_name)
self.start_alter_table(table)
......
......@@ -4,7 +4,7 @@
.. _`SQLite`: http://www.sqlite.org/
"""
try: # Python 3
from collections import MutableMapping as DictMixin
from collections.abc import MutableMapping as DictMixin
except ImportError: # Python 2
from UserDict import DictMixin
from copy import copy
......@@ -96,8 +96,17 @@ class SQLiteHelper(SQLiteCommon):
if omit_constraints is None or cons.name not in omit_constraints
])
# Use "PRAGMA legacy_alter_table = ON" with sqlite >= 3.26 when
# using "ALTER TABLE RENAME TO migration_tmp" to maintain legacy
# behavior. See: https://www.sqlite.org/src/info/ae9638e9c0ad0c36
if self.connection.engine.dialect.server_version_info >= (3, 26):
self.append('PRAGMA legacy_alter_table = ON')
self.execute()
self.append('ALTER TABLE %s RENAME TO migration_tmp' % table_name)
self.execute()
if self.connection.engine.dialect.server_version_info >= (3, 26):
self.append('PRAGMA legacy_alter_table = OFF')
self.execute()
insertion_string = self._modify_table(table, column, delta)
......
......@@ -3,7 +3,7 @@
"""
import abc
try: # Python 3
from collections import MutableMapping as DictMixin
from collections.abc import MutableMapping as DictMixin
except ImportError: # Python 2
from UserDict import DictMixin
import warnings
......@@ -650,12 +650,10 @@ populated with defaults
# TODO: this is fixed in 0.6
def copy_fixed(self, **kw):
"""Create a copy of this ``Column``, with all attributes."""
q = util.safe_quote(self)
return sqlalchemy.Column(self.name, self.type, self.default,
key=self.key,
primary_key=self.primary_key,
nullable=self.nullable,
quote=q,
index=self.index,
unique=self.unique,
onupdate=self.onupdate,
......
from migrate.changeset import SQLA_10
"""
Safe quoting method
"""
def safe_quote(obj):
# this is the SQLA 0.9 approach
if hasattr(obj, 'name') and hasattr(obj.name, 'quote'):
return obj.name.quote
else:
return obj.quote
def fk_column_names(constraint):
if SQLA_10:
......
......@@ -761,7 +761,7 @@ class TestColumnChange(fixture.DB):
@fixture.usedb()
def test_alter_deprecated(self):
try:
# py 2.4 compatability :-/
# py 2.4 compatibility :-/
cw = catch_warnings(record=True)
w = cw.__enter__()
......
......@@ -42,7 +42,7 @@ class TestUtil(fixture.Pathed):
# deprecated echo=True parameter
try:
# py 2.4 compatability :-/
# py 2.4 compatibility :-/
cw = catch_warnings(record=True)
w = cw.__enter__()
......@@ -100,7 +100,7 @@ class TestUtil(fixture.Pathed):
f.close()
try:
# py 2.4 compatability :-/
# py 2.4 compatibility :-/
cw = catch_warnings(record=True)
w = cw.__enter__()
......
......@@ -6,7 +6,7 @@ pbr>=1.8
# never put a cap on this, *ever*, sqla versions are handled via
# tox, and if SQLA is capped it will only make it so we aren't testing
# against all the versions we are compatible with.
SQLAlchemy>=0.7.8,!=0.9.5
SQLAlchemy>=0.9.6
decorator
six>=1.7.0
sqlparse
......
......@@ -4,7 +4,7 @@ summary = Database schema migration for SQLAlchemy
description-file =
README.rst
author = OpenStack
author-email = openstack-dev@lists.openstack.org
author-email = openstack-discuss@lists.openstack.org
home-page = http://www.openstack.org/
classifier =
Environment :: OpenStack
......@@ -15,7 +15,6 @@ classifier =
Programming Language :: Python
Programming Language :: Python :: 2
Programming Language :: Python :: 2.7
Programming Language :: Python :: 2.6
Programming Language :: Python :: 3
Programming Language :: Python :: 3.3
Programming Language :: Python :: 3.4
......
......@@ -25,5 +25,5 @@ except ImportError:
pass
setuptools.setup(
setup_requires=['pbr>=1.3'],
setup_requires=['pbr>=1.8'],
pbr=True)
[tox]
minversion = 1.6
skipsdist = True
envlist = py26,py27,py26sa07,py27sa07,py26sa08,py27sa08,py26sa09,py27sa09,py33,py34,pep8
envlist = py27,py27sa07,py27sa08,py27sa09,py33,py34,pep8
[testenv]
usedevelop = True
whitelist_externals = bash
install_command = pip install {opts} {packages}
# Avoid psycopg2 wheel package rename warnings by not using the binary.
install_command = pip install --no-binary psycopg2 {opts} {packages}
setenv = VIRTUAL_ENV={envdir}
deps = -r{toxinidir}/requirements.txt
-r{toxinidir}/test-requirements.txt
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment