-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Cannot cast using JSON.JSONPathType
#8216
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
Comments
OK if jsonpath is really a type we can cast to that using |
i dont this can be automatic however, we just document it |
not unless we implement a function for |
right we could implement it but then it's like there's this one JSON function that's randomly implemented and the rest aren't, which is just not easy to explain |
Do you want to keep in inside the JSON class or should it have its own type outside of it (I'm guessing called JSONPATH) |
I think we can make an alias for it JsonPath and it should be a genric type, that is, wont fail if used on other backends |
within PG dialect, sure we can add JSONPATH directly as well, that will be the type map for JsonPath |
ah ok, JsonPath is generic, I though it was in pg only. I'll take a look |
Federico Caselli has proposed a fix for this issue in the main branch: JSONPathType can be used in casts in PostgreSQL https://gerrit.sqlalchemy.org/c/sqlalchemy/sqlalchemy/+/4019 |
I'm not sure what to render in the other backends. At the moment in the patch it fails with unsupported compilation |
Hello gentlemen, Any chance this would have been backported to 1.4.x? Or do you advise I upgarde to 2.0? Thanks, |
Well, I went and used |
In some dialects that use server side binding, like psycopg and asyncpg, queries that use
jsonb_path_query_array
and similar function that take jsonpath arguments fail without cast, and casting usingJSON.JSONPathType
errors withAttributeError: 'JSONPathType' object has no attribute '_compiler_dispatch'
Example:
casting instead to jsonpath with a literal columns works:
The text was updated successfully, but these errors were encountered: