summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--lib/sqlalchemy/engine/base.py3
-rw-r--r--lib/sqlalchemy/orm/properties.py9
-rw-r--r--lib/sqlalchemy/orm/query.py6
-rw-r--r--lib/sqlalchemy/orm/session.py3
-rw-r--r--lib/sqlalchemy/schema.py17
-rw-r--r--lib/sqlalchemy/sql.py2
-rw-r--r--lib/sqlalchemy/util.py23
7 files changed, 51 insertions, 12 deletions
diff --git a/lib/sqlalchemy/engine/base.py b/lib/sqlalchemy/engine/base.py
index deeb7ec4e..5e6c74c91 100644
--- a/lib/sqlalchemy/engine/base.py
+++ b/lib/sqlalchemy/engine/base.py
@@ -452,10 +452,11 @@ class Compiled(object):
raise NotImplementedError()
def get_params(self, **params):
- """Deprecated. use construct_params(). (supports unicode names)
+ """Use construct_params(). (supports unicode names)
"""
return self.construct_params(params)
+ get_params = util.deprecated(get_params)
def construct_params(self, params):
"""Return the bind params for this compiled object.
diff --git a/lib/sqlalchemy/orm/properties.py b/lib/sqlalchemy/orm/properties.py
index a6bb1a371..600dab41f 100644
--- a/lib/sqlalchemy/orm/properties.py
+++ b/lib/sqlalchemy/orm/properties.py
@@ -137,6 +137,8 @@ class PropertyLoader(StrategizedProperty):
self.lazy = lazy
self.foreign_keys = util.to_set(foreign_keys)
self._legacy_foreignkey = util.to_set(foreignkey)
+ if foreignkey:
+ util.warn_deprecated('foreignkey option is deprecated; see docs for details')
self.collection_class = collection_class
self.passive_deletes = passive_deletes
self.remote_side = util.to_set(remote_side)
@@ -150,11 +152,14 @@ class PropertyLoader(StrategizedProperty):
self.cascade = mapperutil.CascadeOptions(cascade)
else:
if private:
+ util.warn_deprecated('private option is deprecated; see docs for details')
self.cascade = mapperutil.CascadeOptions("all, delete-orphan")
else:
self.cascade = mapperutil.CascadeOptions("save-update, merge")
self.association = association
+ if association:
+ util.warn_deprecated('association option is deprecated; see docs for details')
self.order_by = order_by
self.attributeext=attributeext
if isinstance(backref, str):
@@ -399,7 +404,7 @@ class PropertyLoader(StrategizedProperty):
raise exceptions.ArgumentError("In relationship '%s', primary and secondary join conditions must not include columns from the polymorphic 'select_table' argument as of SA release 0.3.4. Construct join conditions using the base tables of the related mappers." % (str(self)))
def _determine_fks(self):
- if len(self._legacy_foreignkey) and not self._is_self_referential():
+ if self._legacy_foreignkey and not self._is_self_referential():
self.foreign_keys = self._legacy_foreignkey
def col_is_part_of_mappings(col):
@@ -467,7 +472,7 @@ class PropertyLoader(StrategizedProperty):
# for a self referential mapper, if the "foreignkey" is a single or composite primary key,
# then we are "many to one", since the remote site of the relationship identifies a singular entity.
# otherwise we are "one to many".
- if len(self._legacy_foreignkey):
+ if self._legacy_foreignkey:
for f in self._legacy_foreignkey:
if not f.primary_key:
self.direction = sync.ONETOMANY
diff --git a/lib/sqlalchemy/orm/query.py b/lib/sqlalchemy/orm/query.py
index 01562f7b5..1e091c5e6 100644
--- a/lib/sqlalchemy/orm/query.py
+++ b/lib/sqlalchemy/orm/query.py
@@ -1147,7 +1147,11 @@ class Query(object):
return self._legacy_filter_by(*args, **params).one()
-
+ for deprecated_method in ['list', 'scalar', 'count_by',
+ 'select_whereclause', 'get_by', 'select_by', 'join_by', 'selectfirst',
+ 'selectone', 'select', 'execute', 'select_statement', 'select_text',
+ 'join_to', 'join_via', 'selectfirst_by', 'selectone_by']:
+ exec('%s = util.deprecated(%s, False)' % (deprecated_method, deprecated_method))
Query.logger = logging.class_logger(Query)
diff --git a/lib/sqlalchemy/orm/session.py b/lib/sqlalchemy/orm/session.py
index 87604dde4..d336c5727 100644
--- a/lib/sqlalchemy/orm/session.py
+++ b/lib/sqlalchemy/orm/session.py
@@ -733,9 +733,10 @@ class Session(object):
"within this ``Session`` keyed to their `_instance_key` value.")
def import_instance(self, *args, **kwargs):
- """Deprecated. A synynom for ``merge()``."""
+ """A synynom for ``merge()``."""
return self.merge(*args, **kwargs)
+ import_instance = util.deprecated(import_instance)
# this is the AttributeManager instance used to provide attribute behavior on objects.
# to all the "global variable police" out there: its a stateless object.
diff --git a/lib/sqlalchemy/schema.py b/lib/sqlalchemy/schema.py
index 21822e3a4..17d4d1c77 100644
--- a/lib/sqlalchemy/schema.py
+++ b/lib/sqlalchemy/schema.py
@@ -1125,6 +1125,13 @@ class MetaData(SchemaItem):
"""return True if this MetaData is bound to an Engine."""
return self._bind is not None
+ def _connect(self, bind, **kwargs):
+ from sqlalchemy.engine.url import URL
+ if isinstance(bind, (basestring, URL)):
+ self._bind = sqlalchemy.create_engine(bind, **kwargs)
+ else:
+ self._bind = bind
+
def connect(self, bind, **kwargs):
"""bind this MetaData to an Engine.
@@ -1137,14 +1144,10 @@ class MetaData(SchemaItem):
directly to the given Engine.
"""
-
- from sqlalchemy.engine.url import URL
- if isinstance(bind, (basestring, URL)):
- self._bind = sqlalchemy.create_engine(bind, **kwargs)
- else:
- self._bind = bind
+ self._connect(bind, **kwargs)
+ connect = util.deprecated(connect, False)
- bind = property(lambda self:self._bind, connect, doc="""an Engine or Connection to which this MetaData is bound. this is a settable property as well.""")
+ bind = property(lambda self:self._bind, _connect, doc="""an Engine or Connection to which this MetaData is bound. this is a settable property as well.""")
def clear(self):
self.tables.clear()
diff --git a/lib/sqlalchemy/sql.py b/lib/sqlalchemy/sql.py
index e09dcca8d..b27e82370 100644
--- a/lib/sqlalchemy/sql.py
+++ b/lib/sqlalchemy/sql.py
@@ -215,6 +215,8 @@ def select(columns=None, whereclause=None, from_obj=[], **kwargs):
"""
scalar = kwargs.pop('scalar', False)
+ if scalar:
+ util.warn_deprecated('scalar option is deprecated; see docs for details')
s = Select(columns, whereclause=whereclause, from_obj=from_obj, **kwargs)
if scalar:
return s.as_scalar()
diff --git a/lib/sqlalchemy/util.py b/lib/sqlalchemy/util.py
index e711de3a3..c9c20ef45 100644
--- a/lib/sqlalchemy/util.py
+++ b/lib/sqlalchemy/util.py
@@ -539,3 +539,26 @@ class ScopedRegistry(object):
def _get_key(self):
return self.scopefunc()
+
+
+_warned = Set()
+
+def warn_deprecated(msg):
+ if msg in _warned:
+ return
+ _warned.add(msg)
+ warnings.warn(msg, category=DeprecationWarning, stacklevel=3)
+
+def deprecated(func, add_deprecation_to_docstring=True):
+ def func_with_warning(*args, **kwargs):
+ if func in _warned:
+ return func(*args, **kwargs)
+ _warned.add(func)
+ warnings.warn("Call to deprecated function %s" % func.__name__,
+ category=DeprecationWarning,
+ stacklevel=2)
+ return func(*args, **kwargs)
+ func_with_warning.__name__ = func.__name__
+ func_with_warning.__doc__ = (add_deprecation_to_docstring and 'Deprecated.\n' or '') + func.__doc__
+ func_with_warning.__dict__.update(func.__dict__)
+ return func_with_warning