summaryrefslogtreecommitdiff
path: root/lib/sqlalchemy/sql/expression.py
Commit message (Collapse)AuthorAgeFilesLines
* - Made sqlalchemy.sql.expressions.Executable part of publicMike Bayer2010-02-121-22/+32
| | | | | | | | | | | API, used for any expression construct that can be sent to execute(). FunctionElement now inherits Executable so that it gains execution_options(), which are also propagated to the select() that's generated within execute(). Executable in turn subclasses _Generative which marks any ClauseElement that supports the @_generative decorator - these may also become "public" for the benefit of the compiler extension at some point.
* - The type/expression system now does a more complete jobMike Bayer2010-02-111-45/+43
| | | | | | | | | | | | | | | | | | of determining the return type from an expression as well as the adaptation of the Python operator into a SQL operator, based on the full left/right/operator of the given expression. In particular the date/time/interval system created for Postgresql EXTRACT in [ticket:1647] has now been generalized into the type system. The previous behavior which often occured of an expression "column + literal" forcing the type of "literal" to be the same as that of "column" will now usually not occur - the type of "literal" is first derived from the Python type of the literal, assuming standard native Python types + date types, before falling back to that of the known type on the other side of the expression. Also part of [ticket:1683].
* - FunctionElement subclasses are now directly executable theMike Bayer2010-02-071-3/+4
| | | | | | | | | | | same way any func.foo() construct is, with automatic SELECT being applied when passed to execute(). - The "type" and "bind" keyword arguments of a func.foo() construct are now local to "func." constructs and are not part of the FunctionElement base class, allowing a "type" to be handled in a custom constructor or class-level variable.
* - Added math negation operator support, -x.Mike Bayer2010-02-051-0/+6
|
* fix the kwargs scoping. mysteriously was affecting pool gcingMike Bayer2010-01-291-4/+5
|
* - inline some code and turn some instance-level defaults into class levelMike Bayer2010-01-291-3/+7
|
* - the "autocommit" flag on select() and text() as wellMike Bayer2010-01-281-19/+44
| | | | | | as select().autocommit() are deprecated - now call .execution_options(autocommit=True) on either of those constructs, also available directly on Connection and orm.Query.
* against is optionalMike Bayer2010-01-281-1/+1
|
* - allow exists(s.as_scalar()) to workMike Bayer2010-01-281-1/+1
|
* add an informative error msg for non-collection passed to select()Mike Bayer2010-01-281-2/+8
|
* - Added a tuple_() construct, allows sets of expressionsMike Bayer2010-01-251-5/+38
| | | | | | | | | to be compared to another set, typically with IN against composite primary keys or similar. Also accepts an IN with multiple columns. The "scalar select can have only one column" error message is removed - will rely upon the database to report problems with col mismatch.
* - union(), intersect(), except() and other "compound" typesMike Bayer2010-01-251-5/+1
| | | | | | | | | | | | | | | | of statements have more consistent behavior w.r.t. parenthesizing. Each compound element embedded within another will now be grouped with parenthesis - previously, the first compound element in the list would not be grouped, as SQLite doesn't like a statement to start with parenthesis. However, Postgresql in particular has precedence rules regarding INTERSECT, and it is more consistent for parenthesis to be applied equally to all sub-elements. So now, the workaround for SQLite is also what the workaround for PG was previously - when nesting compound elements, the first one usually needs ".alias().select()" called on it to wrap it inside of a subquery. [ticket:1665]
* - Connection has execution_options(), generative methodMike Bayer2010-01-241-5/+7
| | | | | | | | | which accepts keywords that affect how the statement is executed w.r.t. the DBAPI. Currently supports "stream_results", causes psycopg2 to use a server side cursor for that statement. Can also be set upon select() and text() constructs directly as well as ORM Query().
* not ready to put execution_options in the text()/select() constructors yetMike Bayer2010-01-241-9/+3
|
* statement_options -> execution_optionsMike Bayer2010-01-171-30/+32
|
* - added "statement_options()" to Query, to so options can beMike Bayer2010-01-161-22/+43
| | | | | | | | | | | | | | | | | | | | | passed to the resulting statement. Currently only Select-statements have these options, and the only option used is "stream_results", and the only dialect which knows "stream_results" is psycopg2. - Query.yield_per() will set the "stream_results" statement option automatically. - Added "statement_options()" to Selects, which set statement specific options. These enable e.g. dialect specific options such as whether to enable using server side cursors, etc. - The psycopg2 now respects the statement option "stream_results". This option overrides the connection setting "server_side_cursors". If true, server side cursors will be used for the statement. If false, they will not be used, even if "server_side_cursors" is true on the connection. [ticket:1619] - added a "frozendict" from http://code.activestate.com/recipes/414283/, adding more default collections as immutable class vars on Query, Insert, Select
* happy new yearMike Bayer2010-01-071-1/+1
|
* - Fixed a column arithmetic bug that affected columnMike Bayer2010-01-031-1/+2
| | | | | | | | | correspondence for cloned selectables which contain free-standing column expressions. This bug is generally only noticeable when exercising newer ORM behavior only availble in 0.6 via [ticket:1568], but is more correct at the SQL expression level as well. [ticket:1617]
* - clarify ForeignKey docs, copy operationMike Bayer2010-01-021-186/+187
| | | | - link all classes/functions in expressions
* - calling expr.in_([]), i.e. with an empty list, emits a warningMike Bayer2009-12-291-1/+9
| | | | | | | | | before issuing the usual "expr != expr" clause. The "expr != expr" can be very expensive, and it's preferred that the user not issue in_() if the list is empty, instead simply not querying, or modifying the criterion as appropriate for more complex situations. [ticket:1628]
* - Fixed bug preventing alias() of an alias() from beingMike Bayer2009-12-181-1/+1
| | | | | cloned or adapted (occurs frequently in ORM operations). [ticket:1641]
* documentation patch for [ticket:1354]Mike Bayer2009-12-091-2/+8
|
* - removed needless "counter" behavior with select()Mike Bayer2009-12-081-8/+0
| | | | | | | | | | labelnames that match a column name in the table, i.e. generates "tablename_id" for "id", instead of "tablename_id_1" in an attempt to avoid naming conflicts, when the table has a column actually named "tablename_id" - this is because the labeling logic is always applied to all columns so a naming conflict will never occur.
* - multi-part schema names, i.e. with dots such asMike Bayer2009-12-081-1/+1
| | | | | | | "dbo.master", are now rendered in select() labels with underscores for dots, i.e. "dbo_master_table_column". This is a "friendly" label that behaves better in result sets. [ticket:1428]
* - The "use get" behavior of many-to-one relations, i.e. that aMike Bayer2009-12-081-8/+3
| | | | | | | | | | | | | | lazy load will fallback to the possibly cached query.get() value, now works across join conditions where the two compared types are not exactly the same class, but share the same "affinity" - i.e. Integer and SmallInteger. Also allows combinations of reflected and non-reflected types to work with 0.5 style type reflection, such as PGText/Text (note 0.6 reflects types as their generic versions). [ticket:1556] - types now support an "affinity comparison" operation, i.e. that an Integer/SmallInteger are "compatible", or a Text/String, PickleType/Binary, etc. Part of [ticket:1556].
* scan for autocommit based on text() specific flag, saves isinstance() call ↵Mike Bayer2009-11-101-2/+2
| | | | on each execution.
* - subclassed Function off of new FunctionElement generic baseMike Bayer2009-11-101-51/+57
| | | | | | - removed "key" accessor of Function, Grouping - this doesn't seem to be used for anything - various formatting - documented the four "Element" classes in the compiler extension as per [ticket:1590]
* added docs to case() illusrtating usage of `literal_column()`, can't ↵Mike Bayer2009-10-281-1/+11
| | | | implement #809 directly
* - generalized Enum to issue a CHECK constraint + VARCHAR on default platformMike Bayer2009-10-251-3/+3
| | | | - added native_enum=False flag to do the same on MySQL, PG, if desired
* - Added new ENUM type to the Postgresql dialect, which exists as a schema-levelMike Bayer2009-10-251-32/+23
| | | | | | | | | | | | | | | | | | | | | | | | | construct and extends the generic Enum type. Automatically associates itself with tables and their parent metadata to issue the appropriate CREATE TYPE/DROP TYPE commands as needed, supports unicode labels, supports reflection. [ticket:1511] - MySQL ENUM now subclasses the new generic Enum type, and also handles unicode values implicitly, if the given labelnames are unicode objects. - Added a new Enum generic type, currently supported on Postgresql and MySQL. Enum is a schema-aware object to support databases which require specific DDL in order to use enum or equivalent; in the case of PG it handles the details of `CREATE TYPE`, and on other databases without native enum support can support generation of CHECK constraints. [ticket:1109] [ticket:1511] - types documentation updates - some cleanup on schema/expression docs
* deprecations per [ticket:1498]:Mike Bayer2009-10-151-25/+7
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | - deprecated PassiveDefault - use DefaultClause. - the BINARY and MSBinary types now generate "BINARY" in all cases. Omitting the "length" parameter will generate "BINARY" with no length. Use BLOB to generate an unlengthed binary column. - the "quoting='quoted'" argument to MSEnum/ENUM is deprecated. It's best to rely upon the automatic quoting. - "shortname" attribute on bindparam() is removed. - fold_equivalents flag on join is deprecated (will remain until [ticket:1131] is implemented) - "scalar" flag on select() is removed, use select.as_scalar(). - 'transactional' flag on sessionmaker() and others is removed. Use 'autocommit=True' to indicate 'transactional=False'. - 'polymorphic_fetch' argument on mapper() is removed. Loading can be controlled using the 'with_polymorphic' option. - 'select_table' argument on mapper() is removed. Use 'with_polymorphic=("*", <some selectable>)' for this functionality. - 'proxy' argument on synonym() is removed. This flag did nothing throughout 0.5, as the "proxy generation" behavior is now automatic. - Passing a single list of elements to eagerload(), eagerload_all(), contains_eager(), lazyload(), defer(), and undefer() instead of multiple positional -args is deprecated. - Passing a single list of elements to query.order_by(), query.group_by(), query.join(), or query.outerjoin() instead of multiple positional *args is deprecated. - query.iterate_instances() is removed. Use query.instances(). - Query.query_from_parent() is removed. Use the sqlalchemy.orm.with_parent() function to produce a "parent" clause, or alternatively query.with_parent(). - query._from_self() is removed, use query.from_self() instead. - the "comparator" argument to composite() is removed. Use "comparator_factory". - RelationProperty._get_join() is removed. - the 'echo_uow' flag on Session is removed. Use logging on the "sqlalchemy.orm.unitofwork" name. - session.clear() is removed. use session.expunge_all(). - session.save(), session.update(), session.save_or_update() are removed. Use session.add() and session.add_all(). - the "objects" flag on session.flush() remains deprecated. - the "dont_load=True" flag on session.merge() is deprecated in favor of "load=False". - passing an InstanceState (internal SQLAlchemy state object) to attributes.init_collection() or attributes.get_history() is deprecated. These functions are public API and normally expect a regular mapped object instance. - the 'engine' parameter to declarative_base() is removed. Use the 'bind' keyword argument.
* - an executemany() now requires that all bound parameterMike Bayer2009-10-151-6/+13
| | | | | | | | | | | | sets require that all keys are present which are present in the first bound parameter set. The structure and behavior of an insert/update statement is very much determined by the first parameter set, including which defaults are going to fire off, and a minimum of guesswork is performed with all the rest so that performance is not impacted. For this reason defaults would otherwise silently "fail" for missing parameters, so this is now guarded against. [ticket:1566]
* merge from branches/clauseelement-nonzeroPhilip Jenvey2009-09-241-37/+48
| | | | | | adds a __nonzero__ to _BinaryExpression to avoid faulty comparisons during hash collisions (which only occur on Jython) fixes #1547
* doc fixesMike Bayer2009-08-251-18/+18
|
* - added **kw to ClauseElement.compare(), so that we can smarten up the ↵Mike Bayer2009-08-081-12/+44
| | | | | | | | | | | | | "use_get" operation - many-to-one relation to a joined-table subclass now uses get() for a simple load (known as the "use_get" condition), i.e. Related->Sub(Base), without the need to redefine the primaryjoin condition in terms of the base table. [ticket:1186] - specifying a foreign key with a declarative column, i.e. ForeignKey(MyRelatedClass.id) doesn't break the "use_get" condition from taking place [ticket:1492]
* unwrapped _get_colparams a bit, dropped out an isinstance() callMike Bayer2009-08-081-0/+2
|
* merge 0.6 series to trunk.Mike Bayer2009-08-061-207/+468
|
* merged [ticket:1486] fix from 0.6Mike Bayer2009-07-281-3/+12
|
* - Unary expressions such as DISTINCT propagate theirMike Bayer2009-07-251-4/+3
| | | | | type handling to result sets, allowing conversions like unicode and such to take place. [ticket:1420]
* - Fixed a bug in extract() introduced in 0.5.4 wherebyMike Bayer2009-07-171-2/+1
| | | | | | the string "field" argument was getting treated as a ClauseElement, causing various errors within more complex SQL transformations.
* - sqlMike Bayer2009-05-291-1/+1
| | | | | | | | | | | | | | | | - Removed an obscure feature of execute() (including connection, engine, Session) whereby a bindparam() construct can be sent as a key to the params dictionary. This usage is undocumented and is at the core of an issue whereby the bindparam() object created implicitly by a text() construct may have the same hash value as a string placed in the params dictionary and may result in an inappropriate match when computing the final bind parameters. Internal checks for this condition would add significant latency to the critical task of parameter rendering, so the behavior is removed. This is a backwards incompatible change for any application that may have been using this feature, however the feature has never been documented.
* - The "polymorphic discriminator" column may be part of aMike Bayer2009-05-171-1/+1
| | | | | primary key, and it will be populated with the correct discriminator value. [ticket:1300]
* Lots of fixes to the code examples to specify imports explicitly.Michael Trier2009-03-311-4/+8
| | | | | | | Explicit imports make it easier for users to understand the examples. Additionally a lot of the examples were fixed to work with the changes in the 0.5.x code base. One small correction to the Case expression. Thanks a bunch to Adam Lowry! Fixes #717.
* extract() is now dialect-sensitive and supports SQLite and others.Jason Kirtland2009-03-301-2/+22
|
* - Lazy loader will not use get() if the "lazy load"Mike Bayer2009-03-291-1/+1
| | | | | | | | | SQL clause matches the clause used by get(), but contains some parameters hardcoded. Previously the lazy strategy would fail with the get(). Ideally get() would be used with the hardcoded parameters but this would require further development. [ticket:1357]
* - An alias() of a select() will convert to a "scalar subquery"Mike Bayer2009-03-211-2/+22
| | | | | | when used in an unambiguously scalar context, i.e. it's used in a comparison operation. This applies to the ORM when using query.subquery() as well.
* - Fixed a recursive pickling issue in serializer, triggeredMike Bayer2009-02-171-0/+6
| | | | by an EXISTS or other embedded FROM construct.
* - Fixed missing _label attribute on Function object, othersMike Bayer2009-02-011-1/+2
| | | | | when used in a select() with use_labels (such as when used in an ORM column_property()). [ticket:1302]
* some docstring stuffMike Bayer2009-01-281-20/+19
|
* - _CalculatedClause is goneMike Bayer2009-01-281-85/+74
| | | | | | | | - Function rolls the various standalone execution functionality of CC into itself, accesses its internal state more directly - collate just uses _BinaryExpression, don't know why it didn't do this already - added new _Case construct, compiles directly - the world is a happier place