summaryrefslogtreecommitdiff
path: root/lib/sqlalchemy/sql
Commit message (Collapse)AuthorAgeFilesLines
...
* | Improve serializer behaviorMike Bayer2017-03-141-0/+3
|/ | | | | | | | | | Fix an issue where the Annotated system needs to have a __reduce__ method, also see why we can't default to HIGHEST_PROTOCOL. This latter part might not be a good idea until 1.2 for compatibility reasons. Change-Id: I0239e38259fc768c9e3b6c448c29161e271a969c Fixes: #3918
* add autoescape option to startswith, endswith, and containsDiana Clarke2017-03-141-13/+110
| | | | | | Fixes: #2694 Change-Id: I34c0bdcb01c2b76b9ab6cd315dae13e3dd8a502b Pull-request: https://github.com/zzzeek/sqlalchemy/pull/207
* - add a note as to why we have this very complicated AnnotatedMike Bayer2017-03-091-0/+7
| | | | | | system Change-Id: I7d4048b92fcd3a7c7630c43aa9390d983f447c0a
* Allow SchemaType and Variant to work togetherMike Bayer2017-03-072-11/+79
| | | | | | | | | | | | | | Added support for the :class:`.Variant` and the :class:`.SchemaType` objects to be compatible with each other. That is, a variant can be created against a type like :class:`.Enum`, and the instructions to create constraints and/or database-specific type objects will propagate correctly as per the variant's dialect mapping. Also added testing for some potential double-event scenarios on TypeDecorator but it seems usually this doesn't occur. Change-Id: I4a7e7c26b4133cd14e870f5bc34a1b2f0f19a14a Fixes: #2892
* - document ForeignKeyConstraint columns / elements, fixes #2904Mike Bayer2017-03-071-0/+22
| | | | Change-Id: Ia50a3100d1bd88020c30224932b16aeadd7f4c75
* Don't cache savepoint identifiersMike Bayer2017-03-061-1/+7
| | | | | | | | | | | | | | | | | | | | | | | | Fixed bug in compiler where the string identifier of a savepoint would be cached in the identifier quoting dictionary; as these identifiers are arbitrary, a small memory leak could occur if a single :class:`.Connection` had an unbounded number of savepoints used, as well as if the savepoint clause constructs were used directly with an unbounded umber of savepoint names. The memory leak does **not** impact the vast majority of cases as normally the :class:`.Connection`, which renders savepoint names with a simple counter starting at "1", is used on a per-transaction or per-fixed-number-of-transactions basis before being discarded. The savepoint name in virtually all cases does not require quoting at all, however to support potential third party use cases the "check for quotes needed" logic is retained, at a small performance cost. Uncondtionally quoting the name is another option, but this would turn the name into a case sensitive name which runs the risk of poor interactions with existing deployments that may be looking at these names in other contexts. Change-Id: I6b53c96abf7fdf1840592bbca5da81347911844c Fixes: #3931
* Only use schema_translate_map on SchemaItem subclassesMike Bayer2017-02-283-1/+11
| | | | | | | | | | | | | Fixed bug in new "schema translate" feature where the translated schema name would be invoked in terms of an alias name when rendered along with a column expression; occurred only when the source translate name was "None". The "schema translate" feature now only takes effect for :class:`.SchemaItem` and :class:`.SchemaType` subclasses, that is, objects that correspond to a DDL-creatable structure in a database. Change-Id: Ie8cb35aeaba2c67efec8c8c57c219e4dd346e44a Fixes: #3924
* - add a note referring to the enum value as not currently persisted,Mike Bayer2017-02-011-3/+8
| | | | | | reference #3906 Change-Id: I2274c356cc88cd011c5a34a69e75a2548a93e87a
* - clarify Enum validation rules, fixes #3904Mike Bayer2017-02-011-6/+15
| | | | Change-Id: I221f161ae77ee1b9487329330bc520ab65e97611
* - correctly document LIKE / ILIKE, fixes #3890Mike Bayer2017-01-161-6/+16
| | | | Change-Id: Ie59e61f53d7c59a4777ab9e6e75a43c71d67523b
* Better hide engine passwordValery Yundin2017-01-161-2/+2
| | | | | | | | | | Avoid putting engine password in the exception message in `MetaData.reflect` (since exception messages often appear in logs). Use the same redacted `__repr__` implementation in `TLEngine` as in its base class `Engine` Change-Id: Ic0a7baea917a9c8d87dffdd82ef566673ab08e02 Pull-request: https://github.com/zzzeek/sqlalchemy/pull/327
* Merge "Support python3.6"mike bayer2017-01-1310-89/+89
|\
| * Support python3.6Mike Bayer2017-01-1310-89/+89
| | | | | | | | | | | | | | | | | | | | | | 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
* | Pass **kw to bound params in multi valuesMike Bayer2017-01-091-1/+1
|/ | | | | | | | | Fixed bug where literal_binds compiler flag was not honored by the :class:`.Insert` construct for the "multiple values" feature; the subsequent values are now rendered as literals. Change-Id: I81ac358fd59995885d482e7571620090210865d2 Fixes: #3880
* 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
* | update for 2017 copyrightMike Bayer2017-01-0419-19/+19
|/ | | | Change-Id: I4e8c2aa8fe817bb2af8707410fa0201f938781de
* 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
* 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
* Add _extend_on deduplicating set for metadata.reflect()Mike Bayer2016-11-231-6/+18
| | | | | | | | | | | | | 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
* Ensure Variant passes along impl right-hand typeMike Bayer2016-11-222-1/+52
| | | | | | | | | | | | | | | | | | | 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
* 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
* 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
* Rewrite migration notes for [ticket:3514]Mike Bayer2016-10-192-0/+14
| | | | | | | | | | | | | | | | | | | 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
* Update the Column.nullable docstring for the primary_key=True caseMatt Riedemann2016-10-101-4/+8
| | | | | | | | | | | | | | | | | While reviewing a change that created a new table, the primary_key column value was set to True but nullable was not explicitly set, which led to some confusion over the default behavior for the nullable column value when setting a primary_key. Looking at the docs it's not clear, but the code shows that if nullable is not specified, then nullable = not primary_key, so nullable defaults to False when primary_key is True. This patch adds a simple clarification to the docs so people don't have to check the code. Change-Id: I8553339d56fbae11370c7c6af6d8d4723163be1c Pull-request: https://github.com/zzzeek/sqlalchemy/pull/312
* spelling: Postgresql -> PostgreSQLVille Skyttä2016-10-089-40/+40
|
* Spelling fixesVille Skyttä2016-10-082-2/+2
|
* Change autoincrement compileerror to a warningMike Bayer2016-10-071-5/+5
| | | | | | | | Users are complaining that IntegrityError is no longer raised. Change-Id: I0855d5b7a98d4338f0910501b6e6d404ba33634d Fixes: #3216
* Propagate execution_options at compile stageMike Bayer2016-10-051-0/+15
| | | | | | | | Compiler can now set up execution options and additionally will propagate autocommit from embedded CTEs. Change-Id: I19db7b8fe4d84549ea95342e8d2040189fed1bbe Fixes: #3805
* Add "eager_parenthesis" late-compilation rule, use w/ PG JSON/HSTOREMike Bayer2016-10-012-6/+29
| | | | | | | | | | | | Added compiler-level flags used by Postgresql to place additional parenthesis than would normally be generated by precedence rules around operations involving JSON, HSTORE indexing operators as well as within their operands since it has been observed that Postgresql's precedence rules for at least the HSTORE indexing operator is not consistent between 9.4 and 9.5. Fixes: #3806 Change-Id: I5899677b330595264543b055abd54f3c76bfabf2
* - some documentation hitsMike Bayer2016-10-011-5/+15
| | | | Change-Id: I468fe70168804b08cf0d5e8b57e235bca904b1ff
* Escape literal string values passed to server_defaultMike Bayer2016-09-301-1/+2
| | | | | | | | | | | A string sent as a column default via the :paramref:`.Column.server_default` parameter is now escaped for quotes. This change is backwards compatible with code that may have been working around this previously. Change-Id: I341298a76cc67bc0a53df4ab51ab9379f2294cdd Fixes: #3809
* - clarify documentation on timezone flag, since Oracle has bothMike Bayer2016-09-221-5/+36
| | | | | | | DATE / TIMESTAMP separately the timezone flag will not bump the type to TIMESTAMP WITH TIMEZONE on that backend. Change-Id: I185992093472e1620b8cf84872631a4d48f8edc3
* Merge "Exclude eq and ne from associative operators"mike bayer2016-09-201-1/+1
|\
| * Exclude eq and ne from associative operatorsJohn Passaro2016-09-191-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | The "eq" and "ne" operators are no longer part of the list of "associative" operators, while they remain considered to be "commutative". This allows an expression like ``(x == y) == z`` to be maintained at the SQL level with parenthesis. Pull request courtesy John Passaro. Fixes: #3799 Change-Id: I3759d8987b35649d7418b6524316c9e70c857e68 Pull-request: https://github.com/zzzeek/sqlalchemy/pull/308
* | Support bindparam() with callable for primaryjoinMike Bayer2016-09-191-1/+2
|/ | | | | | | | | | | Fixes the comparison of bindparam() objects based on the "callable" parameter being present which helps to correctly detect use_get, and also checks for "callable" when detecting parameters for value substitution and will not impact the object if present. Change-Id: I4c93ee5d404d2648dd9835beeae0c5fb67e37d19 Fixes: #3767
* Repair foreign_keys population for Join._refresh_for_new_columnMike Bayer2016-09-151-1/+1
| | | | | | | | | | 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
* Merge "Allow stringify compiler to render unnamed column"mike bayer2016-09-021-3/+8
|\
| * Allow stringify compiler to render unnamed columnMike Bayer2016-09-021-3/+8
| | | | | | | | | | | | | | | | | | | | Stringify of expression with unnamed :class:`.Column` objects, as occurs in lots of situations including ORM error reporting, will now render the name in string context as "<name unknown>" rather than raising a compile error. Change-Id: I76f637c5eb4cfdb1b526964cb001565b97e296da Fixes: #3789
* | Repair clauselist comparison to account for clause orderingMike Bayer2016-09-021-5/+16
|/ | | | | | | | | | | | | | | | Fixed bug where the "simple many-to-one" condition that allows lazy loading to use get() from identity map would fail to be invoked if the primaryjoin of the relationship had multiple clauses separated by AND which were not in the same order as that of the primary key columns being compared in each clause. This ordering difference occurs for a composite foreign key where the table-bound columns on the referencing side were not in the same order in the .c collection as the primary key columns on the referenced side....which in turn occurs a lot if one is using declarative mixins and/or declared_attr to set up columns. Change-Id: I66cce74f614c04ed693dc0d58ac8c952b2f8ae54 Fixes: #3788
* Check for supports_execution at ClauseElement baseMike Bayer2016-08-313-5/+11
| | | | | | | | | | Raise a more descriptive exception / message when ClauseElement or non-SQLAlchemy objects that are not "executable" are erroneously passed to ``.execute()``; a new exception ObjectNotExecutableError is raised consistently in all cases. Change-Id: I2dd393121e2c7e5b6b9e40286a2f25670876e8e4 Fixes: #3786
* Fixed example of upsert in the HasCTE.cte docstring bypr/302Vladimir Magamedov2016-08-271-18/+28
| | | | replacing it with more concrete and working example.
* Spelling fixespr/299Ville Skyttä2016-08-081-1/+1
|
* Build string/int processors for JSONIndexType, JSONPathTypeMike Bayer2016-08-041-2/+40
| | | | | | | | | | | | Fixed regression in JSON datatypes where the "literal processor" for a JSON index value, that needs to take effect for example within DDL, would not be invoked for the value. The native String and Integer datatypes are now called upon from within the JSONIndexType and JSONPathType. This is applied to the generic, Postgresql, and MySQL JSON types. Change-Id: Ifa5f2acfeee57a79d01d7fc85d265a37bd27c716 Fixes: #3765
* Ensure post-__clause_element__() expression are used in IndexMike Bayer2016-07-311-1/+3
| | | | | | | | | | | The change in Index for 1.1 combined with the fix for ref #3763 still fails to deliver the correct object resolved by __clause_element__() to the list of expressions for compilation. Make sure we use the expression that's been unwrapped from __clause_element__(). Change-Id: Ie1df8db5090de665048331786f0024d52851923f Fixes: #3763
* Index should extract __clause_element__() earlyMike Bayer2016-07-301-1/+4
| | | | | | | | | | | | Fixed bug where :class:`.Index` would fail to extract columns from compound SQL expressions if those SQL expressions were wrapped inside of an ORM-style ``__clause_element__()`` construct. This bug exists in 1.0.x as well, however in 1.1 is more noticeable as hybrid_property @expression now returns a wrapped element. Fixes: #3763 Change-Id: I992536386503a1fb3f2305790abe008d72c44c4a
* Allow Table._reset_exported to silently passMike Bayer2016-07-241-0/+3
| | | | | | | | | | | 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