Commit Graph

2307 Commits

Author SHA1 Message Date
Mike Bayer 976b4c97df - add a new FAQ section "performance", put the profiling article there,
move the insert rows article there as well
2014-05-12 17:17:41 -04:00
Mike Bayer 46763173fc changelog for pullreq bitbucket:15 2014-05-12 11:39:49 -04:00
mike bayer 1abd53a355 Merge pull request #91 from smurfix/de_apostroph_ify
Documentation fix-up: "its" vs. "it's"
2014-05-11 13:04:05 -04:00
Matthias Urlichs f341cfbfe1 Documentation fix-up: "its" vs. "it's"
Removed ungrammatical apostrophes from documentation, replacing
"it's" with "its" where appropriate (but in a few cases with "it is"
when that read better).

While doing that, I also fixed a couple of minor typos etc.
as I noticed them.
2014-05-11 16:49:56 +02:00
Mike Bayer 230c0d5a19 - Fixed ORM bug where the :func:.class_mapper function would mask
AttributeErrors or KeyErrors that should raise during mapper
configuration due to user errors.  The catch for attribute/keyerror
has been made more specific to not include the configuration step.
fixes #3047
2014-05-10 23:26:09 -04:00
Mike Bayer 85d1899b76 - Fixed some "double invalidate" situations were detected where
a connection invalidation could occur within an already critical section
like a connection.close(); ultimately, these conditions are caused
by the change in 🎫`2907`, in that the "reset on return" feature
calls out to the Connection/Transaction in order to handle it, where
"disconnect detection" might be caught.  However, it's possible that
the more recent change in 🎫`2985` made it more likely for this
to be seen as the "connection invalidate" operation is much quicker,
as the issue is more reproducible on 0.9.4 than 0.9.3.

Checks are now added within any section that
an invalidate might occur to halt further disallowed operations
on the invalidated connection.  This includes two fixes both at the
engine level and at the pool level.   While the issue was observed
with highly concurrent gevent cases, it could in theory occur in
any kind of scenario where a disconnect occurs within the connection
close operation.
fixes #3043
ref #2985
ref #2907

- add some defensive checks during an invalidate situation:
1. _ConnectionRecord.invalidate might be called twice within finalize_fairy
if the _reset() raises an invalidate condition, invalidates, raises and then
goes to invalidate the CR.  so check for this.
2. similarly within Conneciton, anytime we do handle_dbapi_error(), we might become invalidated.
so a following finally must check self.__invalid before dealing with the connection
any futher.
2014-05-10 15:34:42 -04:00
Mike Bayer 55eacc8dbe - Fixed bug where :meth:.Table.update and :meth:.Table.delete
would produce an empty WHERE clause when an empty :func:`.and_()`
or :func:`.or_()` or other blank expression were applied.  This is
now consistent with that of :func:`.select`.
fixes #3045
2014-05-08 22:44:06 -04:00
Mike Bayer 6c7fe6d542 - experiment with multi-zoned navigation 2014-05-01 20:39:46 -04:00
Mike Bayer 890ac4c81b doc fixes 2014-05-01 20:34:33 -04:00
Mike Bayer 2a458680a4 - Fixed bug where the combination of "limit" rendering as
"SELECT FIRST n ROWS" using a bound parameter (only firebird has both),
combined with column-level subqueries
which also feature "limit" as well as "positional" bound parameters
(e.g. qmark style) would erroneously assign the subquery-level positions
before that of the enclosing SELECT, thus returning parameters which
are out of order. Fixes #3038
2014-04-30 19:07:45 -04:00
Alex Gaynor 1caa7fafbd Fix many typos throughout the codebase
Found using: https://github.com/intgr/topy
2014-04-26 13:13:13 -07:00
Mike Bayer 146fbf6d26 - add a note about versioning only applying to flushes 2014-04-25 12:31:04 -04:00
Mike Bayer 5016b581b6 - document that joinedload/eagerload work with of_type() + with_polymoprhic() 2014-04-23 19:13:04 -04:00
Mike Bayer 7303b59b00 - The "primaryjoin" model has been stretched a bit further to allow
a join condition that is strictly from a single column to itself,
translated through some kind of SQL function or expression.  This
is kind of experimental, but the first proof of concept is a
"materialized path" join condition where a path string is compared
to itself using "like".   The :meth:`.Operators.like` operator has
also been added to the list of valid operators to use in a primaryjoin
condition.  fixes #3029
2014-04-19 18:49:58 -04:00
Mike Bayer c33d037880 - Liberalized the contract for :class:.Index a bit in that you can
specify a :func:`.text` expression as the target; the index no longer
needs to have a table-bound column present if the index is to be
manually added to the table, either via inline declaration or via
:meth:`.Table.append_constraint`. fixes #3028
2014-04-19 12:31:19 -04:00
Mike Bayer 1fb4ad75a3 - Revised the query used to determine the current default schema name
to use the ``database_principal_id()`` function in conjunction with
the ``sys.database_principals`` view so that we can determine
the default schema independently of the type of login in progress
(e.g., SQL Server, Windows, etc). fixes #3025
2014-04-17 15:36:43 -04:00
Mike Bayer 99ae0dc821 - Fixed bug in new :meth:.DialectKWArgs.argument_for method where
adding an argument for a construct not previously included for any
special arguments would fail. fixes #3024
2014-04-15 23:34:07 -04:00
Mike Bayer 0c4a1cf963 changelog 2014-04-14 14:58:27 -04:00
Mike Bayer 73095b3531 - Added a new "disconnect" message "connection has been closed unexpectedly".
This appears to be related to newer versions of SSL.
Pull request courtesy Antti Haapala.
2014-04-11 15:42:36 -04:00
mike bayer a48217b135 Merge pull request #84 from Daniel-B-Smith/master
Fixed bug in example code on orm session page.
2014-04-11 14:53:20 -04:00
Mike Bayer fcda519452 - Fixed regression introduced in 0.9 where new "ORDER BY <labelname>"
feature from 🎫`1068` would not apply quoting rules to the
label name as rendered in the ORDER BY.
fix #3020, re: #1068
2014-04-10 22:33:33 -04:00
Daniel Smith 10ea59241f Fixed bug in example code. 2014-04-10 19:15:17 -04:00
Mike Bayer 9f74861d6d - Added new utility function :func:.make_transient_to_detached which can
be used to manufacture objects that behave as though they were loaded
from a session, then detached.   Attributes that aren't present
are marked as expired, and the object can be added to a Session
where it will act like a persistent one. fix #3017
2014-04-09 17:49:16 -04:00
Mike Bayer e8c08b5d7b repair erroneous whitespace in autodoc directives, preventing members from
being documented
2014-04-06 18:14:44 -04:00
Mike Bayer 4527b6ab94 - Restored the import for :class:.Function to the `sqlalchemy.sql.expression`
import namespace, which was removed at the beginning of 0.9.
2014-04-05 21:05:29 -04:00
Mike Bayer a68fdf0d2f - add some docs for the instancestate linkage to the inspection system 2014-04-04 17:33:35 -04:00
Mike Bayer 2e5c8913a8 - Fixes to the newly enhanced boolean coercion in 🎫2804 where
the new rules for "where" and "having" woudn't take effect for the
"whereclause" and "having" kw arguments of the :func:`.select` construct,
which is also what :class:`.Query` uses so wasn't working in the
ORM either. fixes #3013 re: #2804
2014-04-01 13:03:52 -04:00
Mike Bayer e16ede8cae - Added new flag :paramref:.expression.between.symmetric, when set to True
renders "BETWEEN SYMMETRIC".  Also added a new negation operator
"notbetween_op", which now allows an expression like ``~col.between(x, y)``
to render as "col NOT BETWEEN x AND y", rather than a parentheiszed NOT
string.  fixes #2990
2014-03-30 21:20:20 -04:00
Mike Bayer f258c224d7 - fix mapper ref
- don't talk about "can't check for rows matched" here as we changed that in 0.9
2014-03-28 19:59:54 -04:00
Mike Bayer ccc0c44c3a 0.9.4 2014-03-28 19:40:09 -04:00
Mike Bayer d6618e4119 - Added new parameter :paramref:.mapper.confirm_deleted_rows. Defaults
to True, indicates that a series of DELETE statements should confirm
that the cursor rowcount matches the number of primary keys that should
have matched;  this behavior had been taken off in most cases
(except when version_id is used) to support the unusual edge case of
self-referential ON DELETE CASCADE; to accomodate this, the message
is now just a warning, not an exception, and the flag can be used
to indicate a mapping that expects self-refererntial cascaded
deletes of this nature.  See also 🎫`2403` for background on the
original change. re: #2403 fix #3007
2014-03-28 18:00:35 -04:00
Mike Bayer a0329f71ad - revert part of c01558ae7f for now as we also test that a DELETE of two rows
where one is to be deleted from ON DELETE CASCADE succeeds; the check here makes that fail.
We will need to add an option to enable/disable this check per mapping, will likely
do this in next version
2014-03-28 17:42:55 -04:00
Mike Bayer c01558ae7f - Fixed ORM bug where changing the primary key of an object, then marking
it for DELETE would fail to target the correct row for DELETE.
Then to compound matters, basic "number of rows matched" checks were
not being performed.  Both issues are fixed, however note that the
"rows matched" check requires so-called "sane multi-row count"
functionality; the DBAPI's executemany() method must count up the
rows matched by individual statements and SQLAlchemy's dialect must
mark this feature as supported, currently applies to some mysql dialects,
psycopg2, sqlite only. fixes #3006
- Enabled "sane multi-row count" checking for the psycopg2 DBAPI, as
this seems to be supported as of psycopg2 2.0.9.
2014-03-28 16:32:11 -04:00
Mike Bayer 4d93a52e77 - Added support to automap for the case where a relationship should
not be created between two classes that are in a joined inheritance
relationship, for those foreign keys that link the subclass back to
the superclass.
fixes #3004
2014-03-28 10:49:37 -04:00
Mike Bayer 825d3b0d6d - Fixed a very old behavior where the lazy load emitted for a one-to-many
could inappropriately pull in the parent table, and also return results
inconsistent based on what's in the parent table, when the primaryjoin
includes some kind of discriminator against the parent table, such
as ``and_(parent.id == child.parent_id, parent.deleted == False)``.
While this primaryjoin doesn't make that much sense for a one-to-many,
it is slightly more common when applied to the many-to-one side, and
the one-to-many comes as a result of a backref.
Loading rows from ``child`` in this case would keep ``parent.deleted == False``
as is within the query, thereby yanking it into the FROM clause
and doing a cartesian product.  The new behavior will now substitute
the value of the local "parent.deleted" for that parameter as is
appropriate.   Though typically, a real-world app probably wants to use a
different primaryjoin for the o2m side in any case.
fixes #2948
2014-03-27 20:38:46 -04:00
Mike Bayer 0611baa889 - Improved the check for "how to join from A to B" such that when
a table has multiple, composite foreign keys targeting a parent table,
the :paramref:`.relationship.foreign_keys` argument will be properly
interpreted in order to resolve the ambiguity; previously this condition
would raise that there were multiple FK paths when in fact the
foreign_keys argument should be establishing which one is expected.
fixes #2965
2014-03-27 19:43:15 -04:00
Mike Bayer 50576a01eb - Tweaked the settings for mysql-connector-python; in Py2K, the
"supports unicode statements" flag is now False, so that SQLAlchemy
will encode the *SQL string* (note: *not* the parameters)
to bytes before sending to the database.  This seems to allow
all unicode-related tests to pass for mysql-connector, including those
that use non-ascii table/column names, as well as some tests for the
TEXT type using unicode under cursor.executemany().
- other mysql-connector fixes; latest version seems to do better on
function call counts
2014-03-27 19:18:06 -04:00
Mike Bayer 1a35188b69 - Fixed regression caused by release 0.8.5 / 0.9.3's compatibility
enhancements where index reflection on Postgresql versions specific
to only the 8.1, 8.2 series again
broke, surrounding the ever problematic int2vector type.  While
int2vector supports array operations as of 8.1, apparently it only
supports CAST to a varchar as of 8.3.
fix #3000
2014-03-25 12:26:42 -04:00
Mike Bayer 7e6a5e7946 - fix some doctest failures (though some remain, as it's not easy to get doctest
to accept things flexibly), fix #2999
2014-03-24 11:48:18 -04:00
Mike Bayer 87d7076b49 - Added some new event mechanics for dialect-level events; the initial
implementation allows an event handler to redefine the specific mechanics
by which an arbitrary dialect invokes execute() or executemany() on a
DBAPI cursor.  The new events, at this point semi-public and experimental,
are in support of some upcoming transaction-related extensions.
2014-03-24 10:22:39 -04:00
Mike Bayer 39a8e2ed37 - Fixed regression from 0.8.3 as a result of 🎫2818
where :meth:`.Query.exists` wouldn't work on a query that only
had a :meth:`.Query.select_from` entry but no other entities.
re: #2818 fixes #2995
2014-03-22 19:55:00 -04:00
Mike Bayer b00e15b50f - An event listener can now be associated with a :class:.Engine,
after one or more :class:`.Connection` objects have been created
(such as by an orm :class:`.Session` or via explicit connect)
and the listener will pick up events from those connections.
Previously, performance concerns pushed the event transfer from
:class:`.Engine` to  :class:`.Connection` at init-time only, but
we've inlined a bunch of conditional checks to make this possible
without any additional function calls. fixes #2978
2014-03-22 19:34:18 -04:00
Mike Bayer 5d2bfc4df4 - Fixed a few errant `u''` strings that would prevent tests from passing
in Py3.2.  Patch courtesy Arfrever Frehtes Taifersar Arahesis. fixes #2980
2014-03-22 18:48:59 -04:00
Mike Bayer eed9cfc3ae - A major improvement made to the mechanics by which the :class:.Engine
recycles the connection pool when a "disconnect" condition is detected;
instead of discarding the pool and explicitly closing out connections,
the pool is retained and a "generational" timestamp is updated to
reflect the current time, thereby causing all existing connections
to be recycled when they are next checked out.   This greatly simplifies
the recycle process, removes the need for "waking up" connect attempts
waiting on the old pool and eliminates the race condition that many
immediately-discarded "pool" objects could be created during the
recycle operation. fixes #2985
2014-03-22 18:45:39 -04:00
Mike Bayer be3c185fd4 - Added new datatype :class:.oracle.DATE, which is a subclass of
:class:`.DateTime`.  As Oracle has no "datetime" type per se,
it instead has only ``DATE``, it is appropriate here that the
``DATE`` type as present in the Oracle dialect be an instance of
:class:`.DateTime`.  This issue doesn't change anything as far as
the behavior of the type, as data conversion is handled by the
DBAPI in any case, however the improved subclass layout will help
the use cases of inspecting types for cross-database compatibility.
Also removed uppercase ``DATETIME`` from the Oracle dialect as this
type isn't functional in that context.  fixes #2987
2014-03-22 18:22:17 -04:00
Mike Bayer ec97911ed9 - Adjusted `setup.py` file to support the possible future
removal of the ``setuptools.Feature`` extension from setuptools.
If this keyword isn't present, the setup will still succeed
with setuptools rather than falling back to distutils.  C extension
building can be disabled now also by setting the
DISABLE_SQLALCHEMY_CEXT environment variable.  This variable works
whether or not setuptools is even available. fixes #2986
- using platform.python_implementation() in setup.py to detect CPython.
I've tested this function on OSX and linux on Python 2.6 through 3.4,
including 3.1, 3.2, 3.3.
Unfortunately, on OSX + 3.2 only, it seems to segfault.  I've tried
installing 3.2.5 from the python.org .dmg, building it from source,
and also blew away the whole 3.2 directory, something seems to be wrong
with the "platform" module on that platform only, and there's also no
issue on bugs.python.org; however, I'm going with
it anyway. If someone is using 3.2 on OSX they really should be upgrading.
2014-03-22 17:31:50 -04:00
Mike Bayer c464960fdd changelog to fix #2988 2014-03-22 16:36:06 -04:00
Tony Narlock 07992a6697 Fix tag typo in changelog_09 2014-03-21 08:42:37 -05:00
Mike Bayer a22927b809 - reword the paragraph which talks about web framework integration for sessions:
1. fix the typo in the paragraph, fixes #2998
2. as zope-sqlalchemy only provides transaction integration and not session scoping,
dial back the language here as people are probably using scoped_session with pyramid anyway
3. as I'm going to again start recommending people don't cling to flask-sqlalchemy so hard,
take out the word "strongly" from the recommendation.
4. as flask is the only framework I can think of that actually has an explicit SQLAlchemy
layer that handles setting up scoped_session, take out the word "most", now it's "some web frameworks"
(by which it means "only flask...and flask-sqlalchemy is probably not worth using anyway")
2014-03-20 22:46:23 -04:00
Mike Bayer 2a1a79b6ce - The :meth:.ConnectionEvents.after_cursor_execute event is now
emitted for the "_cursor_execute()" method of :class:`.Connection`;
this is the "quick" executor that is used for things like
when a sequence is executed ahead of an INSERT statement, as well as
for dialect startup checks like unicode returns, charset, etc.
the :meth:`.ConnectionEvents.before_cursor_execute` event was already
invoked here.  The "executemany" flag is now always set to False
here, as this event always corresponds to a single execution.
Previously the flag could be True if we were acting on behalf of
an executemany INSERT statement.
2014-03-19 13:03:44 -04:00