summaryrefslogtreecommitdiff
path: root/test/sql
Commit message (Collapse)AuthorAgeFilesLines
* Merge "Make a common approach for "emulated" types"mike bayer2017-09-262-17/+54
|\
| * Make a common approach for "emulated" typesMike Bayer2017-09-252-17/+54
| | | | | | | | | | | | | | | | | | | | | | | | | | | | Internal refinements to the :class:`.Enum`, :class:`.Interval`, and :class:`.Boolean` types, which now extend a common mixin :class:`.Emulated` that indicates a type that provides Python-side emulation of a DB native type, switching out to the DB native type when a supporting backend is in use. The Postgresql :class:`.INTERVAL` type when used directly will now include the correct type coercion rules for SQL expressions that also take effect for :class:`.sqltypes.Interval` (such as adding a date to an interval yields a datetime). Change-Id: Ifb9f9d7cbd9f5990dcb2abb583193e9e92b789ad Fixes: #4088
* | Add table / column comments into tometadata()Mike Bayer2017-09-231-5/+22
|/ | | | | | | | Fixed bug in new SQL comments feature where table and column comment would not be copied when using :meth:`.Table.tometadata`. Change-Id: Ib3112e5e02930245daacb36c8ed38c01fa3e7dbd Fixes: #4087
* Merge "Add __next__(), next() to ResultProxy"mike bayer2017-09-181-0/+17
|\
| * Add __next__(), next() to ResultProxyreview/mike_bayer/ticket_4077Mike Bayer2017-09-151-0/+17
| | | | | | | | | | | | | | | | | | | | | | | | | | Added ``__next__()`` and ``next()`` methods to :class:`.ResultProxy`, so that the ``next()`` builtin function works on the object directly. :class:`.ResultProxy` has long had an ``__iter__()`` method which already allows it to respond to the ``iter()`` builtin. The implementation for ``__iter__()`` is unchanged, as performance testing has indicated that iteration using a ``__next__()`` method with ``StopIteration`` is about 20% slower in both Python 2.7 and 3.6. Change-Id: I70569a4c48ad85a3c21a7ad422f270a559926cfb Fixes: #4077
* | Add multivalued insert context for defaultsreview/mike_bayer/ticket_4075Mike Bayer2017-09-161-0/+64
| | | | | | | | | | | | | | | | | | | | | | | | | | | | Added a new method :class:`.DefaultExecutionContext.current_parameters` which is used within a function-based default value generator in order to retrieve the current parameters being passed to the statement. The new function differs from the ``.current_parameters`` attribute in that it also provides for optional grouping of parameters that correspond to a multi-valued "insert" construct. Previously it was not possible to identify the subset of parameters that were relevant to the function call. Change-Id: I6894c7b4a2bce3e83c3ade8af0e5b2f8df37b785 Fixes: #4075
* | Implement placeholders for CUBE, ROLLUP, GROUPING SETSreview/mike_bayer/pr_github_383Spitcyn2017-09-131-0/+36
|/ | | | | | | | Fixes: #3429 Co-authored-by: Mike Bayer <mike_mp@zzzcomputing.com> Change-Id: I870ee7dc801d553c5309c291402ec468b671e9a9 Pull-request: https://github.com/zzzeek/sqlalchemy/pull/383
* Refactor for cx_Oracle version 6oracle_numericMike Bayer2017-09-113-5/+3
| | | | | | | | | Drops support for cx_Oracle prior to version 5.x, reworks numeric and binary support. Fixes: #4064 Change-Id: Ib9ae9aba430c15cd2a6eeb4e5e3fd8e97b5fe480
* - skip oracle tests until we can merge refactorMike Bayer2017-09-081-0/+2
| | | | Change-Id: Ie9bec6e8f51d52349dcbd8009981818e459e88b8
* Ensure custom ops have consistent typing behavior, boolean supportMike Bayer2017-09-011-2/+31
| | | | | | | | | | | | | | Refined the behavior of :meth:`.Operators.op` such that in all cases, if the :paramref:`.Operators.op.is_comparison` flag is set to True, the return type of the resulting expression will be :class:`.Boolean`, and if the flag is False, the return type of the resulting expression will be the same type as that of the left-hand expression, which is the typical default behavior of other operators. Also added a new parameter :paramref:`.Operators.op.return_type` as well as a helper method :meth:`.Operators.bool_op`. Change-Id: Ifc8553cd4037d741b84b70a9702cbd530f1a9de0 Fixes: #4063
* Add SQL Server CI coverageMike Bayer2017-08-315-11/+20
| | | | Change-Id: Ida0d01ae9bcc0573b86e24fddea620a38c962822
* Add new sane_rowcount_w_returning flagMike Bayer2017-08-311-0/+10
| | | | | | | | | | | | | | | | | Added a new class of "rowcount support" for dialects that is specific to when "RETURNING", which on SQL Server looks like "OUTPUT inserted", is in use, as the PyODBC backend isn't able to give us rowcount on an UPDATE or DELETE statement when OUTPUT is in effect. This primarily affects the ORM when a flush is updating a row that contains server-calcluated values, raising an error if the backend does not return the expected row count. PyODBC now states that it supports rowcount except if OUTPUT.inserted is present, which is taken into account by the ORM during a flush as to whether it will look for a rowcount. ORM tests are implicit in existing tests run against PyODBC Fixes: #4062 Change-Id: Iff17cbe4c7a5742971ed85a4d58660c18cc569c2
* Merge "Apply percent sign escaping to literal binds, comments"mike bayer2017-08-281-1/+18
|\
| * Apply percent sign escaping to literal binds, commentsMike Bayer2017-08-251-1/+18
| | | | | | | | | | | | | | | | | | | | | | | | | | | | Fixed bug in new percent-sign support (e.g. :ticket:`3740`) where a bound parameter rendered with literal_binds would fail to escape percent-signs for relevant dialects. In addition, ensured new table / column comment support feature also fully makes use of literal-rendered parameters so that this percent sign support takes place with table / column comment DDL as well, allowing percent sign support for the mysql / psycopg2 backends that require escaping of percent signs. Change-Id: Ia4136a300933e9bc6a01a7b9afd5c7b9a3fee4e3 Fixes: #4054 Fixes: #4052
* | Allow for multiple FOLLOWING/PRECEDING in a window rangeMike Bayer2017-08-251-12/+18
|/ | | | | | | | | | | Altered the range specification for window functions to allow for two of the same PRECEDING or FOLLOWING keywords in a range by allowing for the left side of the range to be positive and for the right to be negative, e.g. (1, 3) is "1 FOLLOWING AND 3 FOLLOWING". Change-Id: I7d3a6c641151bb49219104968d18dac2266f3db8 Fixes: #4053
* - a few mysql fixes, more to comeMike Bayer2017-08-201-7/+11
| | | | Change-Id: Icdcc8ed03374251b8d3815ae58e2726ea27c14b4
* Ensure Oracle index w/ col DESC etc. is reflectedMike Bayer2017-08-141-0/+15
| | | | | | | | | | | | | | | | | | | | Fixed bug where an index reflected under Oracle with an expression like "column DESC" would not be returned, if the table also had no primary key, as a result of logic that attempts to filter out the index implicitly added by Oracle onto the primary key columns. Reworked the "filter out the primary key index" logic in oracle get_indexes() to be clearer. This changeset also adds an internal check to ColumnCollection to accomodate for the case of a column being added twice, as well as adding a private _table argument to Index such that reflection can specify the Table explicitly. The _table argument can become part of public API in a later revision or release if needed. Change-Id: I745711e03b3e450b7f31185fc70e10d3823063fa Fixes: #4042
* Add support for CACHE and ORDER to sequencesDavid Moore2017-07-051-0/+12
| | | | | | | | | | | Added new keywords :paramref:`.Sequence.cache` and :paramref:`.Sequence.order` to :class:`.Sequence`, to allow rendering of the CACHE parameter understood by Oracle and PostgreSQL, and the ORDER parameter understood by Oracle. Pull request courtesy David Moore. Change-Id: I082c3f8ef56ef89dbaad5da9d5695be5313b0614 Pull-request: https://bitbucket.org/zzzeek/sqlalchemy/pull-requests/96
* Return given type when it matches the adaptationMike Bayer2017-06-261-2/+24
| | | | | | | | | | | | | The rules for type coercion between :class:`.Numeric`, :class:`.Integer`, and date-related types now include additional logic that will attempt to preserve the settings of the incoming type on the "resolved" type. Currently the target for this is the ``asdecimal`` flag, so that a math operation between :class:`.Numeric` or :class:`.Float` and :class:`.Integer` will preserve the "asdecimal" flag as well as if the type should be the :class:`.Float` subclass. Change-Id: Idfaba17220d6db21ca1ca4dcb4c19834cd397817 Fixes: #4018
* Coerce float Python type to Float; ensure Python float coming backMike Bayer2017-06-261-0/+17
| | | | | | | | | | | Added some extra strictness to the handling of Python "float" values passed to SQL statements. A "float" value will be associated with the :class:`.Float` datatype and not the Decimal-coercing :class:`.Numeric` datatype as was the case before, eliminating a confusing warning emitted on SQLite as well as unecessary coercion to Decimal. Change-Id: I1bb1810ff1d198c0d929ccba5656e55401d74119 Fixes: #4017
* Repair WithinGroup.get_children()Mike Bayer2017-06-161-0/+10
| | | | | | | | Fixed AttributeError which would occur in :class:`.WithinGroup` construct during an iteration of the structure. Change-Id: I563882d93c8c32292463a605b636aa60c77e9406 Fixes: #4012
* Merge "Raise if ForeignKeyConstraint created with different numbers of local ↵mike bayer2017-05-251-0/+23
|\ | | | | | | and remote columns."
| * Raise if ForeignKeyConstraint created with different numbers ofMike Bayer2017-05-251-0/+23
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | local and remote columns. An :class:`.ArgumentError` is now raised if a :class:`.ForeignKeyConstraint` object is created with a mismatched number of "local" and "remote" columns, which otherwise causes the internal state of the constraint to be incorrect. Note that this also impacts the condition where a dialect's reflection process produces a mismatched set of columns for a foreign key constraint. Downstream DB2 dialect has been reported as potentially causing this scenario. Change-Id: Id51c34a6c43749bb582639f9c1dc28723482f0e5 Fixes: #3949 References: #3998
* | Flatten operator precedence for comparison operatorsMichael Birtwell2017-05-251-0/+7
|/ | | | | | | | | | | | | | | The operator precedence for all comparison operators such as LIKE, IS, IN, MATCH, equals, greater than, less than, etc. has all been merged into one level, so that expressions which make use of these against each other will produce parentheses between them. This suits the stated operator precedence of databases like Oracle, MySQL and others which place all of these operators as equal precedence, as well as Postgresql as of 9.5 which has also flattened its operator precendence. Co-authored-by: Mike Bayer <mike_mp@zzzcomputing.com> Fixes: #3999 Change-Id: I3f3d5124a64af0d376361cdf15a97e2e703be56f Pull-request: https://github.com/zzzeek/sqlalchemy/pull/367
* Enforce boolean result type for all eq_, is_, isnot, comparisonMike Bayer2017-04-271-0/+10
| | | | | | | | | | | | Repaired issue where the type of an expression that used :meth:`.ColumnOperators.is_` or similar would not be a "boolean" type, instead the type would be "nulltype", as well as when using custom comparison operators against an untyped expression. This typing can impact how the expression behaves in larger contexts as well as in result-row-handling. Change-Id: Ib810ff686de500d8db26ae35a51005fab29603b6 Fixes: #3873
* Add _negate() to Label to negate inner elementMike Bayer2017-04-211-1/+15
| | | | | | | | | Fixed the negation of a :class:`.Label` construct so that the inner element is negated correctly, when the :func:`.not_` modifier is applied to the labeled expression. Change-Id: Ia99917b2959bdfbff28689c962b4203911c57b85 Fixes: #3969
* Add new "expanding" feature to bindparam()Mike Bayer2017-04-073-5/+87
| | | | | | | | | | | | | | | | Added a new kind of :func:`.bindparam` called "expanding". This is for use in ``IN`` expressions where the list of elements is rendered into individual bound parameters at statement execution time, rather than at statement compilation time. This allows both a single bound parameter name to be linked to an IN expression of multiple elements, as well as allows query caching to be used with IN expressions. The new feature allows the related features of "select in" loading and "polymorphic in" loading to make use of the baked query extension to reduce call overhead. This feature should be considered to be **experimental** for 1.2. Fixes: #3953 Change-Id: Ie708414a3ab9c0af29998a2c7f239ff7633b1f6e
* Double percent signs based on paramstyle, not dialectMike Bayer2017-04-053-30/+43
| | | | | | | | | | | | This patch moves the "doubling" of percent signs into the base compiler and makes it completely a product of whether or not the paramstyle is format/pyformat or not. Without this paramstyle, percent signs are not doubled across text(), literal_column(), and column(). Change-Id: Ie2f278ab1dbb94b5078f85c0096d74dbfa049197 Fixes: #3740
* Apply SQL compilation to sqltext for column-level CHECK constraintMike Bayer2017-04-041-0/+13
| | | | | | | | | | | | | Fixed bug where a column-level :class:`.CheckConstraint` would fail to compile the SQL expression using the underlying dialect compiler as well as apply proper flags to generate literal values as inline, in the case that the sqltext is a Core expression and not just a plain string. This was long-ago fixed for table-level check constraints in 0.9 as part of :ticket:`2742`, which more commonly feature Core SQL expressions as opposed to plain string expressions. Change-Id: I1301ba4b40063e91bc47726aecc5f4990ffcaeda Fixes: #3957
* ResultProxy won't autoclose connection until state flag is setMike Bayer2017-04-031-0/+44
| | | | | | | | | | | | | | Changed the mechanics of :class:`.ResultProxy` to unconditionally delay the "autoclose" step until the :class:`.Connection` is done with the object; in the case where Postgresql ON CONFLICT with RETURNING returns no rows, autoclose was occurring in this previously non-existent use case, causing the usual autocommit behavior that occurs unconditionally upon INSERT/UPDATE/DELETE to fail. Change-Id: I235a25daf4381b31f523331f810ea04450349722 Fixes: #3955 (cherry picked from commit 8ee363e4917b0dcd64a83b6d26e465c9e61e0ea5) (cherry picked from commit f52fb5282a046d26b6ee2778e03b995eb117c2ee)
* Merge "Use consistent method signature for Alias.self_group()"mike bayer2017-04-031-0/+14
|\
| * Use consistent method signature for Alias.self_group()Mike Bayer2017-04-031-0/+14
| | | | | | | | | | | | | | | | | | | | | | | | Fixed bug where the use of an :class:`.Alias` object in a column context would raise an argument error when it tried to group itself into a parenthesized expression. Using :class:`.Alias` in this way is not yet a fully supported API, however it applies to some end-user recipes and may have a more prominent role in support of some future Postgresql features. Change-Id: I81717e30416e0350f08d1e022c3d84656e0a9735 Fixes: #3939
* | Return self when Variant.coerce_compared_value would return implMike Bayer2017-04-011-2/+72
|/ | | | | | | | | | | | | Fixed regression released in 1.1.5 due to :ticket:`3859` where adjustments to the "right-hand-side" evaluation of an expression based on :class:`.Variant` to honor the underlying type's "right-hand-side" rules caused the :class:`.Variant` type to be inappropriately lost, in those cases when we *do* want the left-hand side type to be transferred directly to the right hand side so that bind-level rules can be applied to the expression's argument. Change-Id: Ia54dbbb19398549d654b74668753c4152599d900 Fixes: #3952
* Apply type processing to untyped preexec default clauseMike Bayer2017-03-301-8/+27
| | | | | | | | | | | | | | | | Fixed bug where a SQL-oriented Python-side column default could fail to be executed properly upon INSERT in the "pre-execute" codepath, if the SQL itself were an untyped expression, such as plain text. The "pre- execute" codepath is fairly uncommon however can apply to non-integer primary key columns with SQL defaults when RETURNING is not used. Tests exist here to ensure typing is applied to a typed expression for default, but in the case of an untyped SQL value, we know the type from the column, so apply this. Change-Id: I5d8b391611c137b9f700115a50a2bf5b30abfe94 Fixes: #3923
* Treat collation names as identifiersMike Bayer2017-03-232-8/+25
| | | | | | | | | | | The expression used for COLLATE as rendered by the column-level :func:`.expression.collate` and :meth:`.ColumnOperators.collate` is now quoted as an identifier when the name is case sensitive, e.g. has uppercase characters. Note that this does not impact type-level collation, which is already quoted. Change-Id: I83d5d9cd1e66a4f20b96303bb84c5f360d5d6a1a Fixes: #3785
* Merge branch 'master' of https://bitbucket.org/jalessio/sqlalchemyMike Bayer2017-03-181-1/+1
|\
| * Fix typos ('expicit' -> 'explicit')Jamie Alessio2017-03-141-1/+1
| |
* | Implement comments for tables, columnsFrazer McLean2017-03-171-1/+28
|/ | | | | | | | | | | | | | Added support for SQL comments on :class:`.Table` and :class:`.Column` objects, via the new :paramref:`.Table.comment` and :paramref:`.Column.comment` arguments. The comments are included as part of DDL on table creation, either inline or via an appropriate ALTER statement, and are also reflected back within table reflection, as well as via the :class:`.Inspector`. Supported backends currently include MySQL, Postgresql, and Oracle. Co-authored-by: Mike Bayer <mike_mp@zzzcomputing.com> Fixes: #1546 Change-Id: Ib90683850805a2b4ee198e420dc294f32f15d35d
* Add "empty in" strategies; default to "static"Mike Bayer2017-03-143-32/+108
| | | | | | | | | | | | | | | The longstanding behavior of the :meth:`.Operators.in_` and :meth:`.Operators.not_in_` operators emitting a warning when the right-hand condition is an empty sequence has been revised; a new flag :paramref:`.create_engine.empty_in_strategy` allows an empty "IN" expression to generate a simple boolean expression, or to invoke the previous behavior of dis-equating the expression to itself, with or without a warning. The default behavior is now to emit the simple boolean expression, allowing an empty IN to be evaulated without any performance penalty. Change-Id: I65cc37f2d7cf65a59bf217136c42fee446929352 Fixes: #3907
* Enable sane_multi_rowcount for cx_OracleMike Bayer2017-03-141-3/+31
| | | | | | | Also add some tests to test_rowcount. Change-Id: Idaa18fdc4fcfeb615725531c37de77decf76a783 Fixes: #3932
* add autoescape option to startswith, endswith, and containsDiana Clarke2017-03-141-13/+111
| | | | | | Fixes: #2694 Change-Id: I34c0bdcb01c2b76b9ab6cd315dae13e3dd8a502b Pull-request: https://github.com/zzzeek/sqlalchemy/pull/207
* Allow SchemaType and Variant to work togetherMike Bayer2017-03-072-10/+97
| | | | | | | | | | | | | | 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
* Repair missing "checkfirst" for test suiteMike Bayer2017-03-071-0/+1
| | | | | | | | the test_metadata tests trigger the before_create dispatch without the checkfirst flag. Postgresql backend should be able to tolerate this. Change-Id: Ife497cc3a4eb2812462116f94aad732864225f3f
* Only use schema_translate_map on SchemaItem subclassesMike Bayer2017-02-281-1/+45
| | | | | | | | | | | | | 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
* Make all tests to be PEP8 compliantKhairi Hafsham2017-02-0723-183/+199
| | | | | | | | tested using pycodestyle version 2.2.0 Fixes: #3885 Change-Id: I5df43adc3aefe318f9eeab72a078247a548ec566 Pull-request: https://github.com/zzzeek/sqlalchemy/pull/343
* Merge "Support python3.6"mike bayer2017-01-137-16/+18
|\
| * Support python3.6Mike Bayer2017-01-137-16/+18
| | | | | | | | | | | | | | | | | | | | | | 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-0/+12
|/ | | | | | | | | 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
* Tighten rules for order_by(Label) resolutionMike Bayer2017-01-061-0/+50
| | | | | | | | | | | | | | | | - 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
* Call nextval() on sequence when doing INSERT from SELECTMike Bayer2016-12-211-1/+20
| | | | | | | | 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