-
-
Notifications
You must be signed in to change notification settings - Fork 64
fix: pass params as query params for get/head requests #593
fix: pass params as query params for get/head requests #593
Conversation
Pull Request Test Coverage Report for Build 14993454641Details
💛 - Coveralls |
Hi @abhishekg999 thank you for this fix. Can you also add a test for asserting the behavior? Thanks. |
@grdsdev TY, also noticed BaseRPCRequestBuilder also doesnt merge the prefer header. I made an update to that to match the behavior in postgrest-js. |
postgrest/base_request_builder.py
Outdated
@@ -660,7 +660,11 @@ def select( | |||
""" | |||
method, params, headers, json = pre_select(*columns, count=None) | |||
self.params = self.params.add("select", params.get("select")) | |||
self.headers["Prefer"] = "return=representation" | |||
if self.headers.get("prefer"): |
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.
Is headers in python case-insensitive? This line is checking for prefer
, and the line below for Prefer
.
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.
Actually it should both normalize to lowercase,I just did that to match the get("select") in the line above, but I like keeping it uppercase
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.
It is case-insensitive*
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.
LGTM! Thanks for the contribution @abhishekg999
What kind of change does this PR introduce?
Allows using GET and HEAD methods on Postgrest RPC functions with arguments.
What is the current behavior?
RPC functions always try to send params in the body. This will fail for GET and HEAD methods.
Please link any relevant issues here.
#592
What is the new behavior?
You can now properly use get=True / head=True in postgrest RPC func calls.