Commit Graph

11756 Commits

Author SHA1 Message Date
mike bayer c8dea359db Merge "Apply path generation for superclasses to Load._set_path_strategy()" 2018-12-01 16:52:22 +00:00
Mike Bayer fb05e085fe Apply path generation for superclasses to Load._set_path_strategy()
Extended the fix first made as part of 🎫`3287`, where a loader option
made against a subclass using a wildcard would extend itself to include
application of the wildcard to attributes on the super classes as well, to a
"bound" loader option as well, e.g. in an expression like
``Load(SomeSubClass).load_only('foo')``.  Columns that are part of the
parent class of ``SomeSubClass`` will also be excluded in the same way as if
the unbound option ``load_only('foo')`` were used.

Fixes: #4373
Change-Id: I2eee0e587c34323a77df077b9cb699da370c403d
2018-11-30 14:36:20 -05:00
mike bayer 7940e7dc9c Merge "Add __clause_element__ to ColumnProperty" 2018-11-30 18:12:02 +00:00
mike bayer f916fa3b31 Merge "Add the write_timeout option for mysql." 2018-11-30 18:11:06 +00:00
mike bayer 39596f3398 Merge "Allow optional *args with base AnsiFunction" 2018-11-30 15:18:44 +00:00
jun923.gu 6a8454ded3 Add the write_timeout option for mysql.
As MySQLdb support read_timeout and write_timeout option, and
sqlalchemy just support read_timeout option. So sqlalchemy need to add
write_timeout option.

Fixes: #4381
Change-Id: I2bea80bdd6f20fafc72b48fa0e5d795626d9d9b9
Pull-request: https://github.com/sqlalchemy/sqlalchemy/pull/4385
2018-11-30 00:22:58 -05:00
Mike Bayer 3ff3975767 Allow optional *args with base AnsiFunction
Amended the :class:`.AnsiFunction` class, the base of common SQL
functions like ``CURRENT_TIMESTAMP``, to accept positional arguments
like a regular ad-hoc function.  This to suit the case that many of
these functions on specific backends accept arguments such as
"fractional seconds" precision and such.  If the function is created
with arguments, it renders the the parenthesis and the arguments.  If
no arguents are present, the compiler generates the non-parenthesized form.

Fixes: #4386
Change-Id: Ic492ef177e4987cec99ec4d95f55292be8daa087
2018-11-29 23:46:42 -05:00
Raphael 0a0b36686d typo
typo
2018-11-29 19:11:24 -05:00
Mike Bayer 576b33d46a Merge remote-tracking branch 'origin/pr/4382'
Change-Id: I957a13fa77be659a1ce2371342af4e33b1c5a304
2018-11-28 12:32:24 -05:00
Mike Bayer 6837e875a3 Add a test harness for MySQL connect args
This is to assist with #4381.

Change-Id: I5ebfc0da906a13edc4fb3f0ca7ab2d843d43bb00
2018-11-28 11:27:46 -05:00
cclauss 971f086785 print() is a function in Python 3 2018-11-28 10:38:57 +01:00
Mike Bayer 835444be72 Add __clause_element__ to ColumnProperty
Added a ``__clause_element__()`` method to :class:`.ColumnProperty` which
can allow the usage of a not-fully-declared column or deferred attribute in
a declarative mapped class slightly more friendly when it's used in a
constraint or other column-oriented scenario within the class declaration,
though this still can't work in open-ended expressions; prefer to call the
:attr:`.ColumnProperty.expression` attribute if receiving ``TypeError``.

Fixes: #4372
Change-Id: I5d3d1adb9c77de0566298bc2c46e9001d314b0c7
2018-11-27 20:12:16 -05:00
mike bayer ce3cab93d5 Merge "Warn for lower-case column attribute on declarative" 2018-11-27 07:54:43 +00:00
Mike Bayer 50417cf758 Move links etc. to github, new alembic links
Change-Id: I59392d355a216ae59552a04c5508f548b901aa7b
2018-11-26 22:58:50 -05:00
Mike Bayer 6ec40eca1a Warn for lower-case column attribute on declarative
A warning is emitted in the case that a :func:`.column` object is applied to
a declarative class, as it seems likely this intended to be a
:class:`.Column` object.

Fixes: #4374
Change-Id: I2e617ef65547162e3ba6587c168548ad0cf6203d
2018-11-26 01:12:01 -05:00
Mike Bayer b5cb68ac43 - remove @HEAD indicator from docs requirements, fixes #4375
Change-Id: I50b1622c2c2236bf9e436f61c7eea31faaeaa3e1
2018-11-25 23:54:44 -05:00
Mike Bayer f39a6216ee Version 1.3.0b2 placeholder 2018-11-16 23:13:08 -05:00
Mike Bayer 19590812c0 - 1.3.0b1 rel_1_3_0b1 2018-11-16 23:04:42 -05:00
Mike Bayer b7fd3a3fc9 - edits
Change-Id: Ia8e1b5b51acc2b249499796ac36a7a3b68c941a1
2018-11-16 22:46:20 -05:00
Mike Bayer 9addf77342 - edits for 1.3 migration notes
Change-Id: Id2065053088481df5a703c63bfc88799a9943a5e
2018-11-16 18:52:42 -05:00
Mike Bayer 670ace18ae - we don't have a separate contributors doc anymore...
Change-Id: I0d09d3aa386336263829a98aeb1237caab78b789
2018-11-16 18:51:35 -05:00
mike bayer d1f187ecfd Merge "Modernize cx_Oracle parameters" 2018-11-16 03:14:54 +00:00
Mike Bayer 60a8648776 - fix spacing
Change-Id: I460d873b4c6a250594e291b5f47fff5a06280817
2018-11-15 19:51:03 -05:00
Mike Bayer 477a64e2b2 Repair tutorial code example to be deterministic
A few queries featured an aggregate without a GROUP BY
or a complete ordering, causing the doctests to fail
with recent versions of SQLite.  The queries are now made
to include a GROUP BY as well as ORDER BY both columns.

Fixes: #4370
Change-Id: I904bddb4372224158fcecff9f0dbbbe7c1bf36b3
2018-11-15 19:48:45 -05:00
Mike Bayer e0e6fe44e3 Modernize cx_Oracle parameters
Updated the parameters that can be sent to the cx_Oracle DBAPI to both allow
for all current parameters as well as for future parameters not added yet.
In addition, removed unused parameters that were deprecated in version 1.2,
and additionally we are now defaulting "threaded" to False.

Fixes: #4369
Change-Id: I599668960e7b2d5bd1f5e6850e10b5b3ec215ed3
2018-11-15 12:56:37 -05:00
Mike Bayer 996727ed89 Modernize cx_oracle connect documentation
in preparation for #4369, however the documentation was
also inaccurate in that it did not mention connect_args.

Change-Id: I992e5f53ce16cc9c72d2c893a3ca798a9c2b4d07
2018-11-15 12:52:33 -05:00
mike bayer 1f69e9b94c Merge "Add secondary selectable to FROM clauses for correlated exists" 2018-11-15 15:17:59 +00:00
mike bayer bfd6f76a7d Merge "Allow join() to pick the best candidate from multiple froms/entities" 2018-11-15 15:05:11 +00:00
Mike Bayer 7dcfd1e019 Allow join() to pick the best candidate from multiple froms/entities
Refactored :meth:`.Query.join` to further clarify the individual components
of structuring the join. This refactor adds the ability for
:meth:`.Query.join` to determine the most appropriate "left" side of the
join when there is more than one element in the FROM list or the query is
against multiple entities.  In particular this targets the regression we
saw in 🎫`4363` but is also of general use.   The codepaths within
:meth:`.Query.join` are now easier to follow and the error cases are
decided more specifically at an earlier point in the operation.

Fixes: #4365
Change-Id: I403f451243904a020ceab4c3f94bead550c7b2d5
2018-11-14 21:35:15 -05:00
Mike Bayer fdfd168060 Add secondary selectable to FROM clauses for correlated exists
In continuing with a similar theme as that of very recent 🎫`4349`,
repaired issue with :meth:`.RelationshipProperty.Comparator.any` and
:meth:`.RelationshipProperty.Comparator.has` where the "secondary"
selectable needs to be explicitly part of the FROM clause in the
EXISTS subquery to suit the case where this "secondary" is a :class:`.Join`
object.

Fixes: #4366
Change-Id: Icd0d0c3871bbd0059f0c9256e2b980edc2c90551
2018-11-14 17:37:02 -05:00
mike bayer 0a07fd99db Merge "Add new parameters for IDENTITY start/increment in mssql" 2018-11-14 22:35:19 +00:00
Mike Bayer 6629d9f892 Add new parameters for IDENTITY start/increment in mssql
Deprecated the use of :class:`.Sequence` with SQL Server in order to affect
the "start" and "increment" of the IDENTITY value, in favor of new
parameters ``mssql_identity_start`` and ``mssql_identity_increment`` which
set these parameters directly.  :class:`.Sequence` will be used to generate
real ``CREATE SEQUENCE`` DDL with SQL Server in a future release.

Fixes: #4362
Change-Id: I1e69378c5c960ff0bc28137c923589692f1a918f
2018-11-14 17:34:52 -05:00
mike bayer fd8f0044fe Merge "Deannotate "parententity" in primaryjoin/secondaryjoin" 2018-11-14 19:22:25 +00:00
mike bayer 5eafe15901 Merge "Insert primary entity in dynamic "secondary"" 2018-11-14 19:20:30 +00:00
Mike Bayer 4ee5b2c4a9 Deannotate "parententity" in primaryjoin/secondaryjoin
Fixed bug where the ORM annotations could be incorrect for the
primaryjoin/secondaryjoin a relationship if one used the pattern
``ForeignKey(SomeClass.id)`` in the declarative mappings.   This pattern
would leak undesired annotations into the join conditions which can break
aliasing operations done within :class:`.Query` that are not supposed to
impact elements in that join condition.  These annotations are now removed
up front if present.

Also add a test suite for has/any into test_query which will
form the basis for new tests to be added in 🎫`4366`.

Fixes: #4367
Change-Id: I929ef983981bb49bf975f346950ebb0e19c986b8
2018-11-14 11:35:45 -05:00
mike bayer 616b226f74 Merge "Add Sequence to StrSQLCompiler" 2018-11-13 23:37:33 +00:00
Mike Bayer 40c1a46e99 Insert primary entity in dynamic "secondary"
Fixed regression caused by 🎫`4349` where adding the "secondary"
table to the FROM clause for a dynamic loader would affect the ability of
the :class:`.Query` to make a subsequent join to another entity.   The fix
adds the primary entity as the first element of the FROM list since
:meth:`.Query.join` wants to jump from that.   Version 1.3 will have
a more comprehensive solution to this problem as well (🎫`4365`).

Fixes: #4363
Change-Id: I1abbb6207722619dc5369e1fd96de43d60a1ee62
2018-11-13 18:36:24 -05:00
Mike Bayer a698bdbc57 Convert to spaces
Change-Id: I219f7f6ef4f644f64fcb04fed224c6415465df0b
2018-11-10 21:56:52 -05:00
Mike Bayer 8318a98a60 Add Sequence to StrSQLCompiler
Added :class:`.Sequence` to the "string SQL" system that will render a
meaningful string expression (``"<next sequence value: my_sequence>"``)
when stringifying without a dialect a statement that includes a "sequence
nextvalue" expression, rather than raising a compilation error.

Fixes: #4144
Change-Id: Ia910f0e22008a7cde7597365954ede324101cf4d
2018-11-10 21:10:51 -05:00
mike bayer 6b84db83e0 Merge "Add new "all columns" naming convention tokens" 2018-11-11 01:58:18 +00:00
mike bayer 680835f815 Merge "Modernize deferred callable for many-to-one comparison" 2018-11-11 01:56:41 +00:00
Mike Bayer d5c2db437e Modernize deferred callable for many-to-one comparison
Improved the behavior of a relationship-bound many-to-one object expression
such that the retrieval of column values on the related object are now
resilient against the object being detached from its parent
:class:`.Session`, even if the attribute has been expired.  New features
within the :class:`.InstanceState` are used to memoize the last known value
of a particular column attribute before its expired, so that the expression
can still evaluate when the object is detached and expired at the same
time.  Error conditions are also improved using modern attribute state
features to produce more specific messages as needed.

To support the value being mutated while also being resilient towards
expiration, a new feature to InstanceState is added ._last_known_values
which holds onto the expired value when an individual key is expired.
Only takes effect specific to keys and InstanceState objects that
received a special instruction so this does not add to overall
memory/latency.

Fixes: #4359
Change-Id: Iff272e667bf741074549db550bf65348553ca8e7
2018-11-10 20:55:57 -05:00
Mike Bayer be70559584 Add new "all columns" naming convention tokens
Added new naming convention tokens ``column_0N_name``, ``column_0_N_name``,
etc., which will render the names / keys / labels for all columns referenced
by a particular constraint in a sequence.  In order to accommodate for the
length of such a naming convention, the SQL compiler's auto-truncation
feature now applies itself to constraint names as well, which creates a
shortened, deterministically generated name for the constraint that will
apply to a target backend without going over the character limit of that
backend.

Additional notes:

1. the SQLite dialect had a format_index method that was apparently not
used, removed.

2. the naming convention logic has been applying the foreign key
remote column spec to the naming convention, and not the actual
column name.  In the case where the referenced Table object uses
.key inside the columns and these are what ForeignKey() references,
the naming convention was doing the wrong thing.   The patch here
fixes this, however this isn't noted in the migration notes.

Fixes: #3989
Change-Id: Ib24f4754b886676096c480fc54b2e5c2463ac99a
2018-11-10 16:13:01 -05:00
Mike Bayer ec88a22a94 cherry-pick changelog update for 1.2.15 2018-11-10 15:59:12 -05:00
Mike Bayer 056fb6d952 cherry-pick changelog from 1.2.14 2018-11-10 15:59:12 -05:00
Mike Bayer ab1e6fb08f Fix typo
Change-Id: I411466dc1952cf57f73d1453c73b0ca449842c35
2018-11-10 11:26:31 -05:00
Mike Bayer af159c5695 Use case insensitive matching on lower_case_table_names=1,2
Fixed regression caused by 🎫`4344` released in 1.2.13, where the fix
for MySQL 8.0's case sensitivity problem with referenced column names when
reflecting foreign key referents is worked around using the
``information_schema.columns`` view.  The workaround was failing on OSX /
``lower_case_table_names=2`` which produces non-matching casing for the
``information_schema.columns`` vs. that of ``SHOW CREATE TABLE``, so in
case-insensitive SQL modes case-insensitive matching is now used.

Fixes: #4361
Change-Id: I748549bc4c27fad6394593f8ec93fc22bfd01f6c
2018-11-09 23:22:22 -05:00
mike bayer 07de512bf1 Merge "Implement SQLite ON CONFLICT for constraints" 2018-11-09 22:43:20 +00:00
Denis Kataev de804d7245 Implement SQLite ON CONFLICT for constraints
Implemented the SQLite ``ON CONFLICT`` clause as understood at the DDL
level, e.g. for primary key, unique, and CHECK constraints as well as
specified on a :class:`.Column` to satisfy inline primary key and NOT NULL.
Pull request courtesy Denis Kataev.

Fixes: #4360
Change-Id: I4cd4bafa8fca41e3101c87dbbfe169741bbda3f4
Pull-request: https://github.com/zzzeek/sqlalchemy/pull/431
2018-11-07 18:26:40 -05:00
Mike Bayer 1f13c8c833 Improve documentation re: Session.binds and partitioning strategies
Update documentation to include background on arbitrary superclass
usage, add full cross-linking between all related methods and parameters.
De-emphasize "twophase" and document that it is not well-supported
in drivers.

Change-Id: Id99894bb62cc506e896c9aa7c256e9f6e602243e
2018-11-06 15:13:03 -05:00