Skip to content
This repository has been archived by the owner on May 13, 2019. It is now read-only.

Add BETWEEN SQL operator #50

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

marcoceppi
Copy link
Contributor

@marcoceppi marcoceppi commented Jul 10, 2018

This is a pretty clumsy stab at Between, which I'd like to use over the excessive >= / <= queries. I also took the liberty to patch a minor annoyance of the In operator not being available on orm.schema.column.Column

I'm open to feedback, I couldn't really find another good example for generating a sql statement based on two explicit values without adding 3x the lines of code.

Finally, I opt'd for NotBetween instead of the existing NBetween - between is already long, adding two more characters didn't seem like much of an advantage. I did use the nbetween on the column - like I said, this is just a clumsy fumble through a patch.

TODO:

  • Tests.

@codecov
Copy link

codecov bot commented Jul 10, 2018

Codecov Report

Merging #50 into master will decrease coverage by 0.15%.
The diff coverage is 96.66%.

Impacted file tree graph

@@            Coverage Diff            @@
##           master     #50      +/-   ##
=========================================
- Coverage   73.56%   73.4%   -0.16%     
=========================================
  Files          26      25       -1     
  Lines        3038    3016      -22     
  Branches      421     425       +4     
=========================================
- Hits         2235    2214      -21     
- Misses        662     663       +1     
+ Partials      141     139       -2
Impacted Files Coverage Δ
asyncqlio/orm/operators.py 60.75% <100%> (+5.81%) ⬆️
asyncqlio/orm/schema/column.py 74.26% <83.33%> (-0.13%) ⬇️
asyncqlio/orm/schema/types.py 67.16% <0%> (-2.99%) ⬇️
asyncqlio/backends/postgresql/__init__.py 78.88% <0%> (-0.46%) ⬇️
asyncqlio/backends/sqlite3/__init__.py 77.55% <0%> (-0.45%) ⬇️
asyncqlio/backends/mysql/__init__.py 79.56% <0%> (-0.44%) ⬇️
asyncqlio/backends/mysql/aiomysql.py 84.88% <0%> (-0.35%) ⬇️
asyncqlio/orm/ddl/ddlsession.py 87.94% <0%> (-0.17%) ⬇️
asyncqlio/backends/postgresql/asyncpg.py 85.21% <0%> (-0.13%) ⬇️
asyncqlio/orm/query.py 75.41% <0%> (-0.02%) ⬇️
... and 10 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 9bdb490...ccc4042. Read the comment docs.

@marcoceppi marcoceppi force-pushed the feature/between branch 5 times, most recently from a606f2b to 65c3609 Compare July 10, 2018 15:19
@Fuyukai
Copy link
Owner

Fuyukai commented Jul 10, 2018

I'm definitely sure you could merge the logic of both classes into one - have a BetweenBase or similar, which uses a class attribute to define if it's BETWEEN or NOT BETWEEN, and inject the right version in during generate_sql of the parent class.

@marcoceppi
Copy link
Contributor Author

I very well almost did that. I'll update the PR

@marcoceppi
Copy link
Contributor Author

I've updated the PR using a BetweenBase and two shallow Between and NotBetween classes

* Creates `BetweenBase` orm.operators
* Creates `Between` and `NotBetween` orm.operators
* Adds `isin` operators to schema.column
* Adds `nbetween` operator to schema.column
* Adds `between` operator to schema.column
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants