deprecated; use Inspector.get_pk_constraint().
Courtesy Diana Clarke. [ticket:2422]
- restored default get_primary_keys()/get_pk_constraint() wrapper
to help maintain compatibility with third party dialects
created against 0.6 or 0.7
- [bug] Fixed bug which would prevent
OrderingList from being pickleable
[ticket:2454]. Courtesy Jeff Dairiki
+ also in 0.7.7.
+
+- engine
+ - [feature] Added a new system
+ for registration of new dialects in-process
+ without using an entrypoint. See the
+ docs for "Registering New Dialects".
+ [ticket:2462]
+
+ - [bug] The names of the columns on the
+ .c. attribute of a select().apply_labels()
+ is now based on <tablename>_<colkey> instead
+ of <tablename>_<colname>, for those columns
+ that have a distinctly named .key.
+ [ticket:2397]
+
++ - [feature] Inspector.get_primary_keys() is
++ deprecated; use Inspector.get_pk_constraint().
++ Courtesy Diana Clarke. [ticket:2422]
- sql
+ - [feature] The Inspector object can now be
+ acquired using the new inspect() service,
+ part of [ticket:2208]
+
+ - [feature] The column_reflect event now
+ accepts the Inspector object as the first
+ argument, preceding "table". Code which
+ uses the 0.7 version of this very new
+ event will need modification to add the
+ "inspector" object as the first argument.
+ [ticket:2418]
+
+ - [feature] The behavior of column targeting
+ in result sets is now case sensitive by
+ default. SQLAlchemy for many years would
+ run a case-insensitive conversion on these values,
+ probably to alleviate early case sensitivity
+ issues with dialects like Oracle and
+ Firebird. These issues have been more cleanly
+ solved in more modern versions so the performance
+ hit of calling lower() on identifiers is removed.
+ The case insensitive comparisons can be re-enabled
+ by setting "case_insensitive=False" on
+ create_engine(). [ticket:2423]
+
+ - [bug] All of UniqueConstraint, ForeignKeyConstraint,
+ CheckConstraint, and PrimaryKeyConstraint will
+ attach themselves to their parent table automatically
+ when they refer to a Table-bound Column object directly
+ (i.e. not just string column name), and refer to
+ one and only one Table. Prior to 0.8 this behavior
+ occurred for UniqueConstraint and PrimaryKeyConstraint,
+ but not ForeignKeyConstraint or CheckConstraint.
+ [ticket:2410]
+
+ - [bug] column.label(None) now produces an
+ anonymous label, instead of returning the
+ column object itself, consistent with the behavior
+ of label(column, None). [ticket:2168]
+
- [bug] Removed warning when Index is created
with no columns; while this might not be what
the user intended, it is a valid use case
raise NotImplementedError()
-
- Given a :class:`.Connection`, a string
- `table_name`, and an optional string `schema`, return primary
- key information as a list of column names.
-
+ def get_primary_keys(self, connection, table_name, schema=None, **kw):
+ """Return information about primary keys in `table_name`.
- def get_pk_constraint(self, table_name, schema=None, **kw):
++
++
++ Deprecated. This method is only called by the default
++ implementation of :meth:`get_pk_constraint()`. Dialects should
++ instead implement this method directly.
++
+ """
++
+ raise NotImplementedError()
+
+ def get_pk_constraint(self, connection, table_name, schema=None, **kw):
"""Return information about the primary key constraint on
table_name`.
import sqlalchemy
from sqlalchemy import exc, sql
+ from sqlalchemy import schema as sa_schema
from sqlalchemy import util
- from sqlalchemy.util import topological
from sqlalchemy.types import TypeEngine
- from sqlalchemy import schema as sa_schema
+ from sqlalchemy.util import deprecated
+ from sqlalchemy.util import topological
-
+from sqlalchemy import inspection
+from sqlalchemy.engine.base import Connectable
@util.decorator
def cache(fn, self, con, *args, **kw):
primary key information as a list of column names.
"""
- pkeys = self.dialect.get_primary_keys(self.bind, table_name, schema,
- info_cache=self.info_cache,
- **kw)
-
- return pkeys
- pkeys = self.dialect.get_pk_constraint(self.bind, table_name, schema,
++ return self.dialect.get_pk_constraint(self.bind, table_name, schema,
+ info_cache=self.info_cache,
+ **kw)['constrained_columns']
- return pkeys
def get_pk_constraint(self, table_name, schema=None, **kw):
"""Return information about primary key constraint on `table_name`.
optional name of the primary key constraint.
"""
-- pkeys = self.dialect.get_pk_constraint(self.bind, table_name, schema,
++ return self.dialect.get_pk_constraint(self.bind, table_name, schema,
info_cache=self.info_cache,
**kw)
-- return pkeys
--
def get_foreign_keys(self, table_name, schema=None, **kw):
"""Return information about foreign_keys in `table_name`.
"""
-- fk_defs = self.dialect.get_foreign_keys(self.bind, table_name, schema,
++ return self.dialect.get_foreign_keys(self.bind, table_name, schema,
info_cache=self.info_cache,
**kw)
-- return fk_defs
def get_indexes(self, table_name, schema=None, **kw):
"""Return information about indexes in `table_name`.
other options passed to the dialect's get_indexes() method.
"""
-- indexes = self.dialect.get_indexes(self.bind, table_name,
++ return self.dialect.get_indexes(self.bind, table_name,
schema,
info_cache=self.info_cache, **kw)
-- return indexes
def reflecttable(self, table, include_columns, exclude_columns=()):
"""Given a Table object, load its internal constructs based on introspection.
- from test.lib.testing import eq_, assert_raises, assert_raises_message
- import StringIO, unicodedata
+ import unicodedata
+ import sqlalchemy as sa
+ from sqlalchemy import exc as sa_exc
from sqlalchemy import types as sql_types
-from sqlalchemy import schema, events, event
+from sqlalchemy import schema, events, event, inspect
from sqlalchemy import MetaData, Integer, String
- from test.lib.schema import Table, Column
- import sqlalchemy as sa
+ from sqlalchemy.engine.reflection import Inspector
from test.lib import ComparesTables, \
- testing, engines, AssertsCompiledSQL
- from test.lib import fixtures
+ testing, engines, AssertsCompiledSQL, fixtures
+ from test.lib.schema import Table, Column
+ from test.lib.testing import eq_, assert_raises, assert_raises_message
-create_inspector = Inspector.from_engine
-
metadata, users = None, None
class ReflectionTest(fixtures.TestBase, ComparesTables):
self._test_get_columns(schema='test_schema', table_type='view')
@testing.provide_metadata
- def _test_get_primary_keys(self, schema=None):
+ def _test_get_pk_constraint(self, schema=None):
meta = self.metadata
- users, addresses, dingalings = createTables(meta, schema)
+ users, addresses, _ = createTables(meta, schema)
meta.create_all()
- insp = Inspector(meta.bind)
+ insp = inspect(meta.bind)
- users_pkeys = insp.get_primary_keys(users.name,
- schema=schema)
+
+ users_cons = insp.get_pk_constraint(users.name, schema=schema)
+ users_pkeys = users_cons['constrained_columns']
eq_(users_pkeys, ['user_id'])
- addr_cons = insp.get_pk_constraint(addresses.name,
- schema=schema)
+ addr_cons = insp.get_pk_constraint(addresses.name, schema=schema)
addr_pkeys = addr_cons['constrained_columns']
eq_(addr_pkeys, ['address_id'])