postgrest-py
postgrest-py copied to clipboard
Can't cast columns
In the PostgRest documentation, it says to cast a column in query do something like...
GET /people?select=full_name,salary::text HTTP/1.1
It seems like this isn't a possibility in this wrapper, unless I am missing something.
Can you provide an example of when this happens and the outpur you get and what you expected to get, please? 🙂
Through the Python supabase client (which I believe leverages this package), I would do something like...
client.table("my_table").select("*").eq("col1::date", "2021-12-31")
I would expect this to cast column "col1" from its current dtype to a date type and then check the equality condition. The error message I get reflects that it looks for column "my_table"."col1::date" instead of "my_table"."col1"::date if that makes sense.
Right, I get what you mean. Although I think you might be missunderstanding a bit how the client works.
For instance, postgrest-py, as client doesn't get all the records and then filters the data in python, but it actually requests the data filtered to the postgres db, therefore if the column is of type date, your example would work with no casting. I would understand the example if your column was of type text and you wanted to filter it as a date.
I also see this postgREST feature would work really well if you wanted to get a column of a type into a certain JSON compatible type. For instance, I have an int column I want to use in my app as text, therefore I could request the certain column casted as text instead of converting this column to text in all records.
What do you think? Thanks!
This issue is over 2 years old with no replies. Closing this out.