Commit Graph

57 Commits

Author SHA1 Message Date
Tim Graham a755e0657e Removed unused BaseExpression.refs_aggregate().
Unused since afe0bb7b13.
2016-04-22 13:04:13 -04:00
Marc Tamlyn 2d877da855 Refs #3254 -- Added full text search to contrib.postgres.
Adds a reasonably feature complete implementation of full text search
using the built in PostgreSQL engine. It uses public APIs from
Expression and Lookup.

With thanks to Tim Graham, Simon Charettes, Josh Smeaton, Mikey Ariel
and many others for their advice and review. Particular thanks also go
to the supporters of the contrib.postgres kickstarter.
2016-04-22 10:44:37 +01:00
Tim Graham 2cd2d18851 Fixed W503 flake8 warnings. 2016-04-04 17:14:26 -04:00
Kai Feldhoff 5336158990 Fixed #25759 -- Added keyword arguments to customize Expressions' as_sql(). 2016-03-29 08:09:58 -04:00
Tim Graham fb84e877ce Normalized Func.as_sqlite() signature. 2016-03-28 10:59:12 -04:00
Simon Charette 766afc22a1 Fixed #24793 -- Unified temporal difference support. 2016-02-26 12:25:12 -05:00
Anssi Kääriäinen 46ecfb9b3a Fixed #26196 -- Made sure __in lookups use to_field as default.
Thanks Simon Charette for the test.
2016-02-11 11:09:08 -05:00
varunnaganathan 3eba9638ee Fixed #25316 -- Fixed a crash with order_by() and values() after annotate(). 2016-01-02 07:06:54 -05:00
Josh Soref 93452a70e8 Fixed many spelling mistakes in code, comments, and docs. 2015-12-03 12:48:24 -05:00
Dmitry Dygalo 917100eed7 Simplified dict initialization in two places. 2015-11-07 21:46:46 +01:00
Sergey Fedoseev 0a26121797 Refs #25629 -- Added `arity` class attribute to `Func` expressions 2015-11-02 20:09:21 +01:00
Alex Hill 134ca4d438 Fixed #24509 -- Added Expression support to SQLInsertCompiler 2015-09-22 23:35:24 +10:00
Adam Chainz 3fe3887a2e Fixed #25377 -- Changed Count queries to execute COUNT(*) instead of COUNT('*'). 2015-09-14 13:41:35 -04:00
Michael Tänzer 3bbaf84d65 Fixed #18247 -- Added cast to NUMERIC for Decimals on sqlite
On sqlite the SUM() of a decimal column doesn't have a NUMERIC type so
when comparing it to a string literal (which a Decimal gets converted to
in Django) it is not compared as expected.
2015-06-30 18:27:42 -04:00
Anssi Kääriäinen 7b05d2fdae Fixed #24752 -- query crash when reusing Case expressions
Case expressions weren't copied deep enough (self.cases list was
reused resulting in an error).
2015-05-05 11:38:12 -04:00
Josh Smeaton 02a2943e4c Fixed #24485 -- Allowed combined expressions to set output_field 2015-03-22 17:36:55 +11:00
Josh Smeaton 127b3873d0 Fixed #24508 -- Made annotations commutative 2015-03-22 17:28:42 +11:00
Josh Smeaton 88d798d71a Refs #24485 -- Renamed some expression types 2015-03-17 08:40:18 -04:00
Josh Smeaton ff2aa40192 Fixed #24486 -- Fixed error with datetime and DurationField arithmetic 2015-03-17 08:35:49 -04:00
Josh Smeaton ceaf31adff Fixed #24420 -- Allowed ordering by case expressions 2015-03-06 13:30:02 +11:00
Marc Tamlyn 32d4db66b9 Update converters to take a consistent set of parameters.
As suggested by Anssi. This has the slightly strange side effect of
passing the expression to Expression.convert_value has the expression
passed back to it, but it allows more complex patterns of expressions.
2015-02-20 11:35:52 +00:00
Marc Tamlyn 4755f8fc25 Fixed #24343 -- Ensure db converters are used for foreign keys.
Joint effort between myself, Josh, Anssi and Shai.
2015-02-20 11:35:51 +00:00
Josh Smeaton e2d6e14662 Refs #14030 -- Improved expression support for python values 2015-02-12 08:46:25 +11:00
Tim Graham 0ed7d15563 Sorted imports with isort; refs #23860. 2015-02-06 08:16:28 -05:00
Josh Smeaton 14d0bd67d4 Refs #14030 -- Renamed CombinableMixin to Combinable
Removed unused method and updated docstrings.
2015-01-28 10:59:30 +11:00
Josh Smeaton 7171bf755b Refs #14030 -- Added repr methods to all expressions 2015-01-28 10:59:30 +11:00
Josh Smeaton 8196e4bdf4 Fixed #24154 -- Backends can now check support for expressions 2015-01-27 12:20:06 +11:00
Michał Modzelewski 65246de7b1 Fixed #24031 -- Added CASE expressions to the ORM. 2015-01-12 18:15:34 -05:00
Josh Smeaton 21b858cb67 Fixed #24060 -- Added OrderBy Expressions 2015-01-13 09:39:55 +11:00
Anssi Kääriäinen 0c7633178f Fixed #24020 -- Refactored SQL compiler to use expressions
Refactored compiler SELECT, GROUP BY and ORDER BY generation.
While there, also refactored select_related() implementation
(get_cached_row() and get_klass_info() are now gone!).

Made get_db_converters() method work on expressions instead of
internal_type. This allows the backend converters to target
specific expressions if need be.

Added query.context, this can be used to set per-query state.

Also changed the signature of database converters. They now accept
context as an argument.
2015-01-08 14:07:54 -05:00
Josh Smeaton 8713ea7568 Fixed null handling in Value expression 2015-01-07 19:07:49 -05:00
Marc Tamlyn 5ca82e710e Fixed #24033 -- Use interval type on Oracle.
Use INTERVAL DAY(9) TO SECOND(6) for Durationfield on Oracle rather than
storing as a NUMBER(19) of microseconds.

There are issues with cx_Oracle which require some extra data
manipulation in the database backend when constructing queries, but it
handles the conversion back to timedelta objects cleanly.

Thanks to Shai for the review.
2014-12-23 10:38:32 +00:00
Marc Tamlyn 57554442fe Fixed #2443 -- Added DurationField.
A field for storing periods of time - modeled in Python by timedelta. It
is stored in the native interval data type on PostgreSQL and as a bigint
of microseconds on other backends.

Also includes significant changes to the internals of time related maths
in expressions, including the removal of DateModifierNode.

Thanks to Tim and Josh in particular for reviews.
2014-12-20 18:28:29 +00:00
Anssi Kääriäinen 4a2a433e7d Refs #24020 -- return expressions from get_group_by_cols() 2014-12-18 06:01:07 -07:00
Josh Smeaton 267a1dcd9b Fixed #23941 -- Removed implicit decimal formatting from expressions. 2014-12-12 10:17:48 -05:00
Anssi Kääriäinen cbb5cdd155 Fixed #23867 -- removed DateQuerySet hacks
The .dates() queries were implemented by using custom Query, QuerySet,
and Compiler classes. Instead implement them by using expressions and
database converters APIs.
2014-11-26 17:49:25 -05:00
Collin Anderson d4ea4eea79 Fixed #23889 -- Added more usage of quote_name_unless_alias() to avoid deprecation warnings. 2014-11-21 16:44:50 -05:00
Josh Smeaton f61256da3a Renamed qn to compiler 2014-11-16 13:19:34 +01:00
Josh Smeaton f59fd15c49 Fixed #14030 -- Allowed annotations to accept all expressions 2014-11-15 14:00:43 +00:00
Baptiste Mispelon d63ac5b595 Fixed #23492 -- Restored F.__deepcopy__.
This reverts commit 3a66035107.
A regression test was also added.
2014-09-16 12:19:00 +02:00
Aymeric Augustin 428c0bbe1b Appeased flake8 2.1.0. 2014-04-21 12:27:34 +02:00
Florian Hahn 5240b83462 Fixed #17027 -- Added support for the power operator in F expressions.
Thanks dan at dlo.me for the initial patch.

- Added __pow__ and __rpow__ to ExpressionNode
- Added oracle and mysql specific power expressions
- Added used-defined power function for sqlite
2013-10-22 10:29:57 -04:00
Anssi Kääriäinen 3a66035107 Removed F.__deepcopy__()
The method didn't change standard __deepcopy__ in any way.
2013-10-17 17:45:56 +03:00
Alex Gaynor 03d9566e0d A large number of stylistic cleanups across django/db/ 2013-07-08 10:39:54 +10:00
Anssi Kääriäinen d3f00bd570 Refactored qs.add_q() and utils/tree.py
The sql/query.py add_q method did a lot of where/having tree hacking to
get complex queries to work correctly. The logic was refactored so that
it should be simpler to understand. The new logic should also produce
leaner WHERE conditions.

The changes cascade somewhat, as some other parts of Django (like
add_filter() and WhereNode) expect boolean trees in certain format or
they fail to work. So to fix the add_q() one must fix utils/tree.py,
some things in add_filter(), WhereNode and so on.

This commit also fixed add_filter to see negate clauses up the path.
A query like .exclude(Q(reversefk__in=a_list)) didn't work similarly to
.filter(~Q(reversefk__in=a_list)). The reason for this is that only
the immediate parent negate clauses were seen by add_filter, and thus a
tree like AND: (NOT AND: (AND: condition)) will not be handled
correctly, as there is one intermediary AND node in the tree. The
example tree is generated by .exclude(~Q(reversefk__in=a_list)).

Still, aggregation lost connectors in OR cases, and F() objects and
aggregates in same filter clause caused GROUP BY problems on some
databases.

Fixed #17600, fixed #13198, fixed #17025, fixed #17000, fixed #11293.
2013-03-13 10:44:49 +02:00
Aymeric Augustin fc10418fba Fixed #18963 -- Used a subclass-friendly pattern
for Python 2 object model compatibility methods.
2012-11-03 22:07:35 +01:00
Anssi Kääriäinen b625e8272b Moved F() '&' and '|' to .bitand() and .bitor()
Done for consistency with Q() expressions and QuerySet combining. This
will allow usage of '&' and '|' as boolean logical operators in the
future. Refs #16211.
2012-10-10 01:15:29 +03:00
Anssi Kääriäinen a8b1861fc4 Revert "Fixed #16211 -- Added comparison and negation ops to F() expressions"
This reverts commit 28abf5f0eb.

Conflicts:

	docs/releases/1.5.txt
2012-10-10 01:15:29 +03:00
Anssi Kääriäinen 28abf5f0eb Fixed #16211 -- Added comparison and negation ops to F() expressions
Work done by Walter Doekes and Trac alias knoeb. Reviewed by Simon
Charette.
2012-09-30 17:51:06 +03:00
Claude Paroz de2cb5fede [py3] Fixed F-expression right-hand division
Complementary to commit 62a9ed0ac.
2012-08-15 13:28:47 +02:00