summaryrefslogtreecommitdiff
path: root/lib/sqlalchemy/ext/hybrid.py
diff options
context:
space:
mode:
authorAlbert Tugushev <albert@tugushev.ru>2020-02-26 11:09:29 -0500
committersqla-tester <sqla-tester@sqlalchemy.org>2020-02-26 11:09:29 -0500
commita836e3df5d973f75bd8330cecb76511b67c13612 (patch)
tree6c2e6de399ad90f49112bb5fecc02ae99c651a63 /lib/sqlalchemy/ext/hybrid.py
parente15c53716b9f59c7c666c77d1e8b8d82538036a3 (diff)
downloadsqlalchemy-a836e3df5d973f75bd8330cecb76511b67c13612.tar.gz
Remove print statement in favor of print() function in docs and examples
<!-- Provide a general summary of your proposed changes in the Title field above --> ### Description <!-- Describe your changes in detail --> Remove print statements ### Checklist <!-- go over following points. check them with an `x` if they do apply, (they turn into clickable checkboxes once the PR is submitted, so no need to do everything at once) --> This pull request is: - [X] A documentation / typographical error fix - Good to go, no issue or tests are needed - [ ] A short code fix - please include the issue number, and create an issue if none exists, which must include a complete example of the issue. one line code fixes without an issue and demonstration will not be accepted. - Please include: `Fixes: #<issue number>` in the commit message - please include tests. one line code fixes without tests will not be accepted. - [ ] A new feature implementation - please include the issue number, and create an issue if none exists, which must include a complete example of how the feature would look. - Please include: `Fixes: #<issue number>` in the commit message - please include tests. **Have a nice day!** Closes: #5166 Pull-request: https://github.com/sqlalchemy/sqlalchemy/pull/5166 Pull-request-sha: 04a7394f71298322188f0861b4dfe93e5485839d Change-Id: Ib90a59fac929661a18748c6e44966fb87e3978c6
Diffstat (limited to 'lib/sqlalchemy/ext/hybrid.py')
-rw-r--r--lib/sqlalchemy/ext/hybrid.py28
1 files changed, 14 insertions, 14 deletions
diff --git a/lib/sqlalchemy/ext/hybrid.py b/lib/sqlalchemy/ext/hybrid.py
index fd06034ee..7c523edbd 100644
--- a/lib/sqlalchemy/ext/hybrid.py
+++ b/lib/sqlalchemy/ext/hybrid.py
@@ -66,10 +66,10 @@ descriptor evaluates the function body given the ``Interval`` class as
the argument, which when evaluated with SQLAlchemy expression mechanics
returns a new SQL expression::
- >>> print Interval.length
+ >>> print(Interval.length)
interval."end" - interval.start
- >>> print Session().query(Interval).filter(Interval.length > 10)
+ >>> print(Session().query(Interval).filter(Interval.length > 10))
SELECT interval.id AS interval_id, interval.start AS interval_start,
interval."end" AS interval_end
FROM interval
@@ -78,7 +78,7 @@ returns a new SQL expression::
ORM methods such as :meth:`~.Query.filter_by` generally use ``getattr()`` to
locate attributes, so can also be used with hybrid attributes::
- >>> print Session().query(Interval).filter_by(length=5)
+ >>> print(Session().query(Interval).filter_by(length=5))
SELECT interval.id AS interval_id, interval.start AS interval_start,
interval."end" AS interval_end
FROM interval
@@ -101,14 +101,14 @@ SQL expression-level boolean behavior::
>>> i1.intersects(Interval(25, 29))
False
- >>> print Session().query(Interval).filter(Interval.contains(15))
+ >>> print(Session().query(Interval).filter(Interval.contains(15)))
SELECT interval.id AS interval_id, interval.start AS interval_start,
interval."end" AS interval_end
FROM interval
WHERE interval.start <= :start_1 AND interval."end" > :end_1
>>> ia = aliased(Interval)
- >>> print Session().query(Interval, ia).filter(Interval.intersects(ia))
+ >>> print(Session().query(Interval, ia).filter(Interval.intersects(ia)))
SELECT interval.id AS interval_id, interval.start AS interval_start,
interval."end" AS interval_end, interval_1.id AS interval_1_id,
interval_1.start AS interval_1_start, interval_1."end" AS interval_1_end
@@ -153,7 +153,7 @@ object for class-level expressions::
>>> i1.radius
2
- >>> print Session().query(Interval).filter(Interval.radius > 5)
+ >>> print(Session().query(Interval).filter(Interval.radius > 5))
SELECT interval.id AS interval_id, interval.start AS interval_start,
interval."end" AS interval_end
FROM interval
@@ -325,8 +325,8 @@ However, at the expression level, it's expected that the ``User`` class will
be used in an appropriate context such that an appropriate join to
``SavingsAccount`` will be present::
- >>> print Session().query(User, User.balance).\
- ... join(User.accounts).filter(User.balance > 5000)
+ >>> print(Session().query(User, User.balance).
+ ... join(User.accounts).filter(User.balance > 5000))
SELECT "user".id AS user_id, "user".name AS user_name,
account.balance AS account_balance
FROM "user" JOIN account ON "user".id = account.user_id
@@ -390,7 +390,7 @@ we can adjust our ``SavingsAccount`` example to aggregate the balances for
The above recipe will give us the ``balance`` column which renders
a correlated SELECT::
- >>> print s.query(User).filter(User.balance > 400)
+ >>> print(s.query(User).filter(User.balance > 400))
SELECT "user".id AS user_id, "user".name AS user_name
FROM "user"
WHERE (SELECT sum(account.balance) AS sum_1
@@ -443,7 +443,7 @@ named ``word_insensitive``::
Above, SQL expressions against ``word_insensitive`` will apply the ``LOWER()``
SQL function to both sides::
- >>> print Session().query(SearchWord).filter_by(word_insensitive="Trucks")
+ >>> print(Session().query(SearchWord).filter_by(word_insensitive="Trucks"))
SELECT searchword.id AS searchword_id, searchword.word AS searchword_word
FROM searchword
WHERE lower(searchword.word) = lower(:lower_1)
@@ -579,7 +579,7 @@ The ``word_insensitive`` attribute now has case-insensitive comparison behavior
universally, including SQL expression vs. Python expression (note the Python
value is converted to lower case on the Python side here)::
- >>> print Session().query(SearchWord).filter_by(word_insensitive="Trucks")
+ >>> print(Session().query(SearchWord).filter_by(word_insensitive="Trucks"))
SELECT searchword.id AS searchword_id, searchword.word AS searchword_word
FROM searchword
WHERE lower(searchword.word) = :lower_1
@@ -588,12 +588,12 @@ SQL expression versus SQL expression::
>>> sw1 = aliased(SearchWord)
>>> sw2 = aliased(SearchWord)
- >>> print Session().query(
+ >>> print(Session().query(
... sw1.word_insensitive,
... sw2.word_insensitive).\
... filter(
... sw1.word_insensitive > sw2.word_insensitive
- ... )
+ ... ))
SELECT lower(searchword_1.word) AS lower_1,
lower(searchword_2.word) AS lower_2
FROM searchword AS searchword_1, searchword AS searchword_2
@@ -606,7 +606,7 @@ Python only expression::
True
>>> ws1.word_insensitive == "XOmEwOrX"
False
- >>> print ws1.word_insensitive
+ >>> print(ws1.word_insensitive)
someword
The Hybrid Value pattern is very useful for any kind of value that may have