summaryrefslogtreecommitdiff
path: root/lib/sqlalchemy
Commit message (Collapse)AuthorAgeFilesLines
* Render FOR UPDATE on the inner subquery as well as the outerMike Bayer2018-05-011-1/+10
| | | | | | | | | | | | | | | The ORM now doubles the "FOR UPDATE" clause within the subquery that renders in conjunction with joined eager loading in some cases, as it has been observed that MySQL does not lock the rows from a subquery. This means the query renders with two FOR UPDATE clauses; note that on some backends such as Oracle, FOR UPDATE clauses on subqueries are silently ignored since they are unnecessary. Additionally, in the case of the "OF" clause used primarily with Postgresql, the FOR UPDATE is rendered only on the inner subquery when this is used so that the selectable can be targeted to the table within the SELECT statement. Change-Id: Ie5520d08d82bf0afd9e1bd2d43a0b2a0db0de16d Fixes: #4246
* Fix reference leak in compiled cacheOlivier Grisel2018-04-251-3/+3
| | | | | | | | | | Fixed a reference leak issue where the values of the parameter dictionary used in a statement execution would remain referenced by the "compiled cache", as a result of storing the key view used by Python 3 dictionary keys(). Pull request courtesy Olivier Grisel. Change-Id: Icfb0f38111a165780f6dd3e4e3382a03df79ce26 Pull-request: https://github.com/zzzeek/sqlalchemy/pull/441
* Refactor "get" to allow for pluggable identity token schemesMike Bayer2018-04-205-48/+144
| | | | | | | | | | | | | | | Fixed regression in 1.2 within sharded query feature where the new "identity_token" element was not being correctly considered within the scope of a lazy load operation, when searching the identity map for a related many-to-one element. The new behavior will allow for making use of the "id_chooser" in order to determine the best identity key to retrieve from the identity map. In order to achieve this, some refactoring of 1.2's "identity_token" approach has made some slight changes to the implementation of ``ShardedQuery`` which should be noted for other derivations of this class. Change-Id: I04fa60535deec2d0cdec89f602935dfebeb9eb9d Fixes: #4228
* Document how to opt-out of NCHAR for cx_OracleMike Bayer2018-04-201-0/+31
| | | | | | | | | | | Unfortunately, we need to bind Python unicode values as NCHAR as in the case where non-ascii characters are present, it's necessary. We can't know in all cases how this value is being used, so in those cases where Oracle will not accept NCHAR the user should explicitly cast a value down to String. Change-Id: I1a70739033435a7bf5effe2fa810ab064cea9188 Fixes: #4242
* Merge "Ensure select_from_entity adapter is used in ↵mike bayer2018-04-191-6/+8
|\ | | | | | | adjust_for_single_inheritance"
| * Ensure select_from_entity adapter is used in adjust_for_single_inheritanceMike Bayer2018-04-191-6/+8
| | | | | | | | | | | | | | | | | | | | | | | | Fixed issue in single-inheritance loading where the use of an aliased entity against a single-inheritance subclass in conjunction with the :meth:`.Query.select_from` method would cause the SQL to be rendered with the unaliased table mixed in to the query, causing a cartesian product. In particular this was affecting the new "selectin" loader when used against a single-inheritance subclass. Change-Id: Ic2cbe94a5269c101b1f98da9a466180dd4452783 Fixes: #4241
* | Merge "Render and reflect MySQL WITH PARSER index options"mike bayer2018-04-172-2/+46
|\ \
| * | Render and reflect MySQL WITH PARSER index optionsMike Bayer2018-04-172-2/+46
| |/ | | | | | | | | | | | | | | | | | | | | | | Support added for the "WITH PARSER" syntax of CREATE FULLTEXT INDEX in MySQL, using the ``mysql_with_parser`` keyword argument. Reflection is also supported, which accommodates MySQL's special comment format for reporting on this option as well. Additionally, the "FULLTEXT" and "SPATIAL" index prefixes are now reflected back into the ``mysql_prefix`` index option. Change-Id: I0209291978125d8cee1bb5ed386d4f66578697a0 Fixes: #4219
* | Fix - Order of records is not guaranteedPat Buxton2018-04-161-3/+3
|/ | | | | | | | | * Causes intermittent failure against Greenplum cluster * Tested using Greenplum dialact: https://github.com/PlaidCloud/sqlalchemy-greenplum Change-Id: I6387e98f17a3667612fdaaadb27a08f79ec46398 Pull-request: https://github.com/zzzeek/sqlalchemy/pull/440
* Reflect Oracle NUMBER(NULL, 0) as INTEGERKent Bower2018-04-121-2/+5
| | | | | | | | | The Oracle NUMBER datatype is reflected as INTEGER if the precision is NULL and the scale is zero, as this is how INTEGER values come back when reflected from Oracle's tables. Pull request courtesy Kent Bower. Change-Id: I4627febd46cab7085299c0a5700ee0f0bdca513c Pull-request: https://github.com/zzzeek/sqlalchemy/pull/437
* Merge "Correct join for FKs with schema in SQL Server"mike bayer2018-04-112-2/+75
|\
| * Correct join for FKs with schema in SQL ServerMike Bayer2018-04-112-2/+75
| | | | | | | | | | | | | | | | | | | | | | | | | | Fixed 1.2 regression caused by :ticket:`4060` where the query used to reflect SQL Server cross-schema foreign keys was limiting the criteria incorrectly. Additionally, added some rework of the inter-schema reflection tests so that MySQL, MSSQL can be included, breaking out some of the Postgresql-specific behaviors into separate requirements. Fixes: #4234 Change-Id: I20c8e70707075f1767b79127c2c27d4b313c6515
* | Update argument name for distinct() to match docsMichael Williamson2018-04-111-6/+6
| | | | | | | | | | | | | | A tiny change so that the docs are more consistent. At the moment, the same argument is given two different names. Change-Id: Ic487006887d048700f260b2ae4a05d9a380412c1 Pull-request: https://github.com/zzzeek/sqlalchemy/pull/439
* | Raise informative exception for non-sortable PKMike Bayer2018-04-092-2/+7
|/ | | | | | | | | | | An informative exception is re-raised when a primary key value is not sortable in Python during an ORM flush under Python 3, such as an ``Enum`` that has no ``__lt__()`` method; normally Python 3 raises a ``TypeError`` in this case. The flush process sorts persistent objects by primary key in Python so the values must be sortable. Change-Id: Ia186968982dcd1234b82f2e701fefa2a1668a7e4 Fixes: #4232
* Merge "Ensure all visit_sequence accepts **kw args"mike bayer2018-04-045-5/+27
|\
| * Ensure all visit_sequence accepts **kw argsMike Bayer2018-04-045-5/+27
| | | | | | | | | | | | | | | | | | | | Fixed issue where the compilation of an INSERT statement with the "literal_binds" option that also uses an explicit sequence and "inline" generation, as on Postgresql and Oracle, would fail to accommodate the extra keyword argument within the sequence processing routine. Change-Id: Ibdab7d340aea7429a210c9535ccf1a3e85f074fb Fixes: #4231
* | Use base __ne__ implementation for range types w/ NoneMike Bayer2018-04-031-1/+5
|/ | | | | | | | | | | | Fixed bug where the special "not equals" operator for the Postgresql "range" datatypes such as DATERANGE would fail to render "IS NOT NULL" when compared to the Python ``None`` value. Also break up range tests into backend round trip and straight compilation suites. Change-Id: Ibaee132b1ea7dac8b799495a27f98f82a7d9c028 Fixes: #4229
* Add postgresl.REGCLASS type for casting table names to OIDs and vice versaSebastian Bank2018-04-032-3/+17
| | | | | | Fixes: #4160 Change-Id: Id0bdbad1be3a0950dc8f35895ee13d9264244722 Pull-request: https://github.com/zzzeek/sqlalchemy/pull/435
* Merge "Add support for declarative partitioning in PostgreSQL 10"mike bayer2018-03-301-1/+12
|\
| * Add support for declarative partitioning in PostgreSQL 10Vsevolod Solovyov2018-03-301-1/+12
| | | | | | | | | | | | | | | | | | Added support for "PARTITION BY" in Postgresql table definitions, using "postgresql_partition_by". Pull request courtesy Vsevolod Solovyov. Change-Id: Id74d6882d7193fae1e5fd44b6e12d6852866fcc4 Pull-request: https://github.com/zzzeek/sqlalchemy/pull/430
* | Merge "Filter non-integer characters from pyodbc SQL Server version"mike bayer2018-03-302-4/+7
|\ \
| * | Filter non-integer characters from pyodbc SQL Server versionMike Bayer2018-03-302-4/+7
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Adjusted the SQL Server version detection for pyodbc to only allow for numeric tokens, filtering out non-integers, since the dialect does tuple- numeric comparisons with this value. This is normally true for all known SQL Server / pyodbc drivers in any case. Change-Id: I4ab18a07e19231091b5e877ba1fccd5eda72a992 Fixes: #4227
* | | Invalidate on failed connect handlerMike Bayer2018-03-281-4/+8
|/ / | | | | | | | | | | | | | | | | | | | | | | | | Fixed bug in connection pool where a connection could be present in the pool without all of its "connect" event handlers called, if a previous "connect" handler threw an exception; note that the dialects themselves have connect handlers that emit SQL, such as those which set transaction isolation, which can fail if the database is in a non-available state, but still allows a connection. The connection is now invalidated first if any of the connect handlers fail. Change-Id: I61d6f4827a98ab8455f1c3e1c55d046eeccec09a Fixes: #4225
* | Merge "Don't warn for mixin-based __table_args__, __mapper_args__ declared_attr"mike bayer2018-03-211-2/+3
|\ \
| * | Don't warn for mixin-based __table_args__, __mapper_args__ declared_attrMike Bayer2018-03-211-2/+3
| |/ | | | | | | | | | | | | | | | | | | | | | | Removed a warning that would be emitted when calling upon ``__table_args__``, ``__mapper_args__`` as named with a ``@declared_attr`` method, when called from a non-mapped declarative mixin. Calling these directly is documented as the approach to use when one is overidding one of these methods on a mapped class. The warning still emits for regular attribute names. Change-Id: Iae7ed0bd625a2c163c910aa777cef4779128580a Fixes: #4221
* | Merge "Track if we're rendering within the CTE recursively"mike bayer2018-03-161-1/+9
|\ \ | |/ |/|
| * Track if we're rendering within the CTE recursivelyMike Bayer2018-03-141-1/+9
| | | | | | | | | | | | | | | | | | | | Fixed a regression that occurred from the previous fix to :ticket:`4204` in version 1.2.5, where a CTE that refers to itself after the :meth:`.CTE.alias` method has been called would not refer to iself correctly. Change-Id: Iaa63d65ad2b90c8693f9953fbb32dbb10c73a037 Fixes: #4204
* | Ignore non-primary mappers within mutable instrumentationMike Bayer2018-03-121-0/+4
|/ | | | | | | | | | | | Fixed bug where using :meth:`.Mutable.associate_with` or :meth:`.Mutable.as_mutable` in conjunction with a class that has non- primary mappers set up with alternatively-named attributes would produce an attribute error. Since non-primary mappers are not used for persistence, the mutable extension now excludes non-primary mappers from its instrumentation steps. Change-Id: I2630d9f771a171aece03181ccf9159885f68f25e Fixes: #4215
* Raise cx_Oracle minimum version to 5.2Mike Bayer2018-03-071-2/+2
| | | | | | | | | The minimum cx_Oracle version supported is 5.2 (June 2015). Previously, the dialect asserted against version 5.0 but as of 1.2.2 we are using some symbols that did not appear until 5.2. Change-Id: I6fa4238f1722789924f4a6473fdce6f524333825 Fixes: #4211
* Add notes regarding flat=TrueMike Bayer2018-03-071-1/+4
| | | | | | | | | Start documenting that flat=True and aliased=True don't work with selectable particularly when selectable is an aliased select already. References #4212 Change-Id: I6e576165f06387350ae97e43ad979e575a4912b9 (cherry picked from commit 39d7dfa08accf6cce6d53b0807603bf43d580791)
* Merge "Add Query.enable_single_entity()"mike bayer2018-03-062-1/+13
|\
| * Add Query.enable_single_entity()Eric Atkin2018-03-052-1/+13
| | | | | | | | | | | | | | | | | | | | Added new feature :meth:`.Query.only_return_tuples`. Causes the :class:`.Query` object to return keyed tuple objects unconditionally even if the query is against a single entity. Pull request courtesy Eric Atkin. Change-Id: Ib0b7f5f78431aa68082e5b200ed577daa4222336 Pull-request: https://github.com/zzzeek/sqlalchemy/pull/425
* | Merge "Clone _cte_alias instead of assigning "self""mike bayer2018-03-061-1/+1
|\ \
| * | Clone _cte_alias instead of assigning "self"Mike Bayer2018-03-051-1/+1
| |/ | | | | | | | | | | | | | | | | | | Fixed bug in :class:.`CTE` construct along the same lines as that of :ticket:`4204` where a :class:`.CTE` that was aliased would not copy itself correctly during a "clone" operation as is frequent within the ORM as well as when using the :meth:`.ClauseElement.params` method. Change-Id: Id68d72dd244dedfc7bd6116c9a5123c51a55ea20 Fixes: #4210
* | Don't include AliasedClass when pickling optionsMike Bayer2018-03-051-12/+12
|/ | | | | | | | | | | Fixed 1.2 regression where a mapper option that contains an :class:`.AliasedClass` object, as is typical when using the :meth:`.QueryableAttribute.of_type` method, could not be pickled. 1.1's behavior was to omit the aliased class objects from the path, so this behavior is restored. Change-Id: I4b36a422b7c0e6a6da7ee3ba3ab282c13917a31f Fixes: #4209
* Only replace first occurrence for COLLATE/ARRAY syntaxMike Bayer2018-03-051-1/+2
| | | | | | | | | Fixed bug in Postgresql COLLATE / ARRAY adjustment first introduced in :ticket:`4006` where new behaviors in Python 3.7 regular expressions caused the fix to fail. Change-Id: Ied3893d7cac210befa0277b55b3b895b0ba1f0d2 Fixes: #4208
* Get MySQL version info from @@versionMike Bayer2018-03-035-38/+24
| | | | | | | | | | | | | MySQL dialects now query the server version using ``SELECT @@version`` explicitly to the server to ensure we are getting the correct version information back. Proxy servers like MaxScale interfere with the value that is passed to the DBAPI's connection.server_version value so this is no longer reliable. Change-Id: Iafd39be8c9bf1982d58b34cc997ae1016ad6c48c Fixes: #4205 (cherry picked from commit 9ba77e8d3b682bff89fdab5e80271a96a52fe8c8) (cherry picked from commit 5c1ebbc3706c810f936d9e252ee5d16800e561ea)
* Setup master as 1.3Mike Bayer2018-03-021-1/+1
| | | | Change-Id: I1e8240d19f891cb6575f10d93524b551d74864ea
* - add some seealsos for the transient object that loads use caseMike Bayer2018-03-021-0/+11
| | | | | Change-Id: Ibfa79a3721f31806223906cccf4547673b3d42f1 (cherry picked from commit 5de2e17b6e6686adf0a87038e90b001978187c0a)
* Fix enable_relationship_loading() works fine w/ one-to-manyMike Bayer2018-03-021-3/+5
| | | | Change-Id: I6efb62afa02be4d42482cfdbec739a5c6ab32bd7
* Merge "Check existing CTE for an alias name when rendering FROM clause"mike bayer2018-03-011-50/+56
|\
| * Check existing CTE for an alias name when rendering FROM clauseMike Bayer2018-03-011-50/+56
| | | | | | | | | | | | | | | | | | | | Fixed bug in CTE rendering where a :class:`.CTE` that was also turned into an :class:`.Alias` would not render its "ctename AS aliasname" clause appropriately if there were more than one reference to the CTE in a FROM clause. Change-Id: If8cff27a2f4faa5eceb59aa86398db6edb3b9e72 Fixes: #4204
* | Merge existing query params in baked lazy loadMike Bayer2018-02-283-21/+63
|/ | | | | | | | | | | | | | | | | | | | | | | | Fixed a long-standing regression that occurred in version 1.0, which prevented the use of a custom :class:`.MapperOption` that alters the _params of a :class:`.Query` object for a lazy load, since the lazy loader itself would overwrite those parameters. This applies to the "temporal range" example on the wiki. Note however that the :meth:`.Query.populate_existing` method is now required in order to rewrite the mapper options associated with an object already loaded in the identity map. Also, a custom defined :class:`.MapperOption` will now cause lazy loaders related to the target object to use a non-baked query by default unless the :meth:`.MapperOption._generate_cache_key` method is implemented. Fixed bug where the new :meth:`.baked.Result.with_post_criteria` method would not interact with a subquery-eager loader correctly, in that the "post criteria" would not be applied to embedded subquery eager loaders. This is related to :ticket:`4128` in that the post criteria feature is now used by the lazy loader. Change-Id: I899808734458e25a023142c2c5bb37cbed869479 Fixes: #4128
* Merge "Ensure we have states to load when doing poly post load"mike bayer2018-02-231-2/+2
|\
| * Ensure we have states to load when doing poly post loadMike Bayer2018-02-231-2/+2
| | | | | | | | | | | | | | | | | | | | Fixed bug in new "polymorphic selectin" loading when a selection of polymorphic objects were to be partially loaded from a relationship lazy loader, leading to an "empty IN" condition within the load that raises an error for the "inline" form of "IN". Change-Id: I721cf5fdf0b9fd2289067d5d2c6bc87fb2436f07 Fixes: #4199
* | Merge "Allow bind processors to work with expanding IN"mike bayer2018-02-231-1/+1
|\ \ | |/ |/|
| * Allow bind processors to work with expanding INMike Bayer2018-02-231-1/+1
| | | | | | | | | | | | | | | | | | Fixed bug in new "expanding IN parameter" feature where the bind parameter processors for values wasn't working at all, tests failed to cover this pretty basic case which includes that ENUM values weren't working. Change-Id: I8e2420d7229a3e253e43b5227ebb98f9fe0bd14a Fixes: #4198
* | Version 1.2.5 placeholderMike Bayer2018-02-221-1/+1
|/
* Quote cte alias if neededEric Atkin2018-02-221-0/+2
| | | | | | | | | | Fixed bug where CTE expressions would not have their name or alias name quoted when the given name is case sensitive or otherwise requires quoting. Pull request courtesy Eric Atkin. Fixes: #4197 Change-Id: Ib8573e82b9a1ca94b50c7c5d73ee98b79465d689 Pull-request: https://github.com/zzzeek/sqlalchemy/pull/426
* Merge "Ensure mapping has no version_id_generator when checking missing ↵mike bayer2018-02-221-1/+2
|\ | | | | | | version_id"