Commit Graph

5269 Commits

Author SHA1 Message Date
Mike Bayer 39837686b0 - calling str() on a core sql construct has been made more "friendly",
when the construct contains non-standard sql elements such as
returning, array index operations, or dialect-specific or custom
datatypes.  a string is now returned in these cases rendering an
approximation of the construct (typically the postgresql-style
version of it) rather than raising an error. fixes #3631
- add within_group to top-level imports
- add eq_ignore_whitespace to sqlalchemy.testing imports
2016-01-19 16:47:16 -05:00
Mike Bayer b7bc704f3d - Fixed issue where two same-named relationships that refer to
a base class and a concrete-inherited subclass would raise an error
if those relationships were set up using "backref", while setting up the
identical configuration using relationship() instead with the conflicting
names would succeed, as is allowed in the case of a concrete mapping.
fixes #3630
2016-01-19 13:34:42 -05:00
Mike Bayer 2a7f37b7b0 - The `str() call for :class:.Query` will now take into account
the :class:`.Engine` to which the :class:`.Session` is bound, when
generating the string form of the SQL, so that the actual SQL
that would be emitted to the database is shown, if possible.  Previously,
only the engine associated with the :class:`.MetaData` to which the
mappings are associated would be used, if present.  If
no bind can be located either on the :class:`.Session` or on
the :class:`.MetaData` to which the mappings are associated, then
the "default" dialect is used to render the SQL, as was the case
previously.  fixes #3081
2016-01-19 12:44:42 -05:00
Mike Bayer d4d9a65248 - Fixed bug where some exception re-raise scenarios would attach
the exception to itself as the "cause"; while the Python 3 interpreter
is OK with this, it could cause endless loops in iPython.
fixes #3625
- add tests for reraise, raise_from_cause
- raise_from_cause is the same on py2k/3k, use just one function
2016-01-18 17:35:44 -05:00
Mike Bayer 1f7a1f777d - A deep improvement to the recently added :meth:.TextClause.columns
method, and its interaction with result-row processing, now allows
the columns passed to the method to be positionally matched with the
result columns in the statement, rather than matching on name alone.
The advantage to this includes that when linking a textual SQL statement
to an ORM or Core table model, no system of labeling or de-duping of
common column names needs to occur, which also means there's no need
to worry about how label names match to ORM columns and so-forth.  In
addition, the :class:`.ResultProxy` has been further enhanced to
map column and string keys to a row with greater precision in some
cases.  fixes #3501
- reorganize the initialization of ResultMetaData for readability
and complexity; use the name "cursor_description", define the
task of "merging" cursor_description with compiled column information
as its own function, and also define "name extraction" as a separate task.
- fully change the name we use in the "ambiguous column" error to be the
actual name that was ambiguous, modify the C ext also
2016-01-14 18:06:26 -05:00
Mike Bayer 0ff3f95d5b - there was a DATEPART test after all, fix format 2016-01-14 17:50:03 -05:00
Mike Bayer 215167d8d3 - changelog for pr bitbucket:70, fixes #3624 2016-01-12 09:53:09 -05:00
Mike Bayer b301f009e1 - refactor a bit the loader options system to make it a bit more
intelligible, given the fixes for ref #3623.  unfortunately the system
is still quite weird even though it was rewritten to be... less weird
2016-01-10 17:47:38 -05:00
Mike Bayer c7ae0daf0e - Fixed regression since 0.9 where the 0.9 style loader options
system failed to accommodate for multiple :func:`.undefer_group`
loader options in a single query.   Multiple :func:`.undefer_group`
options will now be taken into account even against the same
entity. fixes #3623
2016-01-09 10:10:20 -05:00
Mike Bayer 89facbed88 - Multi-tenancy schema translation for :class:.Table objects is added.
This supports the use case of an application that uses the same set of
:class:`.Table` objects in many schemas, such as schema-per-user.
A new execution option
:paramref:`.Connection.execution_options.schema_translate_map` is
added. fixes #2685
- latest tox doesn't like the {posargs} in the profile rerunner
2016-01-08 22:12:25 -05:00
Mike Bayer ff803b1a2a - pg8000 fixes for json 2016-01-07 11:04:58 -05:00
Mike Bayer cd8adfe418 - add a do-nothing for mock url _instantiate_plugins 2016-01-06 20:10:28 -05:00
Mike Bayer c8b7729338 - Added a new entrypoint system to the engine to allow "plugins" to
be stated in the query string for a URL.   Custom plugins can
be written which will be given the chance up front to alter and/or
consume the engine's URL and keyword arguments, and then at engine
create time will be given the engine itself to allow additional
modifications or event registration.  Plugins are written as a
subclass of :class:`.CreateEnginePlugin`; see that class for
details.
fixes #3536
2016-01-06 17:20:57 -05:00
Mike Bayer 93d71b80f2 - add a few JSON tests specific to MySQL, including basic reflection 2016-01-06 13:18:04 -05:00
Mike Bayer a80bb4e5aa - Added :class:.mysql.JSON for MySQL 5.7. The JSON type provides
persistence of JSON values in MySQL as well as basic operator support
of "getitem" and "getpath", making use of the ``JSON_EXTRACT``
function in order to refer to individual paths in a JSON structure.
fixes #3547
- Added a new type to core :class:`.types.JSON`.  This is the
base of the PostgreSQL :class:`.postgresql.JSON` type as well as that
of the new :class:`.mysql.JSON` type, so that a PG/MySQL-agnostic
JSON column may be used.  The type features basic index and path
searching support.
fixes #3619
- reorganization of migration docs etc. to try to refer both to
the fixes to JSON that helps Postgresql while at the same time
indicating these are new features of the new base JSON type.
- a rework of the Array/Indexable system some more, moving things
that are specific to Array out of Indexable.
- new operators for JSON indexing added to core so that these can
be compiled by the PG and MySQL dialects individually
- rename sqltypes.Array to sqltypes.ARRAY - as there is no generic
Array implementation, this is an uppercase type for now, consistent
with the new sqltypes.JSON type that is also not a generic implementation.
There may need to be some convention change to handle the case of
datatypes that aren't generic, rely upon DB-native implementations,
but aren't necessarily all named the same thing.
2016-01-06 12:47:48 -05:00
Mike Bayer 197ffa2be2 - Fixed 1.0 regression where the eager fetch of cursor.rowcount was
no longer called for an UPDATE or DELETE statement emitted via plain
text or via the :func:`.text` construct, affecting those drivers
that erase cursor.rowcount once the cursor is closed such as SQL
Server ODBC and Firebird drivers.
fixes #3622
2016-01-05 10:25:36 -05:00
Mike Bayer 04b1a52783 - break out mysql/base into modules as it's getting huge with more to come 2016-01-04 17:37:23 -05:00
Mike Bayer c7d6c667b5 - Fixed an assertion that would raise somewhat inappropriately
if a :class:`.Index` were associated with a :class:`.Column` that
is associated with a lower-case-t :class:`.TableClause`; the
association should be ignored for the purposes of associating
the index with a :class:`.Table`.
fixes #3616
2015-12-23 22:59:44 -05:00
Mike Bayer 8c54b14b5c - An adjustment to the regular expression used to parse MySQL views,
such that we no longer assume the "ALGORITHM" keyword is present in
the reflected view source, as some users have reported this not being
present in some Amazon RDS environments.
fixes #3613
2015-12-22 12:04:45 -05:00
Mike Bayer 0c8242b26e - varchar requires a length 2015-12-22 11:19:44 -05:00
Mike Bayer 4b708c4839 - add the test from ref #3614 as well for testing ref #3611 2015-12-21 21:42:45 -05:00
Mike Bayer 913858c949 - Further fixes to 🎫3605, pop method on :class:.MutableDict,
where the "default" argument was not included.
fixes #3605
2015-12-17 11:24:35 -05:00
Mike Bayer a22b208506 - Fixed bug in baked loader system where the systemwide monkeypatch
for setting up baked lazy loaders would interfere with other
loader strategies that rely on lazy loading as a fallback, e.g.
joined and subquery eager loaders, leading to ``IndexError``
exceptions at mapper configuration time.
fixes #3612
2015-12-15 21:44:00 -05:00
Mike Bayer a8ec349198 - Fixed regression caused in 1.0.10 by the fix for 🎫3593 where
the check added for a polymorphic joinedload from a
poly_subclass->class->poly_baseclass connection would fail for the
scenario of class->poly_subclass->class.
fixes #3611
2015-12-15 14:00:50 -05:00
Mike Bayer c42725ed54 - add some more oracle skips 2015-12-14 20:22:04 -05: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 7d96ad4d53 - Fixed bug where use of the :meth:.Query.select_from method would
cause a subsequent call to the :meth:`.Query.with_parent` method to
fail. fixes #3606
- add mark-as-fail test for #3607
2015-12-12 21:08:56 -05:00
Mike Bayer 5710a1e88b - Added support for the `dict.pop() and dict.popitem()` methods
to the :class:`.mutable.MutableDict` class.
fixes #3605
2015-12-11 11:21:46 -05:00
Mike Bayer d533b8e922 - The ORM and Core tutorials, which have always been in doctest format,
are now exercised within the normal unit test suite in both Python
2 and Python 3.
- remove the old testdocs.py runner and replace with test/base/test_tutorials.py
- use pytest's unicode fixer so that we can test for unicode strings
in both py2k/3k
- use py3k format overall for prints, exceptions
- add other fixers to guarantee deterministic results
- add skips and ellipses to outputs that aren't worth matching
2015-12-10 17:09:47 -05:00
Mike Bayer e57bf79616 - Fixed issue within the :meth:.Insert.from_select construct whereby
the :class:`.Select` construct would have its ``._raw_columns``
collection mutated in-place when compiling the :class:`.Insert`
construct, when the target :class:`.Table` has Python-side defaults.
The :class:`.Select` construct would compile standalone with the
erroneous column present subsequent to compilation of the
:class:`.Insert`, and the the :class:`.Insert` statement itself would
fail on a second compile attempt due to duplicate bound parameters.
fixes #3603
2015-12-09 18:15:25 -05:00
Mike Bayer f4a1129e79 - fix changelog for #3602
- add version switch for backend fsp test

(cherry picked from commit 67b22cee3a)
2015-12-08 13:50:25 -05:00
Mike Bayer 7df4054b04 - make this DROP conditional, attempting to isolate why jenkins has
an issue with just one test
2015-12-08 10:40:45 -05:00
Mike Bayer 3f42743d6a - Fixed bug in MySQL reflection where the "fractional sections portion"
of the :class:`.mysql.DATETIME`, :class:`.mysql.TIMESTAMP` and
:class:`.mysql.TIME` types would be incorrectly placed into the
``timestamp`` attribute, which is unused by MySQL, instead of the
``fsp`` attribute.
fixes #3602
2015-12-07 17:24:09 -05:00
Mike Bayer d7eae8c95c - flake8 test_reflection and rework the type-based tests into
individual categories w/ modernized fixtures, assert attributes
within type objects.
2015-12-07 17:09:11 -05:00
Mike Bayer 3ec9b9f6b6 - The :meth:.Session.merge method now tracks pending objects by
primary key before emitting an INSERT, and merges distinct objects with
duplicate primary keys together as they are encountered, which is
essentially semi-deterministic at best.   This behavior
matches what happens already with persistent objects.
fixes #3601
2015-12-04 11:52:16 -05:00
Mike Bayer 935bc34dc5 - Fixed issue where post_update on a many-to-one relationship would
fail to emit an UPDATE in the case where the attribute were set to
None and not previously loaded.
fixes #3599
2015-12-02 12:13:57 -05:00
Mike Bayer 9695faf329 - Fixed bug where CREATE TABLE with a no-column table, but a constraint
such as a CHECK constraint would render an erroneous comma in the
definition; this scenario can occur such as with a Postgresql
INHERITS table that has no columns of its own.
fixes #3598
2015-12-01 19:03:03 -05:00
Mike Bayer 9c2c247563 Merge remote-tracking branch 'origin/pr/216' 2015-11-30 13:02:39 -05:00
Mike Bayer a09fc9740d Merge remote-tracking branch 'origin/pr/215' 2015-11-30 12:57:47 -05:00
Mike Bayer d5fd26b836 Merge remote-tracking branch 'origin/pr/212' 2015-11-30 12:46:45 -05:00
Mike Bayer 03a3b5ffd3 - A descriptive ValueError is now raised in the event that SQL server
returns an invalid date or time format from a DATE or TIME
column, rather than failing with a NoneType error.  Pull request
courtesy Ed Avis.
pullreq github:206
2015-11-30 12:19:26 -05:00
Mike Bayer 2b39f09e73 Merge remote-tracking branch 'origin/pr/218' 2015-11-30 11:53:09 -05:00
Iuri de Silvio d9178320d6 Fix _assert_unorderable_types on py36.
The error message changed to:

`'<' not supported between instances of 'foo' and 'bar'`
2015-11-30 14:50:25 -02:00
Mike Bayer e45e4aa97d Merge remote-tracking branch 'origin/pr/210' 2015-11-30 11:40:44 -05:00
Mike Bayer 4fcd93afb8 - close the session 2015-11-29 21:50:50 -05:00
Mike Bayer b0308a7b3a - Fixed an issue in baked queries where the .get() method, used either
directly or within lazy loads, didn't consider the mapper's "get clause"
as part of the cache key, causing bound parameter mismatches if the
clause got re-generated.  This clause is cached by mappers
on the fly but in highly concurrent scenarios may be generated more
than once when first accessed.
fixes #3597
2015-11-29 11:42:55 -05:00
Mike Bayer c90f0a49f3 - Added support for parameter-ordered SET clauses in an UPDATE
statement.  This feature is available by passing the
:paramref:`~.sqlalchemy.sql.expression.update.preserve_parameter_order`
flag either to the core :class:`.Update` construct or alternatively
adding it to the :paramref:`.Query.update.update_args` dictionary at
the ORM-level, also passing the parameters themselves as a list of 2-tuples.
Thanks to Gorka Eguileor for implementation and tests.
adapted from pullreq github:200
2015-11-28 14:30:05 -05:00
Mike Bayer 1202e140b9 - Fixed bug which is actually a regression that occurred between
versions 0.8.0 and 0.8.1, due 🎫`2714`.  The case where
joined eager loading needs to join out over a subclass-bound
relationship when "with_polymorphic" were also used would fail
to join from the correct entity.
fixes #3593
2015-11-25 15:29:04 -05:00
Nils Philippsen 58f73d2278 py2k: accept unicode literals on :func:backref, too
Fixed bug where in Py2K a unicode literal would not be accepted as the
string name of a class or other argument within declarative using
:func:`.backref` on :func:`.relationship`.

amends commit e6f67f4805
2015-11-25 16:03:59 +01:00