summaryrefslogtreecommitdiff
path: root/lib/sqlalchemy
Commit message (Collapse)AuthorAgeFilesLines
* Support python3.6Mike Bayer2017-01-1351-341/+353
| | | | | | | | | | | 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
* Merge "Adapt from "localparent" in joinedloader"mike bayer2017-01-091-2/+2
|\
| * Adapt from "localparent" in joinedloaderMike Bayer2017-01-091-2/+2
| | | | | | | | | | | | | | | | | | | | Fixed bug involving joined eager loading against multiple entities when polymorphic inheritance is also in use which would throw "'NoneType' object has no attribute 'isa'". The issue was introduced by the fix for :ticket:`3611`. Change-Id: I296ecda38c01ec8f69dcd843beaebed6949cecfa Fixes: #3884
* | Merge "Tighten rules for order_by(Label) resolution"mike bayer2017-01-092-8/+9
|\ \
| * | Tighten rules for order_by(Label) resolutionMike Bayer2017-01-062-8/+9
| |/ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | - Fixed bug originally introduced in 0.9 via :ticket:`1068` where order_by(<some Label()>) would order by the label name based on name alone, that is, even if the labeled expression were not at all the same expression otherwise present, implicitly or explicitly, in the selectable. The logic that orders by label now ensures that the labeled expression is related to the one that resolves to that name before ordering by the label name; additionally, the name has to resolve to an actual label explicit in the expression elsewhere, not just a column name. This logic is carefully kept separate from the order by(textual name) feature that has a slightly different purpose. Change-Id: I44fc36dab34380cc238c1e79ecbe23f1628d588a Fixes: #3882
* | Merge "update for 2017 copyright"mike bayer2017-01-09173-173/+173
|\ \ | |/ |/|
| * update for 2017 copyrightMike Bayer2017-01-04173-173/+173
| | | | | | | | Change-Id: I4e8c2aa8fe817bb2af8707410fa0201f938781de
* | - add a section for ARRAY of JSON to complement ARRAY of ENUM. references #3467Mike Bayer2017-01-051-0/+23
| | | | | | | | Change-Id: I9836b842be01ef24138071fa022d80f5f77be14f
* | Ensure session.no_autoflush uses finallyplumSemPy2017-01-041-2/+4
|/ | | | | | | | | | The :attr:`.Session.no_autoflush` context manager now ensures that the autoflush flag is reset within a "finally" block, so that if an exception is raised within the block, the state still resets appropriately. Pull request courtesy Emin Arakelian. Change-Id: Ib19ddf32074b1df82a6a1f1ae14e3a962cd31a5f Pull-request: https://github.com/zzzeek/sqlalchemy/pull/335
* Correct any_, all_ spellingMike Bayer2016-12-281-1/+1
| | | | | | | | | - Fixed 1.1 regression where "import *" would not work for sqlalchemy.sql.expression, due to mis-spelled "any_" and "all_" functions. Change-Id: I25d1cd34c9239dbdcdb1889c5cda2474557e1418 Fixes: #3878
* Don't select lastrowid for inline=TrueMike Bayer2016-12-212-1/+52
| | | | | | | | | | | - Fixed bug where SQL Server dialects would attempt to select the last row identity for an INSERT from SELECT, failing in the case when the SELECT has no rows. For such a statement, the inline flag is set to True indicating no last primary key should be fetched. Change-Id: Ic40d56d9eadadc3024a4d71245f9eed4c420024a Fixes: #3876
* Call nextval() on sequence when doing INSERT from SELECTMike Bayer2016-12-211-1/+1
| | | | | | | | Fixed bug where an INSERT from SELECT where the source table contains an autoincrementing Sequence would fail to compile correctly. Change-Id: I41eb9f65789a4007712ae61ed5fa23a9839a5128 Fixes: #3877
* Bump "table compression" flag to Oracle 10.1Mike Bayer2016-12-201-1/+1
| | | | | | | | | | - Fixed bug where the "COMPRESSION" keyword was used in the ALL_TABLES query on Oracle 9.2; even though Oracle docs state table compression was introduced in 9i, the actual column is not present until 10.1. Change-Id: Iebfa59bfcfdff859169df349a5426137ab006e67 Fixes: #3875
* Add real .entities to _BundleEntityMike Bayer2016-12-191-2/+7
| | | | | | | | | Fixed bug where the single-table inheritance query criteria would not be inserted into the query in the case that the :class:`.Bundle` construct were used as the selection criteria. Change-Id: Ib7c128ceef5c3220a098cdfd0270c43a2a67716d Fixes: #3874
* Add _extend_on deduplicating set for metadata.reflect()Mike Bayer2016-11-233-11/+34
| | | | | | | | | | | | | The "extend_existing" option of :class:`.Table` reflection would cause indexes and constraints to be doubled up in the case that the parameter were used with :meth:`.MetaData.reflect` (as the automap extension does) due to tables being reflected both within the foreign key path as well as directly. A new de-duplicating set is passed through within the :meth:`.MetaData.reflect` sequence to prevent double reflection in this way. Change-Id: Ibf6650c1e76a44ccbe15765fd79df2fa53d6bac7 Fixes: #3861
* Allow the value 0 for Postgresql TIME/TIMESTAMP precisionIonuț Ciocîrlan2016-11-231-4/+4
| | | | | Change-Id: Ie38c48369222d95849645f027e2c659f503cfd53 Pull-request: https://github.com/zzzeek/sqlalchemy/pull/322
* Ensure Variant passes along impl right-hand typeMike Bayer2016-11-223-7/+105
| | | | | | | | | | | | | | | | | | | Fixed issue in :class:`.Variant` where the "right hand coercion" logic, inherited from :class:`.TypeDecorator`, would coerce the right-hand side into the :class:`.Variant` itself, rather than what the default type for the :class:`.Variant` would do. In the case of :class:`.Variant`, we want the type to act mostly like the base type so the default logic of :class:`.TypeDecorator` is now overridden to fall back to the underlying wrapped type's logic. Is mostly relevant for JSON at the moment. This patch additionally adds documentation and basic tests to allow for backend-agnostic comparison of JSON index elements to other objects. A future version should attempt to improve upon this by providing "astext", "asint" types of operators. Change-Id: I7b7b45d604a4ae8d1dc236a5a1248695aab5232e Fixes: #3859
* Disable single-inheritance critera on the outside of UNIONMike Bayer2016-11-181-19/+11
| | | | | | | | | | | | | Fixed bug related to :ticket:`3177`, where a UNION or other set operation emitted by a :class:`.Query` would apply "single-inheritance" criteria to the outside of the union (also referencing the wrong selectable), even though this criteria is now expected to be already present on the inside subqueries. The single-inheritance criteria is now omitted once union() or another set operation is called against :class:`.Query` in the same way as :meth:`.Query.from_self`. Change-Id: I0fd1331c7ba85a758a1c15e06c271914f2c717f3 Fixes: #3856
* Port lower case quoted name fix to firebirdMike Bayer2016-11-162-1/+42
| | | | | | | | | | | | | | Ported the fix for Oracle quoted-lowercase names to Firebird, so that a table name that is quoted as lower case can be reflected properly including when the table name comes from the get_table_names() inspection function. Also genericize the test to the test suite for denormlized name dialects. Fixes: #3548 Change-Id: I8ca62e8d2b359e363ccb01cfe2daa0995354a3cb
* - 1.1.5 setupMike Bayer2016-11-161-1/+1
| | | | Change-Id: I937b12e464944221c2870e2fc62be15187c76b52
* Add missing items to collection.__getstate__Mike Bayer2016-11-141-1/+7
| | | | | | | | | | the refactor in b606e47ddc54 / ticket:3457 failed to adjust __getstate__ / __setstate__. need to memoize a few more things including the class itself so that we can navigate back to "attr". Change-Id: I4ece2a616cb8b9dac7b50763ca59e47d0f26cfdf Fixes: #3852
* Count columns using PrimaryKeyConstraint.__len__ directlyMike Bayer2016-11-121-1/+1
| | | | | | | | | | PrimaryKeyConstraint is present on Table however on table() and others it's a ColumnSet. The warning here only needs len() and PrimaryKeyConstraint supports that directly in the same way as ColumnSet. Change-Id: I19c11a39110bfef48cdea49a471e7ab80b537538 Fixes: #3842
* Quote URL tokens with semicolons for pyodbc, adodbapiMike Bayer2016-11-112-1/+19
| | | | | | | | | | Fixed bug in pyodbc dialect (as well as in the mostly non-working adodbapi dialect) whereby a semicolon present in the password or username fields could be interpreted as a separator for another token; the values are now quoted when semicolons are present. Change-Id: I5f99fd8db53ebf8e805e7d9d60bc09b8f1af603f Fixes: #3762
* Use configured props for mapper.attrs, mapper.all_orm_descriptorsMike Bayer2016-11-101-2/+2
| | | | | | | | | | | | Fixed bug where the :attr:`.Mapper.attrs`, :attr:`.Mapper.all_orm_descriptors` and other derived attributes would fail to refresh when mapper properties or other ORM constructs were added to the mapper/class after these accessors were first called. (also trying different ways to get the changelog to merge cleanly) Change-Id: Iaecdb4b3d8c3a3b44302a5880476e60a1f4e27d9 Fixes: #3778
* Merge "Consider version_id_prop when emitting bulk UPDATE"mike bayer2016-11-101-1/+6
|\
| * Consider version_id_prop when emitting bulk UPDATEMike Bayer2016-11-101-1/+6
| | | | | | | | | | | | | | | | | | The version id needs to be part of _changed_dict() so that the value is present to send to _emit_update_statements() Change-Id: Ia85f0ef7714296a75cdc6c88674805afbbe752c8 Fixes: #3781
* | Add conditional import for pysqlcipher3Kevin Jurczyk2016-11-101-2/+16
| | | | | | | | | | | | | | This is a Py3K supporting DBAPI for pysqlcipher. Change-Id: I2a625274a371908f4de9d37f33e05408894b334b Pull-request: https://github.com/zzzeek/sqlalchemy/pull/320
* | Merge "Remove non-working Connection.default_schema_name() method"mike bayer2016-11-101-3/+0
|\ \ | |/ |/|
| * Remove non-working Connection.default_schema_name() methodBenjamin Dopplinger2016-11-101-3/+0
| | | | | | | | | | | | | | | | | | | | | | The method `engine.base.Connection.default_schema_name` is broken since 4b532e2 (this was when `engine.dialect.get_default_schema_name` was replaced with `engine.dialect.default_schema_name`). The method is unused and also is not functional for end-user use, so remove it for now. Change-Id: I6ffbd9ce1b9b54ff6df63ed45d7d33591f183933 Pull-request: https://github.com/zzzeek/sqlalchemy/pull/321
* | Add support for server side cursors to mysqldb and pymysqlRoman Podoliaka2016-11-109-43/+269
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This allows to skip buffering of the results on the client side, e.g. the following snippet: table = sa.Table( 'testtbl', sa.MetaData(), sa.Column('id', sa.Integer, primary_key=True), sa.Column('a', sa.Integer), sa.Column('b', sa.String(512)) ) table.create(eng, checkfirst=True) with eng.connect() as conn: result = conn.execute(table.select().limit(1)).fetchone() if result is None: for _ in range(1000): conn.execute( table.insert(), [{'a': random.randint(1, 100000), 'b': ''.join(random.choice(string.ascii_letters) for _ in range(100))} for _ in range(1000)] ) with eng.connect() as conn: for row in conn.execution_options(stream_results=True).execute(table.select()): pass now uses ~23 MB of memory instead of ~327 MB on CPython 3.5.2 and PyMySQL 0.7.9. psycopg2 implementation and execution options (stream_results, server_side_cursors) are reused. Change-Id: I4dc23ce3094f027bdff51b896b050361991c62e2
* | Ensure attribute keys used for bulk update pk setMike Bayer2016-11-102-1/+11
|/ | | | | | | | Fixed bug in :meth:`.Session.bulk_update_mappings` where an alternate-named primary key attribute would not track properly into the UPDATE statement. Change-Id: I33e9140f45827772768fa548adcfeb4dbfc2208d Fixes: #3849
* Add quotes around PRAGMA values in pysqlcipher connect.Kevin Jurczyk2016-11-081-1/+1
| | | | | | | | | Arguments such as cipher, kdf_iter, cipher_page_size and cipher_use_hmac may (always?) require quotes within the PRAGMA directive. Change-Id: I2c808f34e1c44f0593b72b304e170e4af0a6035a Pull-request: https://github.com/zzzeek/sqlalchemy/pull/319
* Put include_table=True for DO UPDATE..WHERE, but not ON CONFLICTMike Bayer2016-11-071-0/+1
| | | | | | | | | | | | | Fixed regression caused by the fix in :ticket:`3807` (version 1.1.0) where we ensured that the tablename was qualified in the WHERE clause of the DO UPDATE portion of PostgreSQL's ON CONFLICT, however you *cannot* put the table name in the WHERE clause in the actual ON CONFLICT itself. This was an incorrect assumption, so that portion of the change in :ticket:`3807` is rolled back. Change-Id: I442d8629496a8e405b54711cfcf487761810ae8a Fixes: #3846 Fixes: #3807
* Move setup functionality into _register_attributeMike Bayer2016-11-062-22/+17
| | | | | | | | | | | | | | | | | | | | | | | | | | Options like uselist and backref can be determined from within _register_attribute based on parent_property given; move this logic inside so that individual strategies have less responsibility. Also don't require that _register_attribute consider the "strategy" itself at all; it would be better if we could no longer require that Joined/Subquery/etc loaders call upon the "lazy" strategy in order to initialize attribute instrumentation and this could be done more generically. Fixes long-standing bug where the "noload" relationship loading strategy would cause backrefs and/or back_populates options to be ignored. There is concern that some application that uses "noload" might be surprised at a back-populating attribute appearing suddenly, which may have side effects. However, "noload" itself must be extremely seldom used since as a strategy, it already disables loading, population of attributes is the only behavior that is even supported, so that this issue has existed for at least through 0.7 four years ago without ever being reported indicates extremely low use of this option. Change-Id: Icffb9c83ac5782b76ce882ed1df4361a1efbfba3 Fixes: #3845
* Add check for blank string coming from MySQL's enumMike Bayer2016-10-281-0/+10
| | | | | | | | | | | | | MySQL's native ENUM type supports any non-valid value being sent, and in response will return a blank string. A hardcoded rule to check for "is returning the blank string" has been added to the MySQL implementation for ENUM so that this blank string is returned to the application rather than being rejected as a non-valid value. Note that if your MySQL enum is linking values to objects, you still get the blank string back. Change-Id: I61f85c20293a48b0c11a31f2a19f6756c206bd20 Fixes: #3841
* - 1.1.4 versioningMike Bayer2016-10-281-1/+1
| | | | Change-Id: I6545ebfeeee103cac133d0b8270a860cba2d2996
* Merge "Restore object to the identity_map upon delete() unconditionally"mike bayer2016-10-272-3/+9
|\
| * Restore object to the identity_map upon delete() unconditionallyMike Bayer2016-10-272-3/+9
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Fixed regression caused by :ticket:`2677` whereby calling :meth:`.Session.delete` on an object that was already flushed as deleted in that session would fail to set up the object in the identity map (or reject the object), causing flush errors as the object were in a state not accommodated by the unit of work. The pre-1.1 behavior in this case has been restored, which is that the object is put back into the identity map so that the DELETE statement will be attempted again, which emits a warning that the number of expected rows was not matched (unless the row were restored outside of the session). Change-Id: I9a8871f82cb1ebe67a7ad54d888d5ee835a9a40a Fixes: #3839
* | Minor fixes in the ext.hybrid documentation.pr/316Randy Barlow2016-10-231-2/+2
|/
* Ensure .mapper is set on _ColumnEntityMike Bayer2016-10-211-1/+6
| | | | | | | | | | | | | | _ColumnEntity didn't seem to have .mapper present, which due to the way _mapper_zero() worked didn't tend to come across it. With :ticket:`3608` _mapper_zero() has been simplified so make sure this is now present. Also ensure that _select_from_entity is an entity and not a mapped class, though this does not seem to matter at the moment. Fixes: #3836 Change-Id: Id6dae8e700269b97de3b01562edee95ac1e01f80
* Don't set pg autoincrement if type affinity is not IntegerMike Bayer2016-10-201-1/+2
| | | | | | | | | | | | | | | Postgresql table reflection will ensure that the :paramref:`.Column.autoincrement` flag is set to False when reflecting a primary key column that is not of an :class:`.Integer` datatype, even if the default is related to an integer-generating sequence. This can happen if a column is created as SERIAL and the datatype is changed. The autoincrement flag can only be True if the datatype is of integer affinity in the 1.1 series. This bug is related to a test failure in downstream sqlalchemy_migrate. Change-Id: I40260e47e1927a1ac940538408983c943bbdba28 Fixes: #3835
* Convert expression type for concat + EnumMike Bayer2016-10-201-0/+13
| | | | | | | | | | | | Fixed bug involving new value translation and validation feature in :class:`.Enum` whereby using the enum object in a string concatenation would maintain the :class:`.Enum` type as the type of the expression overall, producing missing lookups. A string concatenation against an :class:`.Enum`-typed column now uses :class:`.String` as the datatype of the expression itself. Change-Id: Id402054e3ef008e0250c740dbb7e1c80f339fe78 Fixes: #3833
* Ensure TypeDecorator delegates _set_parent_with_dispatchMike Bayer2016-10-202-2/+4
| | | | | | | | | | | | | | | | Ensure TypeDecorator delegates _set_parent_with_dispatch as well as _set_parent to itself as well as its impl, as the TypeDecorator class itself may have an active SchemaType implementation as well. Fixed regression which occurred as a side effect of :ticket:`2919`, which in the less typical case of a user-defined :class:`.TypeDecorator` that was also itself an instance of :class:`.SchemaType` (rather than the implementation being such) would cause the column attachment events to be skipped for the type itself. Change-Id: I0afb498fd91ab7d948e4439e7323a89eafcce0bc Fixes: #3832
* - open for 1.1.3Mike Bayer2016-10-201-1/+1
| | | | Change-Id: I283e52a7a63ec4f7a285aba1b41627f11b7ad41b
* Rewrite migration notes for [ticket:3514]Mike Bayer2016-10-193-0/+20
| | | | | | | | | | | | | | | | | | | The change to "evaluates none" datatypes in the ORM was not fully described in the migration notes, missing the key behavioral change that a column which is missing a default entirely will not receive a value for a missing JSON column now. The issue here touched upon a revisit of the assumptions in [ticket:3514], but overall the old behavior "worked" mostly because the ORM wants to explicitly render NULL into an INSERT for column values that are missing, which itself is a legacy behavior which should be considered for possible removal in a future major release. Given that "missing ORM value + no column default set up == dont put it in the INSERT" would be the most intuitive behavior, the move in [ticket:3514] represents a step in this direction. Change-Id: I454d5bb0773bd73d9864925dcc47f1f0810e33ba Fixes: #3830
* Add a qualifying character to multi INSERT..VALUES parameter namesMike Bayer2016-10-171-3/+3
| | | | | | | | | | Changed the naming convention used when generating bound parameters for a multi-VALUES insert statement, so that the numbered parameter names don't conflict with the anonymized parameters of a WHERE clause, as is now common in a PostgreSQL ON CONFLICT construct. Change-Id: I3188d100fe4d322a47d344d6a63d3e40b915f228 Fixes: #3828
* Add explicit copy() to EnumMike Bayer2016-10-171-0/+3
| | | | | | | | | | | | | | | | | The Boolean and Enum types both place SchemaType second in the inheritance hierarchy. In the case of Enum, this works out that the copy() method is called from the base TypeEngine which fails to transfer _create_events. The test suite doesn't seem to work with the inhertance hierarchy set up like this as the event listeners don't work out, the _on_metadata_create and _on_table_create hooks cause the production of an adapted type which then adds event listeners that cause deque changed while iteration. It's not clear why Enum /Boolean don't have this problem. But in any case it seems like the class mechanics for these types remains fragile and would benefit from yet another refactor someday. Change-Id: Ib641a5d2321b00f58bbe98dd0c5e789374db32b2 Fixes: #3827
* Memoize load_path in all cases, run quick populators for path changeMike Bayer2016-10-172-14/+36
| | | | | | | | | | | | | | | | | | | | | | | | Adds a new variant to the "isnew" state within entity loading for isnew=False, but the load path is new. This is to address the use case of an entity appearing in multiple places in the row in a more generalized way than the fixes in [ticket:3431], [ticket:3811] in that loading.py will be able to tell the populator that this row is not "isnew" but is a "new" path for the entity. For the moment, the new information is only being applied to the use of "quick" populators so that simple column loads can take place on top of a deferred loader from elsewhere in the row. As part of this change, state.load_path() will now always be populated with the "path" that was in effect when this state was originally loaded, which for multi-path loads of the same entity is still non-deterministic. Ideally there'd be some kind of "here's all the paths that loaded this state and how" type of data structure though it's not clear if that could be done while maintaining performance. Fixes: #3822 Change-Id: Ib915365353dfcca09e15c24001a8581113b97d5e
* Assemble "don't joinedload other side" rule using query._current_pathMike Bayer2016-10-173-3/+18
| | | | | | | | | Discovered during testing for [ticket:3822], the rule added for [ticket:1495] will fail if the source object has propagated options set up, which add elements to query._current_path. Fixes: #3824 Change-Id: I3d96c96fee5f9b247f739d2136d18681ac61f2fe
* Merge "Check for __module__ not present in util.wrap_callable()"mike bayer2016-10-171-1/+2
|\