diff options
| author | mike bayer <mike_mp@zzzcomputing.com> | 2020-02-28 00:27:27 +0000 |
|---|---|---|
| committer | Gerrit Code Review <gerrit@bbpush.zzzcomputing.com> | 2020-02-28 00:27:27 +0000 |
| commit | 132006ba8a714199d4f761b0e66fc2e516e46ba3 (patch) | |
| tree | d66e54051a92d4842db8dff989ec1d4143f7a586 /lib/sqlalchemy/ext | |
| parent | f78db5e1f68d6b2fb6a7acc04036f682d9a22974 (diff) | |
| parent | a836e3df5d973f75bd8330cecb76511b67c13612 (diff) | |
| download | sqlalchemy-132006ba8a714199d4f761b0e66fc2e516e46ba3.tar.gz | |
Merge "Remove print statement in favor of print() function in docs and examples"
Diffstat (limited to 'lib/sqlalchemy/ext')
| -rw-r--r-- | lib/sqlalchemy/ext/compiler.py | 4 | ||||
| -rw-r--r-- | lib/sqlalchemy/ext/hybrid.py | 28 |
2 files changed, 16 insertions, 16 deletions
diff --git a/lib/sqlalchemy/ext/compiler.py b/lib/sqlalchemy/ext/compiler.py index 59c16f803..c27907cdc 100644 --- a/lib/sqlalchemy/ext/compiler.py +++ b/lib/sqlalchemy/ext/compiler.py @@ -32,7 +32,7 @@ when the object is compiled to a string:: from sqlalchemy import select s = select([MyColumn('x'), MyColumn('y')]) - print str(s) + print(str(s)) Produces:: @@ -90,7 +90,7 @@ method which can be used for compilation of embedded attributes:: ) insert = InsertFromSelect(t1, select([t1]).where(t1.c.x>5)) - print insert + print(insert) Produces:: 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 |
