Commit Graph

27 Commits

Author SHA1 Message Date
Mike Bayer 036cb93abf - Fixed bug where :meth:.in_() would go into an endless loop if
erroneously passed a column expression whose comparator included
the ``__getitem__()`` method, such as a column that uses the
:class:`.postgresql.ARRAY` type. [ticket:2957]
2014-02-13 15:19:12 -05:00
Mike Bayer 6b3ecd14ea - Added a new parameter :paramref:.Operators.op.is_comparison. This
flag allows a custom op from :meth:`.Operators.op` to be considered
as a "comparison" operator, thus usable for custom
:paramref:`.relationship.primaryjoin` conditions.
2014-01-31 19:14:08 -05:00
Mike Bayer b653fb3a23 - The precedence rules for the :meth:.ColumnOperators.collate operator
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]
2013-12-05 19:03:31 -05:00
Mike Bayer f035b6e0a4 An overhaul of expression handling for special symbols particularly
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]
2013-10-23 17:44:52 -04:00
Mike Bayer 08a6a8b519 - Removed some now unneeded version checks [ticket:2829] courtesy alex gaynor 2013-09-22 20:35:40 -04:00
Mike Bayer 34ef21909b - The :meth:.Operators.notin_ operator added in 0.8 now properly
produces the negation of the expression "IN" returns
when used against an empty collection.  Also in 0.8.3.
2013-08-07 13:28:45 -05:00
Mike Bayer d993bdeac8 - remove the `__iter__()` with notimplemented since it interferes
with legitimate iterable detection, [ticket:2726]
2013-06-03 16:32:12 -04:00
Mike Bayer 5884c2e7e5 Fully implemented the IS and IS NOT operators with
regards to the True/False constants.  An expression like
``col.is_(True)`` will now render ``col IS true``
on the target platform, rather than converting the True/
False constant to an integer bound parameter.
This allows the ``is_()`` operator to work on MySQL when
given True/False constants.
[ticket:2682]
2013-04-22 19:12:47 -04:00
Mike Bayer cb19f227f3 The :meth:.ColumnOperators.in_ operator will now coerce
values of ``None`` to :func:`.null`.
[ticket:2496]
2013-02-02 16:17:58 -05:00
Mike Bayer 4950b85e83 - BinaryExpression now keeps track of "left" and "right" as passed in,
so that they can be compared in ``__nonzero__`` prior to their
self_group() step.  [ticket:2621]
2012-12-02 12:37:52 -05:00
Mike Bayer 1e29a74bd6 Fixed a gotcha where inadvertently calling list() on a
:class:`.ColumnElement` would go into an endless loop, if
      :meth:`.ColumnOperators.__getitem__` were implemented.
      A new NotImplementedError is emitted via ``__iter__()``.
2012-11-18 10:38:02 -05:00
Mike Bayer d0651ef4b3 Added :meth:.ColumnOperators.notin_,
:meth:`.ColumnOperators.notlike`,
:meth:`.ColumnOperators.notilike` to :class:`.ColumnOperators`.
[ticket:2580]
2012-10-24 16:01:17 -04:00
Mike Bayer e656bf4f47 - move most/all operator specific tests into test_operator, convert fully to TOT 2012-10-24 14:29:52 -04:00
Mike Bayer c859893cb8 - get 100% lint/pep8 happening for test_compiler; next we will begin
cutting up tests and removing old ones
- move test_in() to test_operators
- slice up migrated operator tests into TOT
2012-10-24 14:02:37 -04:00
Mike Bayer 20cdc64588 trying different approaches to test layout. in this one, the testing modules
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.
2012-09-27 02:37:33 -04:00
Mike Bayer 23d300c874 - [bug] A tweak to column precedence which moves the
"concat" and "match" operators to be the same as
    that of "is", "like", and others; this helps with
    parenthesization rendering when used in conjunction
    with "IS". [ticket:2564]
2012-09-22 16:48:49 -04:00
Mike Bayer 6c50ffcf44 - aaand actually get is/isnot to be usable with None/NULL 2012-09-22 16:45:02 -04:00
Mike Bayer 1ceda8c23c - [bug] Added missing operators is_(), isnot()
to the ColumnOperators base, so that these long-available
    operators are present as methods like all
    the other operators.  [ticket:2544]
2012-09-22 16:14:58 -04:00
Mike Bayer 78937f6aad add a contains() override test 2012-09-04 11:30:31 -04:00
Mike Bayer bc9ff8fcc9 lshift (<<) and rshift (>>) are also supported as optional operators. 2012-09-04 10:44:37 -04:00
Mike Bayer 7d6c1c4a95 - [feature] Reworked the startswith(), endswith(),
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]
2012-08-27 19:40:12 -04:00
Mike Bayer aef0c7a903 - [feature] The Core oeprator system now includes
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].
2012-08-20 17:04:25 -04:00
Mike Bayer f327eaea47 _adapt_expression() moves fully to _DefaultColumnComparator which resumes
its original role as stateful, forms the basis of TypeEngine.Comparator.  lots
of code goes back mostly as it was just with cleaner typing behavior, such
as simple flow in _binary_operate now.
2012-08-16 16:11:42 -04:00
Mike Bayer 079f5a282b -we move all the invocation of "_adapt_expression" into TypeEngine.Comparator. at this point
the split of operator stuff is getting awkward and we might want to move _DefaultComparator.
2012-08-16 14:07:33 -04:00
Mike Bayer 05864ab8a6 - fix concat() operator, tests
- [feature] Custom unary operators can now be
  used by combining operators.custom_op() with
  UnaryExpression().
- clean up the operator dispatch system and make it more consistent.
This does change the compiler contract for custom ops.
2012-08-14 13:47:58 -04:00
Mike Bayer 37fad88b84 move the whole thing to TypeEngine. the feature is pretty much for free like this. 2012-08-13 16:18:12 -04:00
Mike Bayer d9b5991f9c - develop new system of applying custom operators to ColumnElement classes. resembles
that of the ORM so far.
2012-08-13 14:37:58 -04:00