-
Notifications
You must be signed in to change notification settings - Fork 15
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: port to SQLAlchemy 1.4 / 2.0 #28
Conversation
Codecov Report
@@ Coverage Diff @@
## master #28 +/- ##
=========================================
Coverage 100.00% 100.00%
=========================================
Files 2 2
Lines 128 148 +20
Branches 1 2 +1
=========================================
+ Hits 128 148 +20
Flags with carried forward coverage won't be shown. Click here to find out more.
Continue to review full report at Codecov.
|
60282d8
to
b4011e1
Compare
If you have bandwidth @vicrep 🙏🏽 ? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you elaborate on why we need to make the query_counter
a dependency? Could we not make it a pure function which takes as arguments the query, which could be either a legacy or non-legacy query?
IMO requiring you make a dependency that returns a callable as a counter function feels a little indirected from a consumer's PoV / is not a very straightforward interface.
Could we make the pagination dependency smart enough to then determine if the query is a session.query
or a DbQuery
, and only call session.execute()
on the latter?
Honestly, as I think about it more, could it be worth having two separate dependencies, one to paginate classic SQLA queries, and one to paginate when passed a 1.4 DbQuery
? That way no breaking changes, and I think there's enough overlap that most of the code would be reused between both, but that way we're super explicit.
Dependency is nice to do this: def query_count_dep(q: str = Query(...), session:Session=Depends())-> QueryCount:
def query_count(query:DbQuery)->int:
query = select(func.count()).where(User.name.like(q)
return session.execute(query).scalar()
I agree.
yes, it is actually what that PR achieves. Out of the box, it just works with legacy and modern queries.
I will keep the same That PR breaks the scoping rule. It does 2 things: porting to SQL 2.0 queries. Introducing a query count dependency. I'll lean and remove the breaking change. |
Oh I totally agree that the dependency a nice "advanced" usage option; I just would offer a simpler interface for people who want something a little more straightforward :) Sounds good about scoping, I think we can probably find a sleek way to allow users to do both (simple/pure counter, and advanced dependency based counter). |
Something similar to how the python JSON module lets you override encoders could be nice -- when calling |
a915063
to
4ad6882
Compare
not anymore a breaking change FYI @vicrep |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🚢 🎉
Description
Related PRs
Blocked by