Commit Graph

45 Commits

Author SHA1 Message Date
Mike Bayer 2efd89d029 Add SQL Server CI coverage
Change-Id: Ida0d01ae9bcc0573b86e24fddea620a38c962822
2017-08-31 17:20:26 -04:00
Mike Bayer c4d6596ba3 Additional fixes to sane rowcount
Implement rowcount assertions and single row check
for post_update as well as deletes.

Change-Id: I4e5ba7e8747bf0e0b41f569089eb8cdbf064b7a9
Fixes: #4062
2017-08-31 15:27:26 -04:00
Mike Bayer 64b0760faa Add all versioning logic to _post_update()
An UPDATE emitted as a result of the
:paramref:`.relationship.post_update` feature will now integrate with
the versioning feature to both bump the version id of the row as well
as assert that the existing version number was matched.

Fixes: #3496
Change-Id: I865405dd6069f1c1e3b0d27a4980e9374e059f97
2017-06-15 18:58:29 -04:00
Mike Bayer de11c5217b Add with_for_update() support in session.refresh()
Session.refresh() is still hardcoded to legacy lockmode,
come up with a new API so that the newer argument style
works with it.

Added new argument :paramref:`.with_for_update` to the
:meth:`.Session.refresh` method.  When the :meth:`.Query.with_lockmode`
method were deprecated in favor of :meth:`.Query.with_for_update`,
the :meth:`.Session.refresh` method was never updated to reflect
the new option.

Change-Id: Ia02a653746b7024699b515451525a88d7a17d63a
Fixes: #3991
2017-05-24 16:23:56 -04:00
Diana Clarke 990d4c799f detect and raise for version_id is NULL
The versioning feature does not support NULL for the version counter.
An exception is now raised if the version id is programmatic and
was set to NULL for an UPDATE.  Pull request courtesy Diana Clarke.

Fixes: #3673
Change-Id: I8b0da56234a7c7f5e7fde35536e09a6216a5e48a
2017-05-22 16:25:54 -04:00
Mike Bayer 0a67c13052 Detect no params w/ manual version_id counter and set to itself
Fixed bug where programmatic version_id counter in conjunction with
joined table inheritance would fail if the version_id counter
were not actually incremented and no other values on the base table
were modified, as the UPDATE would have an empty SET clause.  Since
programmatic version_id where version counter is not incremented
is a documented use case, this specific condition is now detected
and the UPDATE now sets the version_id value to itself, so that
concurrency checks still take place.

Change-Id: I80e385bffeed4851cc20131cbe983c173a46f655
Fixes: #3996
2017-05-22 14:47:26 -04:00
Mike Bayer f8ecdf47f0 Allow SQL expressions to be set on PK columns
Removes an unnecessary transfer of modified PK column
value to the params dictionary, so that if the modified PK column
is already present in value_params, this remains in effect.  Also
propagate a new flag through to _emit_update_statements() that will
trip "return_defaults()" across the board if a PK col w/ SQL expression
change is present, and pull this PK value in _postfetch as well assuming
we're an UPDATE.

Change-Id: I9ae87f964df9ba8faea8e25e96b8327f968e5d1b
Fixes: #3801
2016-09-20 11:33:16 -04:00
Mike Bayer 26ed90ab22 - Fixed bug where :meth:.Session.bulk_update_mappings and related
would not bump a version id counter when in use.  The experience
here is still a little rough as the original version id is required
in the given dictionaries and there's not clean error reporting
on that yet.
fixes #3610
2015-12-14 17:39:50 -05:00
Mike Bayer 0e4c4d7efc - Fixed bug in :meth:.Update.return_defaults which would cause all
insert-default holding columns not otherwise included in the SET
clause (such as primary key cols) to get rendered into the RETURNING
even though this is an UPDATE.

- Major fixes to the :paramref:`.Mapper.eager_defaults` flag, this
flag would not be honored correctly in the case that multiple
UPDATE statements were to be emitted, either as part of a flush
or a bulk update operation.  Additionally, RETURNING
would be emitted unnecessarily within update statements.

fixes #3609
2015-12-14 17:30:21 -05:00
Mike Bayer 1e0afd584c - Fixed regression in 1.0 where new feature of using "executemany"
for UPDATE statements in the ORM (e.g. :ref:`feature_updatemany`)
would break on Postgresql and other RETURNING backends
when using server-side version generation
schemes, as the server side value is retrieved via RETURNING which
is not supported with executemany.
fixes #3556
2015-10-19 12:17:37 -04:00
Mike Bayer 1835be36fc - add autoinc marker for oracle 2015-06-25 11:11:00 -04:00
Mike Bayer 1e2f1f5baa - Fixed a major regression in the 1.0 series where the version_id_counter
feature would cause an object's version counter to be incremented
when there was no net change to the object's row, but instead an object
related to it via relationship (e.g. typically many-to-one)
were associated or de-associated with it, resulting in an UPDATE
statement that updates the object's version counter and nothing else.
In the use case where the relatively recent "server side" and/or
"programmatic/conditional" version counter feature were used
(e.g. setting version_id_generator to False), the bug could cause an
UPDATE without a valid SET clause to be emitted.
fixes #3465
2015-06-24 21:53:15 -04:00
Mike Bayer 6135c03230 - further fixes and even better tests for this block 2015-01-19 11:47:28 -05:00
Mike Bayer 0bd074cc5a - continue moving things out that don't need to be there
- an existing state shouldn't need its load_options/load_path updated;
it should maintain those from its original Query source.  there's no
tests that check this behavior
2014-08-30 02:35:35 -04:00
Mike Bayer 759e8aec13 - fix whitespace 2014-07-25 20:23:10 -04:00
Tony Locke ebf74bd659 PEP8 tidy for test/orm/test_versioning.py 2014-07-19 20:20:12 +01: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 82a67abf4b - fix the uuid routine here to not run out of uuids 2014-03-24 11:57:38 -04:00
Mike Bayer 2f150bee28 - rename __multiple__ to __backend__, and apply __backend__ to a large number of tests.
- move out logging tests from test_execute to test_logging
2014-03-24 11:33:53 -04:00
Mike Bayer 5a6895471f - modify what we did in [ticket:2793] so that we can also set the
version id programmatically outside of the generator.   using this system,
we can also leave the version id alone.
2013-09-06 21:39:36 -04:00
Mike Bayer e9c748a7bf - ensure rowcount is returned for an UPDATE with no implicit returning
- modernize test for that
- use py3k compatible next() in test_returning/test_versioning
2013-08-25 17:37:59 -04:00
Mike Bayer d6ce68727f - The `version_id_generator parameter of Mapper` can now be specified
to rely upon server generated version identifiers, using triggers
or other database-provided versioning features, by passing the value
``False``.  The ORM will use RETURNING when available to immediately
load the new version identifier, else it will emit a second SELECT.
[ticket:2793]
- The ``eager_defaults`` flag of :class:`.Mapper` will now allow the
newly generated default values to be fetched using an inline
RETURNING clause, rather than a second SELECT statement, for backends
that support RETURNING.
- Added a new variant to :meth:`.ValuesBase.returning` called
:meth:`.ValuesBase.return_defaults`; this allows arbitrary columns
to be added to the RETURNING clause of the statement without interfering
with the compilers usual "implicit returning" feature, which is used to
efficiently fetch newly generated primary key values.  For supporting
backends, a dictionary of all fetched values is present at
:attr:`.ResultProxy.returned_defaults`.
- add a glossary entry for RETURNING
- add documentation for version id generation, [ticket:867]
2013-08-25 14:03:54 -04:00
Mike Bayer be40b51cb0 getting everything to pass again 2012-09-27 16:33:54 -04:00
Mike Bayer 20cdc64588 trying different approaches to test layout. in this one, the testing modules
become an externally usable package but still remains within the main sqlalchemy parent package.
in this system, we use kind of an ugly hack to get the noseplugin imported outside of the
"sqlalchemy" package, while still making it available within sqlalchemy for usage by
third party libraries.
2012-09-27 02:37:33 -04:00
Mike Bayer b76995600a - [bug] Fixed bug where incorrect type information
would be passed when the ORM would bind the
"version" column, when using the "version" feature.
Tests courtesy Daniel Miller.  [ticket:2539]
2012-09-16 21:15:55 -04:00
Daniel Miller c5d06d6f5d Added test and fix for version_id_col bug. 2012-09-12 11:59:59 -04:00
Mike Bayer 22ba1c43b7 -whitespace bonanza, contd 2012-07-28 17:05:50 -04:00
Philip Jenvey 2101cf7f40 wrap another StaleDataError detection in supports_sane_row_count 2011-05-11 18:58:11 -07:00
Philip Jenvey 24e6c56da8 update warnings per zxjdbc 2011-04-23 14:15:08 -07:00
Mike Bayer 7b24e458c7 - move all the comments that got shoved below the fixture grabs back up 2011-03-27 17:19:00 -04:00
Mike Bayer 68a350d462 - remove test.sql._base, test.engine._base, test.orm._base, move those classes to a new test.lib.fixtures module
- move testing.TestBase to test.lib.fixtures
- massive search and replace
2011-03-27 16:27:27 -04:00
Mike Bayer a3083eabf4 - move all the setup_classes(cls) and setup_mappers(cls) to use a
local cls.Basic, cls.Comparable base class so that there is no ambiguity
or hash identity behaviors getting in the way of class registration.
2011-03-27 15:04:06 -04:00
Mike Bayer 14a2fae239 - remove @testing.resolve_artifact_names, replace with direct attribute
access to the cls/self.tables/classes registries
- express orm/_base.py ORMTest in terms of engine/_base.py TablesTest,
factor out common steps into TablesTest, remove AltEngineTest as a
separate class.   will further consolidate these base classes
2011-03-26 19:03:11 -04:00
Mike Bayer 3ac7ec476e - fix oracle tests
- fix some obnoxious type adaption issues resulting from the "adapt must copy" change
2011-01-25 22:37:18 -05:00
Mike Bayer b3dd50a8da - Session.merge() will check the version id of the incoming
state against that of the database, assuming the mapping
uses version ids and incoming state has a version_id
assigned, and raise StaleDataError if they don't
match.  [ticket:2027]
2011-01-18 16:34:34 -05:00
Mike Bayer 350aed3fdb - whitespace removal bonanza 2011-01-02 14:23:42 -05:00
Mike Bayer 3351c35edb - merge rfc0b9df5d9e0 from 0.6 branch 2010-12-28 15:01:19 -05:00
Mike Bayer e1402efb19 - move sqlalchemy.test to test.lib 2010-11-15 19:37:50 -05:00
Mike Bayer c09b79d61e - 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.
2010-08-01 18:24:35 -04:00
Mike Bayer 8e0618aa65 - 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
2010-07-24 10:10:28 -04:00
Mike Bayer dbc582a43f - apparently [ticket:1761] was covered in tests already.
- Usage of version_id_col on a backend that supports
cursor.rowcount for execute() but not executemany() now works
when a delete is issued (already worked for saves, since those
don't use executemany()). For a backend that doesn't support
cursor.rowcount at all, a warning is emitted the same
as with saves.  [ticket:1761]
2010-04-04 10:18:16 -04:00
Mike Bayer 75e14f855e - Session.refresh() now does an equivalent expire()
on the given instance first, so that the "refresh-expire"
cascade is propagated.   Previously, refresh() was
not affected in any way by the presence of "refresh-expire"
cascade.   This is a change in behavior versus that
of 0.6beta2, where the "lockmode" flag passed to refresh()
would cause a version check to occur.  Since the instance
is first expired, refresh() always upgrades the object
to the most recent version.

- The 'refresh-expire' cascade, when reaching a pending object,
will expunge the object if the cascade also includes
"delete-orphan", or will simply detach it otherwise.
[ticket:1754]
2010-03-29 17:56:02 -04:00
Mike Bayer b2741d8b77 - added "lockmode" kw argument to Session.refresh(), will
pass through the string value to Query the same as
in with_lockmode(), will also do version check for a
version_id_col-enabled mapping.
2010-03-19 13:10:13 -04:00
Mike Bayer 065fcbd9d2 - The official name for the relation() function is now
relationship(), to eliminate confusion over the relational
algebra term.  relation() however will remain available
in equal capacity for the foreseeable future.  [ticket:1740]
2010-03-17 17:48:29 -04:00
Mike Bayer 84c6857d21 - Fixed bug which caused "row switch" logic, that is an
INSERT and DELETE replaced by an UPDATE, to fail when
version_id_col was in use. [ticket:1692]

- Added "version_id_generator" argument to Mapper, this is a
callable that, given the current value of the "version_id_col",
returns the next version number.  Can be used for alternate
versioning schemes such as uuid, timestamps.  [ticket:1692]
2010-03-16 12:58:13 -04:00