Commit Graph

1206 Commits

Author SHA1 Message Date
Jamie Alessio 5efde68c99 Fix typos ('expicit' -> 'explicit')
(cherry picked from commit 3771af0af4)
2017-03-18 14:58:14 -04:00
Andrii Soldatenko 575ec4a5b8 Support python3.6
Corrects some warnings and adds tox config.  Adds DeprecationWarning
to the error category.   Large sweep for string literals w/ backslashes
as this is common in docstrings

Co-authored-by: Andrii Soldatenko
Fixes: #3886
Change-Id: Ia7c838dfbbe70b262622ed0803d581edc736e085
Pull-request: https://github.com/zzzeek/sqlalchemy/pull/337
2017-01-13 11:08:35 -05:00
Mike Bayer bc4cf9480e Repair foreign_keys population for Join._refresh_for_new_column
Fixed bug where setting up a single-table inh subclass of a joined-table
subclass which included an extra column would corrupt the foreign keys
collection of the mapped table, thereby interfering with the
initialization of relationships.

Change-Id: I04a0cf98fd456d12d5a5b9e77a46a01246969a63
Fixes: #3797
(cherry picked from commit 8967099c3ba8b04fa20536bc0a026f6adc8e096f)
2016-09-15 00:56:46 -04:00
Mike Bayer a736be3feb Allow Table._reset_exported to silently pass
Fixed bug in :class:`.Table` where the internal method
``_reset_exported()`` would corrupt the state of the object.  This
method is intended for selectable objects and is called by the ORM
in some cases; an erroneous mapper configuration would could lead the
ORM to call this on on a :class:`.Table` object.

Change-Id: I63fa34ee0cdf16358bb125c556390df79758bcbc
Fixes: #3755
(cherry picked from commit 149fb5f55a5df3f31f6575919a5a5a2e5ba9cb0c)
2016-07-24 17:41:14 -04:00
Mike Bayer b3a424dacc - a variety of test adjustments to accomodate for MySQL 5.7
Change-Id: Ied4245433d0d7b469dae6e7394c4931d8405f387
(cherry picked from commit 02190234a2)
2016-07-24 16:42:00 -04:00
Mike Bayer 9880da342f Preserve type for math negation
Fixed issue in SQL math negation operator where the type of the
expression would no longer be the numeric type of the original.
This would cause issues where the type determined result set
behaviors.

Change-Id: If0e339614a3686e251235fc94b6f59310c4630a5
Fixes: #3735
(cherry picked from commit 5c60aaefd3)
2016-07-01 12:45:51 -04:00
Mike Bayer e7ea2a4e19 Deprecate FromClause.count() (pending for 1.1)
count() here is misleading in that it not only
counts from an arbitrary column in the table, it also
does not make accommodations for DISTINCT, JOIN, etc.
as the ORM-level function does.  Core should not be
attempting to provide a function like this.

Change-Id: I9916fc51ef744389a92c54660ab08e9695b8afc2
Fixes: #3724
2016-06-13 15:37:46 -04:00
Mike Bayer 33e2a0230e Ensure CTE internals are handled during clone
The CTE construct was missing a _copy_internals() method
which would handle CTE-specific structures including _cte_alias,
_restates during a clone operation.

Change-Id: I9aeac9cd24d8f7ae6b70e52650d61f7c96cb6d7e
Fixes: #3722
(cherry picked from commit 7189d0bc82)
2016-06-10 17:27:06 -04:00
Mike Bayer d318139fdc Skip UniqueConstraint marked by unique=True in tometadata
Fixes an issue where a Column would be copied with unique=True
and at the same time the UniqueConstraint would also be copied,
leading to duplicate UniqueConstraints in the target table,
when tometadata() is used.   Imitates the same logic used
by index=True/Index to avoid duplicates.  For some reason
a fix was implemented for Index long ago but never for
UniqueConstraint.

Change-Id: Ie622ee912a6fb8bf0ea900a8b09d78c7ebc79fc0
Fixes: #3721
(cherry picked from commit afb466fb8b)
2016-06-02 13:54:38 -04:00
Mike Bayer 4b31736343 Support "blank" schema when MetaData.schema is set
Previously, it was impossible to have a Table that has
None for a schema name when the "schema" parameter on
MetaData was set.  A new symbol sqlalchemy.schema.BLANK_SCHEMA
is added which indicates that the schema name should unconditionally
be set to None.  In particular, this value must be passed within
cross-schema foreign key reflection, so that a Table which
is in the "default" schema can be represented properly.

Fixes: #3716
Change-Id: I3d24f99c22cded206c5379fd32a225e74edb7a8e
(cherry picked from commit c124fa36d5)
2016-05-18 11:44:56 -04:00
Mike Bayer c250525953 Don't double-process ResultMetaData for BufferedColumnResultProxy
Fixed a bug in the result proxy used mainly by Oracle when binary and
other LOB types are in play, such that when query / statement caching
were used, the type-level result processors, notably that required by
the binary type itself but also any other processor, would become lost
after the first run of the statement due to it being removed from the
cached result metadata.

Change-Id: I751940866cffb4f48de46edc8137482eab59790c
Fixes: #3699
(cherry picked from commit f3bc60bdd8)
2016-04-27 11:47:07 -05:00
Mike Bayer 3db48cc627 Fix result set handling for case insensitive dupe cols
Fixed bug where when using ``case_sensitive=False`` with an
:class:`.Engine`, the result set would fail to correctly accomodate
for duplicate column names in the result set, causing an error
when the statement is executed in 1.0, and preventing the
"ambiguous column" exception from functioning in 1.1.

Change-Id: If582bb9fdd057e4da3ae42f7180b17d1a1a2d98e
Fixes: #3690
(cherry picked from commit 1f3e5d9826)
2016-04-21 10:39:14 -04:00
Mike Bayer bdd29fd56b - move all resultproxy tests intio test_resultset, adapted from
03d35a833c in master (not cherry-picked)
2016-03-30 17:44:04 -04:00
Mike Bayer dfe49c7b7f - Fixed bug where the negation of an EXISTS expression would not
be properly typed as boolean in the result, and also would fail to be
anonymously aliased in a SELECT list as is the case with a
non-negated EXISTS construct.
fixes #3682

(cherry picked from commit 07a4b6cbcd)
2016-03-21 10:58:08 -04:00
Mike Bayer d2adf94115 - move out unconsumed names tests from test_compiler out to test_insert, test_update
- establish consistent names between existing unconsumed names tests and new ones
added per ref #3666

(cherry picked from commit 6b7c207801)
2016-03-02 20:26:14 -05:00
Athena Yao dfde3b2211 Add test for inserting multiple values
(cherry picked from commit a1de176d23)
2016-03-02 20:25:59 -05:00
Mike Bayer aa9ce3f521 - additional adjustment to the fix made in 8ad968f331
for ref #3657.  The Oracle dialect makes more use of the "select_wraps_for"
feature than SQL server because Oracle doesn't have "TOP" for a limit-only
select, so tests are showing more happening here.  In the case where
the select() has some dupe columns, these are deduped from the .c collection
so a positional match between the wrapper and original can't use .inner_columns,
because these collections wont match.  Using _columns_plus_names
instead which is the deduped collection that determines the SELECT display,
which definitely have to match up.
2016-02-21 22:46:31 -05:00
Mike Bayer cf818984ab - reworked the way the "select_wraps_for" expression is
handled within visit_select(); this attribute was added in the
1.0 series to accommodate the subquery wrapping behavior of
SQL Server and Oracle while also working with positional
column targeting and no longer relying upon "key fallback"
in order to target columns in such a statement.  The IBM DB2
third-party dialect also has this use case, but its implementation
is using regular expressions to rewrite the textual SELECT only
and does not make use of a "wrapped" select at this time.
The logic no longer attempts to reconcile proxy set collections as
this was not deterministic, and instead assumes that the select()
and the wrapper select() match their columns postionally,
at least for the column positions they have in common,
so it is now very simple and safe.  fixes #3657.
- as a side effect of #3657 it was also revealed that the
strategy of calling upon a ResultProxy._getter was not
correctly calling into NoSuchColumnError when an expected
column was not present, and instead returned None up to
loading.instances() to produce NoneType failures; added
a raiseerr argument to _getter() which is called when we
aren't expecting None, fixes #3658.

(cherry picked from commit 8ad968f331)
2016-02-20 20:30:58 -05:00
Mike Bayer 498b0729b2 - Fixed bug in :func:.expression.text construct where a double-colon
expression would not escape properly, e.g. ``some\:\:expr``, as is most
commonly required when rendering Postgresql-style CAST expressions.
fixes #3644

(cherry picked from commit 29dcaa2b0a)
2016-02-09 18:06:15 -05:00
Mike Bayer e2404a4e3f - add literal_binds for delete() statements in addition to insert()/update()
- move tests to CRUDTest
- changelog, fixes #3643

(cherry picked from commit 150591f9e0)
2016-02-03 11:10:40 -05:00
Tim Tate f87fe4c351 fix passing literal_binds flag through for update and insert
(cherry picked from commit c9b03fa8af)
2016-02-03 11:10:38 -05:00
Mike Bayer 69f6a8d714 - Fixed issue where inadvertent use of the Python `__contains__`
override with a column expression (e.g. by using ``'x' in col``)
would cause an endless loop in the case of an ARRAY type, as Python
defers this to ``__getitem__`` access which never raises for this
type.  Overall, all use of ``__contains__`` now raises
NotImplementedError.
fixes #3642

(cherry picked from commit e0a580b3d0)
2016-02-02 10:41:01 -05:00
Mike Bayer c7ddf26dd2 - rework ColumnCollection to no longer persist "all_col_set"; we don't
need this collection except in the extend/update uses where we
create it ad-hoc.  simplifies pickling.  Compatibility with 1.0
should be OK as ColumnColleciton uses __getstate__ in any case
and the __setstate__ contract hasn't changed.
- Fixed bug in :class:`.Table` metadata construct which appeared
around the 0.9 series where adding columns to a :class:`.Table`
that was unpickled would fail to correctly establish the
:class:`.Column` within the 'c' collection, leading to issues in
areas such as ORM configuration.   This could impact use cases such
as ``extend_existing`` and others.  fixes #3632

(cherry picked from commit 8163de4cc9)
2016-01-26 16:43:04 -05:00
Mike Bayer 341a52015b - native unicode expectations are too difficult to maintain
w/ the number of drivers /DBURIs /  python versions

(cherry picked from commit d18d6d9baf)
2016-01-23 14:34:08 -05:00
Mike Bayer 107f1f47b9 - add a forwards-test here as well
(cherry picked from commit 38958f7b3f)
2016-01-21 15:33:18 -05:00
Mike Bayer 9cc769ac40 - documenation updates to clarify specific SQLite versions
that have problems with right-nested joins and UNION column keys;
references #3633 references #3634.   backport from 1.1 to 0.9
announcing 1.1 as where these behaviors will be retired based
on version-specific checks
- fix test_resultset so that it passes when SQLite 3.10.0 is
present, references #3633

(cherry picked from commit 89fa08792e)
2016-01-21 15:23:56 -05:00
Mike Bayer 6ba8382fa8 - 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

(cherry picked from commit 197ffa2be2)
2016-01-05 10:26:12 -05:00
Mike Bayer 7184e69e27 - add some more oracle skips
(cherry picked from commit c42725ed54)
2015-12-14 20:22:21 -05:00
Mike Bayer a6387b0df8 - 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

(cherry picked from commit 0e4c4d7efc)
2015-12-14 17:30:42 -05:00
Mike Bayer 6d44b01263 - 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

(cherry picked from commit e57bf79616)
2015-12-09 18:15:57 -05:00
Mike Bayer 7b5fd86a42 - 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

(cherry picked from commit 9695faf329)
2015-12-01 19:04:48 -05:00
Mike Bayer d2d60acdcb - 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

(cherry picked from commit c90f0a49f3)
2015-11-28 14:30:58 -05:00
Mike Bayer 3dcbee5f51 - fix bool test
(cherry picked from commit 1704eacf24)
2015-09-27 12:13:48 -04:00
Mike Bayer 28b2a0c986 - break out critical aspects of test_query into their own tests
finally, test_resultset and test_insert_exec.   Update all
idioms within these.

(cherry picked from commit a8e1d33ae5)
2015-09-27 12:10:27 -04:00
Mike Bayer 161209c70a - Fixed regression in 1.0-released default-processor for multi-VALUES
insert statement, 🎫`3288`, where the column type for the
default-holding column would not be propagated to the compiled
statement in the case where the default was being used,
leading to bind-level type handlers not being invoked.
fixes #3520

(cherry picked from commit c39ff9978d)
2015-08-31 11:30:21 -04:00
Mike Bayer c7312cc508 - changelog for #3459, fixes #3459
- test for .cast() method has no good place now except for
test_cast in test_compiler.py
2015-07-19 17:56:18 -04:00
Mike Bayer 1c65ddee24 Merge branch 'bb_issue_3459' of https://bitbucket.org/xflr6/sqlalchemy into pr56 2015-07-19 17:51:26 -04:00
Mike Bayer ddad190529 - Fixed regression where new methods on :class:.ResultProxy used
by the ORM :class:`.Query` object (part of the performance
enhancements of 🎫`3175`) would not raise the "this result
does not return rows" exception in the case where the driver
(typically MySQL) fails to generate cursor.description correctly;
an AttributeError against NoneType would be raised instead.
fixes #3481
2015-07-19 16:32:31 -04:00
Mike Bayer c00ef11a0c - pg8000 very annoyingly complaining here, use total literal 2015-07-19 16:01:02 -04:00
Mike Bayer d7ceb63c94 - Fixed regression where :meth:.ResultProxy.keys would return
un-adjusted internal symbol names for "anonymous" labels, which
are the "foo_1" types of labels we see generated for SQL functions
without labels and similar.  This was a side effect of the
performance enhancements implemented as part of references #918.
fixes #3483
2015-07-19 12:20:00 -04:00
Mike Bayer 3cfe3fd81d - Fixed bug where coersion of literal `True or False` constant
in conjunction with :func:`.and_` or :func:`.or_` would fail
with an AttributeError.
fixes #3490
2015-07-19 10:27:33 -04:00
Mike Bayer 41aead96cd - Fixed potential issue where a custom subclass
of :class:`.FunctionElement` or other column element that incorrectly
states 'None' or any other invalid object as the ``.type``
attribute will report this exception instead of recursion overflow.
fixes #3485
2015-07-19 10:00:13 -04:00
Mike Bayer 480dad983c - fix these two tests 2015-07-17 11:08:42 -04:00
Mike Bayer b89ca77dca Merge remote-tracking branch 'origin/pr/188' into pr188 2015-07-17 10:44:05 -04:00
Dan Gittik ae6fd1c389 Added test for modulo operator. 2015-07-17 02:28:23 +03:00
jakeogh 66b9a71ce7 add CYCLE support to Sequence() and docstrings for NO MINVALUE and NO MAXVALUE 2015-06-27 20:49:46 +00:00
jakeogh 85ebe01349 add NO MINVALUE and NO MAXVALUE support to Sequence() 2015-06-27 18:48:46 +00:00
jakeogh ad7caa6988 add MAXVALUE support to Sequence() 2015-06-27 18:37:09 +00:00
jakeogh f31c288b65 add MINVALUE support to Sequence() 2015-06-27 08:40:44 +00:00
Sebastian Bank 84e813aee4 add ClauseElement.cast() shortcut-method 2015-06-19 17:37:21 +02:00