summaryrefslogtreecommitdiff
path: root/test/sql/test_compiler.py
Commit message (Collapse)AuthorAgeFilesLines
* Fix many typos throughout the codebasepr/85Alex Gaynor2014-04-261-1/+1
| | | | Found using: https://github.com/intgr/topy
* - Adjusted the logic which applies names to the .c collection whenMike Bayer2014-02-261-2/+8
| | | | | | | | | a no-name :class:`.BindParameter` is received, e.g. via :func:`.sql.literal` or similar; the "key" of the bind param is used as the key within .c. rather than the rendered name. Since these binds have "anonymous" names in any case, this allows individual bound parameters to have their own name within a selectable if they are otherwise unlabeled. fixes #2974
* - Fixed bug where so-called "literal render" of :func:`.bindparam`Mike Bayer2014-02-051-0/+7
| | | | | | constructs would fail if the bind were constructed with a callable, rather than a direct value. This prevented ORM expressions from being rendered with the "literal_binds" compiler flag.
* - Fixed bug whereby SQLite compiler failed to propagate compiler argumentsMike Bayer2014-01-311-0/+6
| | | | | | | | | | such as "literal binds" into a CAST expression. - Fixed bug whereby binary type would fail in some cases if used with a "test" dialect, such as a DefaultDialect or other dialect with no DBAPI. - Fixed bug where "literal binds" wouldn't work with a bound parameter that's a binary type. A similar, but different, issue is fixed in 0.8.
* - conjunctions like and_() and or_() can now accept generators as arguments.Mike Bayer2014-01-051-0/+11
|
* - for [ticket:2651], leaving CheckConstraint alone, preferring to keepMike Bayer2013-12-161-1/+2
| | | | | | | | | backwards compatibility. A note about backslashing escapes is added. Because the Text() construct now supports bind params better, the example given in the code raises an exception now, so that should cover us. The exception itself has been enhanced to include the key name of the bound param. We're backporting this to 0.8 but 0.8 doesn't have the text->bind behavior that raises.
* - The precedence rules for the :meth:`.ColumnOperators.collate` operatorMike Bayer2013-12-051-52/+0
| | | | | | | | | | | have been modified, such that the COLLATE operator is now of lower precedence than the comparison operators. This has the effect that a COLLATE applied to a comparison will not render parenthesis around the comparison, which is not parsed by backends such as MSSQL. The change is backwards incompatible for those setups that were working around the issue by applying :meth:`.Operators.collate` to an individual element of the comparison expression, rather than the comparison expression as a whole. [ticket:2879]
* - New improvements to the :func:`.text` construct, includingMike Bayer2013-11-291-166/+0
| | | | | | | | more flexible ways to set up bound parameters and return types; in particular, a :func:`.text` can now be turned into a full FROM-object, embeddable in other statements as an alias or CTE using the new method :meth:`.TextClause.columns`. [ticket:2877]
* - fix up rendering of "of"Mike Bayer2013-11-281-71/+7
| | | | | | - move out tests, dialect specific out of compiler, compiler tests use new API, legacy API tests in test_selecatble - add support for adaptation of ForUpdateArg, alias support in compilers
* - work in progress, will squashMike Bayer2013-11-281-0/+6
|
* An overhaul of expression handling for special symbols particularlyMike Bayer2013-10-231-15/+53
| | | | | | | | | | with conjunctions, e.g. ``None`` :func:`.expression.null` :func:`.expression.true` :func:`.expression.false`, including consistency in rendering NULL in conjunctions, "short-circuiting" of :func:`.and_` and :func:`.or_` expressions which contain boolean constants, and rendering of boolean constants and expressions as compared to "1" or "0" for backends that don't feature ``true``/``false`` constants. [ticket:2804]
* - Removed some now unneeded version checks [ticket:2829] courtesy alex gaynorMike Bayer2013-09-221-4/+0
|
* forgot to add system to the copy() methodMike Bayer2013-08-251-0/+7
| | | | | Conflicts: lib/sqlalchemy/schema.py
* added "system=True" to Column, so that we generally don't have to botherMike Bayer2013-08-251-0/+9
| | | | with CreateColumn rules
* Fixed bug where the expression system relied upon the ``str()``Mike Bayer2013-07-121-0/+40
| | | | | | | | | | | | form of a some expressions when referring to the ``.c`` collection on a ``select()`` construct, but the ``str()`` form isn't available since the element relies on dialect-specific compilation constructs, notably the ``__getitem__()`` operator as used with a Postgresql ``ARRAY`` element. The fix also adds a new exception class :class:`.UnsupportedCompilationError` which is raised in those cases where a compiler is asked to compile something it doesn't know how to. Also in 0.8.3. [ticket:2780]
* - rework of correlation, continuing on #2668, #2746Mike Bayer2013-06-261-11/+99
| | | | | | | | | | | | | | | | | | | | | | | | - add support for correlations to propagate all the way in; because correlations require context now, need to make sure a select enclosure of any level takes effect any number of levels deep. - fix what we said correlate_except() was supposed to do when we first released #2668 - "the FROM clause is left intact if the correlated SELECT is not used in the context of an enclosing SELECT..." - it was not considering the "existing_froms" collection at all, and prohibited additional FROMs from being placed in an any() or has(). - add test for multilevel any() - lots of docs, including glossary entries as we really need to define "WHERE clause", "columns clause" etc. so that we can explain correlation better - based on the insight that a SELECT can correlate anything that ultimately came from an enclosing SELECT that links to this one via WHERE/columns/HAVING/ORDER BY, have the compiler keep track of the FROM lists that correspond in this way, link it to the asfrom flag, so that we send to _get_display_froms() the exact list of candidate FROMs to correlate. no longer need any asfrom logic in the Select() itself - preserve 0.8.1's behavior for correlation when no correlate options are given, not to mention 0.7 and prior's behavior of not propagating implicit correlation more than one level.. this is to reduce surprises/hard-to-debug situations when a user isn't trying to correlate anything.
* test tweakMike Bayer2013-06-031-1/+4
|
* Merge branch 'master' into ticket_1068Mike Bayer2013-06-031-10/+12
|\
| * - unicode literals need to just be handled differently if they have utf-8Mike Bayer2013-05-041-2/+3
| | | | | | | | | | encoded in them vs. unicode escaping. not worth figuring out how to combine these right now
| * - test_types, test_compiler, with sqlite at leastMike Bayer2013-04-281-1/+2
| |
| * - the raw 2to3 runMike Bayer2013-04-271-9/+9
| | | | | | | | - went through examples/ and cleaned out excess list() calls
* | magic accessors to the rescueMike Bayer2013-05-271-13/+0
| |
* | still not locating more nested expressions, may need to match on nameMike Bayer2013-05-271-11/+29
| |
* | attempt number one, doesn't detect though if the label in the order by is ↵Mike Bayer2013-05-271-0/+63
|/ | | | not directly present there.
* - reinstate insert returning back into test_insert.py; defaultdialectMike Bayer2013-04-011-4/+0
| | | | needs to be explicit here since tablestest sticks testing.db onto metadata.bind
* moving insert returning test back into CRUD test class until I figure out ↵Diana Clarke2013-03-301-0/+5
| | | | why moving it broke the oracle/postgres builds
* move the update tests from CRUDTest into sql/test_update.py (see #2630)Diana Clarke2013-03-301-103/+0
|
* move the insert tests from CRUDTest into sql/test_insert.py (see #2630)Diana Clarke2013-03-291-219/+1
|
* move the delete tests from CRUDTest into sql/test_delete.py (see #2630)Diana Clarke2013-03-291-46/+1
|
* merge plus fix the test spelling tooMike Bayer2013-03-181-2/+2
|
* - since correlation is now always at least semi-automatic, remove theMike Bayer2013-03-091-33/+241
| | | | | | ability for correlation to have any effect for a SELECT that's stated in the FROM. - add a new exhaustive test suite for correlation to test_compiler
* Changed behavior of Select.correlate() to ignore correlations to froms that ↵Luke Cyca2013-03-071-2/+6
| | | | don't exist in the superquery.
* #2629Mike Bayer2013-01-251-0/+8
| | | | | insert().returning() raises an informative CompileError if attempted to compile on a dialect that doesn't support RETURNING.
* attempt to hide these from 2to3Mike Bayer2012-12-081-3/+3
|
* internally at least refer to multirow as "multivalues", to distinguish betweenMike Bayer2012-12-081-5/+5
| | | | | an INSERT that's used in executemany() as opposed to one which has a VALUES clause with multiple entries.
* - multivalued inserts, [ticket:2623]Mike Bayer2012-12-081-11/+142
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | - update "not supported" messages for empty inserts, mutlivalue inserts - rework the ValuesBase approach for multiple value sets so that stmt.parameters does store a list for multiple values; the _has_multiple_parameters flag now indicates which of the two modes the statement is within. it now raises exceptions if a subsequent call to values() attempts to call a ValuesBase with one mode in the style of the other mode; that is, you can't switch a single- or multi- valued ValuesBase to the other mode, and also if a multiple value is passed simultaneously with a kwargs set. Added tests for these error conditions - Calling values() multiple times in multivalue mode now extends the parameter list to include the new parameter sets. - add error/test if multiple *args were passed to ValuesBase.values() - rework the compiler approach for multivalue inserts, back to where _get_colparams() returns the same list of (column, value) as before, thereby maintaining the identical number of append() and other calls when multivalue is not enabled. In the case of multivalue, it makes a last-minute switch to return a list of lists instead of the single list. As it constructs the additional lists, the inline defaults and other calculated default parameters of the first parameter set are copied into the newly generated lists so that these features continue to function for a multivalue insert. Multivalue inserts now add no additional function calls to the compilation for regular insert constructs. - parameter lists for multivalue inserts now includes an integer index for all parameter sets. - add detailed documentation for ValuesBase.values(), including careful wording to describe the difference between multiple values and an executemany() call. - add a test for multivalue insert + returning - it works ! - remove the very old/never used "postgresql_returning"/"firebird_returning" flags.
* compiler: add support for multirow insertsIdan Kamara2012-12-061-0/+15
| | | | | | | | | | | | | | | | | | | | | Some databases support this syntax for inserts: INSERT INTO table (id, name) VALUES ('v1', 'v2'), ('v3', 'v4'); which greatly increases INSERT speed. It is now possible to pass a list of lists/tuples/dictionaries as the values param to the Insert construct. We convert it to a flat dictionary so we can continue using bind params. The above query will be converted to: INSERT INTO table (id, name) VALUES (:id, :name), (:id0, :name0); Currently only supported on postgresql, mysql and sqlite.
* Fixed bug where keyword arguments passed toMike Bayer2012-10-241-1/+48
| | | | | | | | :meth:`.Compiler.process` wouldn't get propagated to the column expressions present in the columns clause of a SELECT statement. In particular this would come up when used by custom compilation schemes that relied upon special flags. [ticket:2593]
* - move most/all operator specific tests into test_operator, convert fully to TOTMike Bayer2012-10-241-208/+0
|
* - get 100% lint/pep8 happening for test_compiler; next we will beginMike Bayer2012-10-241-564/+615
| | | | | | cutting up tests and removing old ones - move test_in() to test_operators - slice up migrated operator tests into TOT
* The auto-correlation feature of :func:`.select`, andMike Bayer2012-10-221-9/+4
| | | | | | | | | by proxy that of :class:`.orm.Query`, will not take effect for a SELECT statement that is being rendered directly in the FROM list of the enclosing SELECT. Correlation in SQL only applies to column expressions such as those in the WHERE, ORDER BY, columns clause. [ticket:2595]
* - [feature] The Query can now load entity/scalar-mixedMike Bayer2012-10-151-1/+17
| | | | | | | | | | | | | | | | | | | | | | | | | | "tuple" rows that contain types which aren't hashable, by setting the flag "hashable=False" on the corresponding TypeEngine object in use. Custom types that return unhashable types (typically lists) can set this flag to False. [ticket:2592] - [bug] Applying a column expression to a select statement using a label with or without other modifying constructs will no longer "target" that expression to the underlying Column; this affects ORM operations that rely upon Column targeting in order to retrieve results. That is, a query like query(User.id, User.id.label('foo')) will now track the value of each "User.id" expression separately instead of munging them together. It is not expected that any users will be impacted by this; however, a usage that uses select() in conjunction with query.from_statement() and attempts to load fully composed ORM entities may not function as expected if the select() named Column objects with arbitrary .label() names, as these will no longer target to the Column objects mapped by that entity. [ticket:2591]
* - [feature] "scalar" selects now have a WHERE methodMike Bayer2012-10-151-10/+27
| | | | | | | | | | | | | | | | | | | | to help with generative building. Also slight adjustment regarding how SS "correlates" columns; the new methodology no longer applies meaning to the underlying Table column being selected. This improves some fairly esoteric situations, and the logic that was there didn't seem to have any purpose. - [feature] Some support for auto-rendering of a relationship join condition based on the mapped attribute, with usage of core SQL constructs. E.g. select([SomeClass]).where(SomeClass.somerelationship) would render SELECT from "someclass" and use the primaryjoin of "somerelationship" as the WHERE clause. This changes the previous meaning of "SomeClass.somerelationship" when used in a core SQL context; previously, it would "resolve" to the parent selectable, which wasn't generally useful. Related to [ticket:2245].
* - [bug] Fixed bug in over() construct wherebyMike Bayer2012-09-301-0/+28
| | | | | | | | passing an empty list for either partition_by or order_by, as opposed to None, would fail to generate correctly. Courtesy Gunnlaugur Por Briem. [ticket:2574]
* trying different approaches to test layout. in this one, the testing modulesMike Bayer2012-09-271-2/+3
| | | | | | | become an externally usable package but still remains within the main sqlalchemy parent package. in this system, we use kind of an ugly hack to get the noseplugin imported outside of the "sqlalchemy" package, while still making it available within sqlalchemy for usage by third party libraries.
* - [feature] Reworked the startswith(), endswith(),Mike Bayer2012-08-271-55/+0
| | | | | | | | | | | | contains() operators to do a better job with negation (NOT LIKE), and also to assemble them at compilation time so that their rendered SQL can be altered, such as in the case for Firebird STARTING WITH [ticket:2470] - [feature] firebird - The "startswith()" operator renders as "STARTING WITH", "~startswith()" renders as "NOT STARTING WITH", using FB's more efficient operator. [ticket:2470]
* - [feature] The "required" flag is set toMike Bayer2012-08-271-6/+20
| | | | | | | | | | True by default, if not passed explicitly, on bindparam() if the "value" or "callable" parameters are not passed. This will cause statement execution to check for the parameter being present in the final collection of bound parameters, rather than implicitly assigning None. [ticket:2556]
* - [bug] Fixed bug whereby usage of a UNIONMike Bayer2012-08-221-1/+52
| | | | | | | | or similar inside of an embedded subquery would interfere with result-column targeting, in the case that a result-column had the same ultimate name as a name inside the embedded UNION. [ticket:2552]
* - [feature] The Core oeprator system now includesMike Bayer2012-08-201-63/+15
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | the `getitem` operator, i.e. the bracket operator in Python. This is used at first to provide index and slice behavior to the Postgresql ARRAY type, and also provides a hook for end-user definition of custom __getitem__ schemes which can be applied at the type level as well as within ORM-level custom operator schemes. Note that this change has the effect that descriptor-based __getitem__ schemes used by the ORM in conjunction with synonym() or other "descriptor-wrapped" schemes will need to start using a custom comparator in order to maintain this behavior. - [feature] postgresql.ARRAY now supports indexing and slicing. The Python [] operator is available on all SQL expressions that are of type ARRAY; integer or simple slices can be passed. The slices can also be used on the assignment side in the SET clause of an UPDATE statement by passing them into Update.values(); see the docs for examples. - [feature] Added new "array literal" construct postgresql.array(). Basically a "tuple" that renders as ARRAY[1,2,3].
* - [feature] The prefix_with() method is now availableMike Bayer2012-08-191-2/+53
| | | | | | | | on each of select(), insert(), update(), delete(), all with the same API, accepting multiple prefix calls, as well as a "dialect name" so that the prefix can be limited to one kind of dialect. [ticket:2431]