Mike Bayer [Thu, 26 Aug 2010 15:32:50 +0000 (11:32 -0400)]
- An object that's been deleted now gets a flag
'deleted', which prohibits the object from
being re-add()ed to the session, as previously
the object would live in the identity map
silently until its attributes were accessed.
The make_transient() function now resets this
flag along with the "key" flag.
- make_transient() can be safely called on an
already transient instance.
Mike Bayer [Thu, 26 Aug 2010 05:33:51 +0000 (01:33 -0400)]
- replaced all self.__connection.is_valid with
"safe" self._connection_is_valid.
- Fixed bug in Connection whereby if a "disconnect"
event occurred in the "initialize" phase of the
first connection pool connect, an AttributeError
would be raised when the Connection would attempt
to invalidate the DBAPI connection. [ticket:1894]
- Connection.invalidate() can be called more than
once and subsequent calls do nothing.
Mike Bayer [Mon, 23 Aug 2010 22:17:31 +0000 (18:17 -0400)]
- the history_meta versioning recipe sets "unique=False"
when copying columns, so that the versioning
table handles multiple rows with repeating values.
[ticket:1887]
Mike Bayer [Sat, 21 Aug 2010 23:38:28 +0000 (19:38 -0400)]
- Similarly, for relationship(), foreign_keys,
remote_side, order_by - all column-based
expressions are enforced - lists of strings
are explicitly disallowed since this is a
very common error
Mike Bayer [Sat, 14 Aug 2010 18:52:18 +0000 (14:52 -0400)]
- Another pass through the series of error messages
emitted when relationship() is configured with
ambiguous arguments. The "foreign_keys"
setting is no longer mentioned, as it is almost
never needed and it is preferable users set up
correct ForeignKey metadata, which is now the
recommendation. If 'foreign_keys'
is used and is incorrect, the message suggests
the attribute is probably unnecessary. Docs
for the attribute are beefed up. This
because all confused relationship() users on the
ML appear to be attempting to use foreign_keys
due to the message, which only confuses them
further since Table metadata is much clearer.
- If the "secondary" table has no ForeignKey metadata
and no foreign_keys is set, even though the
user is passing screwed up information, it is assumed
that primary/secondaryjoin expressions should
consider only and all cols in "secondary" to be
foreign. It's not possible with "secondary" for
the foreign keys to be elsewhere in any case.
A warning is now emitted instead of an error,
and the mapping succeeds. [ticket:1877]
- fixed incorrect "Alternate Collection Mappings" reference
in the docs, not sure if someone wants to reference
"Rows that Point to Themselves" function
- "Collection Mapping" is "Advanced Collection Mapping", this
section is troublesome since nobody really needs it but it
is public API
Mike Bayer [Wed, 11 Aug 2010 15:57:56 +0000 (11:57 -0400)]
- a warning is emitted in mapper() if the polymorphic_on
column is not present either in direct or derived
form in the mapped selectable or in the
with_polymorphic selectable, instead of silently
ignoring it. Look for this to become an
exception in 0.7.
Mike Bayer [Tue, 10 Aug 2010 14:24:02 +0000 (10:24 -0400)]
- Fixed the psycopg2 dialect to use its
set_isolation_level() method instead of relying
upon the base "SET SESSION ISOLATION" command,
as psycopg2 resets the isolation level on each new
transaction otherwise.
Mike Bayer [Sun, 8 Aug 2010 19:14:27 +0000 (15:14 -0400)]
- some of the refinements from the sa_synonyms branch which will
allow the hybrid extension to work, but doesn't re-implement synonym,
comparable_property,concreteinheritedproperty
- mapper.get_property() and _entity_descriptor use plain getattr()
to get at descriptors in all cases, thereby placing more
trust in the ultimate class-bound attribute to provide mapped
properties
Mike Bayer [Sun, 8 Aug 2010 00:58:23 +0000 (20:58 -0400)]
- the _Label construct, i.e. the one that is produced
whenever you say somecol.label(), now counts itself
in its "proxy_set" unioned with that of it's
contained column's proxy set, instead of
directly returning that of the contained column.
This allows column correspondence
operations which depend on the identity of the
_Labels themselves to return the correct result
- fixes ORM bug [ticket:1852].
Mike Bayer [Thu, 5 Aug 2010 16:28:01 +0000 (12:28 -0400)]
- Dynamic attributes don't support collection
population - added an assertion for when
set_committed_value() is called, as well as
when joinedload() or subqueryload() options
are applied to a dynamic attribute, instead
of failure / silent failure. [ticket:1864]
Mike Bayer [Thu, 5 Aug 2010 01:30:53 +0000 (21:30 -0400)]
- Fixed bug whereby replacing composite foreign key
columns in a reflected table would cause an attempt
to remove the reflected constraint from the table
a second time, raising a KeyError. [ticket:1865]
- fixed test of error message now that we've improved it
(didn't know that msg had an assertion)
Mike Bayer [Tue, 3 Aug 2010 18:06:41 +0000 (14:06 -0400)]
- the text() construct, if placed in a column
oriented situation, will at least return NULLTYPE
for its type instead of None, allowing it to
be used a little more freely for ad-hoc column
expressions than before. literal_column()
is still the better choice, however.
Mike Bayer [Tue, 3 Aug 2010 15:55:12 +0000 (11:55 -0400)]
- Calling fetchone() or similar on a result that
has already been exhausted, has been closed,
or is not a result-returning result now
raises ResourceClosedError, a subclass of
InvalidRequestError, in all cases, regardless
of backend. Previously, some DBAPIs would
raise ProgrammingError (i.e. pysqlite), others
would return None leading to downstream breakages
(i.e. MySQL-python).
- Connection, ResultProxy, as well as Session use
ResourceClosedError for all "this
connection/transaction/result is closed" types of
errors.
Mike Bayer [Tue, 3 Aug 2010 00:41:47 +0000 (20:41 -0400)]
- add an example of declarative with hybrid, including why this
is a different use case (i.e. formalized apps vs. quickstart).
- solidified docstrings for ForeignKey
Mike Bayer [Mon, 2 Aug 2010 20:59:06 +0000 (16:59 -0400)]
- Specifying a non-column based argument
for column_mapped_collection, including string,
text() etc., will raise an error message that
specifically asks for a column element, no longer
misleads with incorrect information about
text() or literal(). [ticket:1863]
Mike Bayer [Mon, 2 Aug 2010 19:29:31 +0000 (15:29 -0400)]
- if @classproperty is used with a regular class-bound
mapper property attribute, it will be called to get the
actual attribute value during initialization. Currently,
there's no advantage to using @classproperty on a column
or relationship attribute of a declarative class that
isn't a mixin - evaluation is at the same time as if
@classproperty weren't used. But here we at least allow
it to function as expected.
- docs for column_property() with declarative
- mixin docs in declarative made more clear - mixins
are optional - each subsection starts with, "in *declarative mixins*",
to reduce confusion
Mike Bayer [Mon, 2 Aug 2010 05:12:03 +0000 (01:12 -0400)]
- The generated index name also is based on
a "max index name length" attribute which is
separate from the "max identifier length" -
this to appease MySQL who has a max length
of 64 for index names, separate from their
overall max length of 255. [ticket:1412]
Mike Bayer [Mon, 2 Aug 2010 00:55:44 +0000 (20:55 -0400)]
- worked through about 25% of mappers.rst to implement
up to date and clear explanations of things, including
as much context and description as possible
Mike Bayer [Sun, 1 Aug 2010 22:24:35 +0000 (18:24 -0400)]
- The name ConcurrentModificationError has been
changed to StaleDataError, and descriptive
error messages have been revised to reflect
exactly what the issue is. Both names will
remain available for the forseeable future
for schemes that may be specifying
ConcurrentModificationError in an "except:"
clause.
Mike Bayer [Sun, 1 Aug 2010 18:07:35 +0000 (14:07 -0400)]
- Repaired the usage of merge() when used with
concrete inheriting mappers. Such mappers frequently
have so-called "concrete" attributes, which are
subclass attributes that "disable" propagation from
the parent - these needed to allow a merge()
operation to pass through without effect.
Mike Bayer [Sat, 24 Jul 2010 14:10:28 +0000 (10:10 -0400)]
- The value of version_id_col can be changed
manually, and this will result in an UPDATE
of the row. Versioned UPDATEs and DELETEs
now use the "committed" value of the
version_id_col in the WHERE clause and
not the pending changed value. The
version generator is also bypassed if
manual changes are present on the attribute.
[ticket:1857]
- ensure before_update/after_update called on parent
for collection change
Mike Bayer [Thu, 22 Jul 2010 05:46:41 +0000 (01:46 -0400)]
- Moving an o2m object from one collection to
another, or vice versa changing the referenced
object by an m2o, where the foreign key is also a
member of the primary key, will now be more
carefully checked during flush if the change in
value of the foreign key on the "many" side is the
result of a change in the primary key of the "one"
side, or if the "one" is just a different object.
In one case, a cascade-capable DB would have
cascaded the value already and we need to look at
the "new" PK value to do an UPDATE, in the other we
need to continue looking at the "old". We now look
at the "old", assuming passive_updates=True,
unless we know it was a PK switch that
triggered the change. [ticket:1856]
Mike Bayer [Wed, 21 Jul 2010 20:19:08 +0000 (16:19 -0400)]
- The beaker_caching example has been reorgnized
such that the Session, cache manager,
declarative_base are part of environment, and
custom cache code is portable and now within
"caching_query.py". This allows the example to
be easier to "drop in" to existing projects.
Mike Bayer [Wed, 21 Jul 2010 15:33:47 +0000 (11:33 -0400)]
- Changed the scheme used to generate truncated
"auto" index names when using the "index=True"
flag on Column. The truncation only takes
place with the auto-generated name, not one
that is user-defined (an error would be
raised instead), and the truncation scheme
itself is now based on a fragment of an md5
hash of the identifier name, so that multiple
indexes on columns with similar names still
have unique names. [ticket:1855]
Mike Bayer [Thu, 15 Jul 2010 13:59:17 +0000 (09:59 -0400)]
- Column-entities (i.e. query(Foo.id)) copy their
state more fully when queries are derived from
themselves + a selectable (i.e. from_self(),
union(), etc.), so that join() and such have the
correct state to work from. [ticket:1853]
- Fixed bug where Query.join() would fail if
querying a non-ORM column then joining without
an on clause when a FROM clause is already
present, now raises a checked exception the
same way it does when the clause is not
present. [ticket:1853]
Mike Bayer [Wed, 14 Jul 2010 18:50:45 +0000 (14:50 -0400)]
- More tweaks to cx_oracle Decimal handling.
"Ambiguous" numerics with no decimal place
are coerced to int at the connection handler
level. The advantage here is that ints
come back as ints without SQLA type
objects being involved and without needless
conversion to Decimal first.
Unfortunately, some exotic subquery cases
can even see different types between
individual result rows, so the Numeric
handler, when instructed to return Decimal,
can't take full advantage of "native decimal"
mode and must run isinstance() on every value
to check if its Decimal already. Reopen of
[ticket:1840]
Mike Bayer [Wed, 14 Jul 2010 01:30:55 +0000 (21:30 -0400)]
- PG doc updates
- pypostgresql has 15 errors, 3 failures, this probably
puts it in the "yes" as opposed to the "partial" support
category. [ticket:1850]
Mike Bayer [Wed, 14 Jul 2010 00:52:05 +0000 (20:52 -0400)]
- _extract_error_code now expects the raw DBAPI error in all cases
for all four MySQL dialects. has_table() passes in the "orig"
from the SQLAlchemy exception. continuing of [ticket:1848]
Mike Bayer [Tue, 13 Jul 2010 15:55:08 +0000 (11:55 -0400)]
- pull out type() ahead of time to cut down on fn calls.
Would replace this with set(dir(self)) but not sure if some
class schemes may have issues with dir() (also for low numbers
of args, not using the set() probably faster).
Mike Bayer [Mon, 12 Jul 2010 15:15:16 +0000 (11:15 -0400)]
- The _extract_error_code() method now works
correctly with the "mysqldb" dialect. Previously,
the reconnect logic would fail for OperationalError
conditions, however since MySQLdb has its
own reconnect feature, there was no symptom
here unless one watched the logs.
[ticket:1848]
Mike Bayer [Thu, 8 Jul 2010 22:17:23 +0000 (18:17 -0400)]
- added "expr" to the column descriptions accessor, this is
an expression that matches on identity the original expression
passed to the query. In particular you can pass it into order_by()
and similar.
Mike Bayer [Thu, 8 Jul 2010 18:13:56 +0000 (14:13 -0400)]
- 78 chars
- Added "column_descriptions" accessor to Query,
returns a list of dictionaries containing
naming/typing information about the entities
the Query will return. Can be helpful for
building GUIs on top of ORM queries.
Mike Bayer [Thu, 8 Jul 2010 14:16:13 +0000 (10:16 -0400)]
- Improved the check for an "unmapped class",
including the case where the superclass is mapped
but the subclass is not. Any attempts to access
cls._sa_class_manager.mapper now raise
UnmappedClassError(). [ticket:1142]
Mike Bayer [Wed, 7 Jul 2010 16:01:02 +0000 (12:01 -0400)]
- Removed errant many-to-many load in unitofwork
which triggered unnecessarily on expired/unloaded
collections. This load now takes place only if
passive_updates is False and the parent primary
key has changed, or if passive_deletes is False
and a delete of the parent has occurred.
[ticket:1845]
Mike Bayer [Mon, 5 Jul 2010 23:54:46 +0000 (19:54 -0400)]
- latest distribute
- added caveats to unittest README encountered with Py2.7 + current nose 0.11.3
- call counts for py2.7. all tests pass for sqlite + mysql-python + psycopg2
Mike Bayer [Sat, 3 Jul 2010 18:53:37 +0000 (14:53 -0400)]
- Added support for @classproperty to provide
any kind of schema/mapping construct from a
declarative mixin, including columns with foreign
keys, relationships, column_property, deferred.
This solves all such issues on declarative mixins.
An error is raised if any MapperProperty subclass
is specified on a mixin without using @classproperty.
[ticket:1751] [ticket:1796] [ticket:1805]