You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
add full control for return type under PG ARRAY, HSTORE, JSON, JSONB indexed (element) access #3503
Migrated issue, originally created by Michael Bayer (@zzzeek)
e.g., if I want myhstorecol['somecol'] to have a custom type, how do I do that? Some system that works for all of these types that defines the return types for indexed access should be devised.
1.1 because this is like a big deal, it's going to come up a lot, but no concrete plan right now.
The Postgresql :class:.postgresql.ARRAY type now supports multidimensional
indexed access, e.g. expressions such as somecol[5][6] without
any need for explicit casts or type coercions, provided
that the :paramref:.postgresql.ARRAY.dimensions parameter is set to the
desired number of dimensions. fixes support direct mult-dimensional ARRAY access based on explicit dimensions #3487
The return type for the :class:.postgresql.JSON and :class:.postgresql.JSONB
when using indexed access has been fixed to work like Postgresql itself,
and returns an expression that itself is of type :class:.postgresql.JSON
or :class:.postgresql.JSONB. Previously, the accessor would return
:class:.NullType which disallowed subsequent JSON-like operators to be
used. part of fixes add full control for return type under PG ARRAY, HSTORE, JSON, JSONB indexed (element) access #3503
The :class:.postgresql.JSON, :class:.postgresql.JSONB and
:class:.postgresql.HSTORE datatypes now allow full control over the
return type from an indexed textual access operation, either column[someindex].astext
for a JSON type or column[someindex] for an HSTORE type,
via the :paramref:.postgresql.JSON.astext_type and
:paramref:.postgresql.HSTORE.text_type parameters. also part of fixes add full control for return type under PG ARRAY, HSTORE, JSON, JSONB indexed (element) access #3503
The :attr:.postgresql.JSON.Comparator.astext modifier no longer
calls upon :meth:.ColumnElement.cast implicitly, as PG's JSON/JSONB
types allow cross-casting between each other as well. Code that
makes use of :meth:.ColumnElement.cast on JSON indexed access,
e.g. col[someindex].cast(Integer), will need to be changed
to call :attr:.postgresql.JSON.Comparator.astext explicitly. This is
part of the refactor in references add full control for return type under PG ARRAY, HSTORE, JSON, JSONB indexed (element) access #3503 for consistency in operator
use.
The Postgresql :class:.postgresql.ARRAY type now supports multidimensional
indexed access, e.g. expressions such as somecol[5][6] without
any need for explicit casts or type coercions, provided
that the :paramref:.postgresql.ARRAY.dimensions parameter is set to the
desired number of dimensions. fixes support direct mult-dimensional ARRAY access based on explicit dimensions #3487
The return type for the :class:.postgresql.JSON and :class:.postgresql.JSONB
when using indexed access has been fixed to work like Postgresql itself,
and returns an expression that itself is of type :class:.postgresql.JSON
or :class:.postgresql.JSONB. Previously, the accessor would return
:class:.NullType which disallowed subsequent JSON-like operators to be
used. part of fixes add full control for return type under PG ARRAY, HSTORE, JSON, JSONB indexed (element) access #3503
The :class:.postgresql.JSON, :class:.postgresql.JSONB and
:class:.postgresql.HSTORE datatypes now allow full control over the
return type from an indexed textual access operation, either column[someindex].astext
for a JSON type or column[someindex] for an HSTORE type,
via the :paramref:.postgresql.JSON.astext_type and
:paramref:.postgresql.HSTORE.text_type parameters. also part of fixes add full control for return type under PG ARRAY, HSTORE, JSON, JSONB indexed (element) access #3503
The :attr:.postgresql.JSON.Comparator.astext modifier no longer
calls upon :meth:.ColumnElement.cast implicitly, as PG's JSON/JSONB
types allow cross-casting between each other as well. Code that
makes use of :meth:.ColumnElement.cast on JSON indexed access,
e.g. col[someindex].cast(Integer), will need to be changed
to call :attr:.postgresql.JSON.Comparator.astext explicitly. This is
part of the refactor in references add full control for return type under PG ARRAY, HSTORE, JSON, JSONB indexed (element) access #3503 for consistency in operator
use.
The Postgresql :class:.postgresql.ARRAY type now supports multidimensional
indexed access, e.g. expressions such as somecol[5][6] without
any need for explicit casts or type coercions, provided
that the :paramref:.postgresql.ARRAY.dimensions parameter is set to the
desired number of dimensions. fixes support direct mult-dimensional ARRAY access based on explicit dimensions #3487
The return type for the :class:.postgresql.JSON and :class:.postgresql.JSONB
when using indexed access has been fixed to work like Postgresql itself,
and returns an expression that itself is of type :class:.postgresql.JSON
or :class:.postgresql.JSONB. Previously, the accessor would return
:class:.NullType which disallowed subsequent JSON-like operators to be
used. part of fixes add full control for return type under PG ARRAY, HSTORE, JSON, JSONB indexed (element) access #3503
The :class:.postgresql.JSON, :class:.postgresql.JSONB and
:class:.postgresql.HSTORE datatypes now allow full control over the
return type from an indexed textual access operation, either column[someindex].astext
for a JSON type or column[someindex] for an HSTORE type,
via the :paramref:.postgresql.JSON.astext_type and
:paramref:.postgresql.HSTORE.text_type parameters. also part of fixes add full control for return type under PG ARRAY, HSTORE, JSON, JSONB indexed (element) access #3503
The :attr:.postgresql.JSON.Comparator.astext modifier no longer
calls upon :meth:.ColumnElement.cast implicitly, as PG's JSON/JSONB
types allow cross-casting between each other as well. Code that
makes use of :meth:.ColumnElement.cast on JSON indexed access,
e.g. col[someindex].cast(Integer), will need to be changed
to call :attr:.postgresql.JSON.Comparator.astext explicitly. This is
part of the refactor in references add full control for return type under PG ARRAY, HSTORE, JSON, JSONB indexed (element) access #3503 for consistency in operator
use.
Activity
sqlalchemy-bot commentedon Jul 29, 2015
Michael Bayer (@zzzeek) wrote:
see also #3499 and #3487 which should refer to this system.
sqlalchemy-bot commentedon Aug 11, 2015
Michael Bayer (@zzzeek) wrote:
The ongoing work here is in https://bitbucket.org/zzzeek/sqlalchemy/src/39adada25d71ac33d2a468cc19eb61c0fdfa9280/?at=ticket_3499, however the idea of the "schema" or "index_map" has been scaled back; it's not appropriate given that the PG JSON type always returns a json object no matter what you do to it; what index_map/schema would need to do is to automatically render CAST clauses for all of these types and that's just too elaborate and unnecessary.
The latest in that branch has all three of array, hstore, json/jsonb working fully with a much simpler architecture than before.
sqlalchemy-bot commentedon Aug 17, 2015
Michael Bayer (@zzzeek) wrote:
.postgresql.ARRAY,:class:
.postgresql.JSONand :class:.postgresql.HSTOREis nowset to False, which allows these types to be fetchable in ORM
queries that include entities within the row. fixes flip off the "hashable" flag for PG unhashable types: JSON, JSONB (already has it), ARRAY. also NULLTYPE, add/test type_coerce as well as cast() to indexed access #3499
.postgresql.ARRAYtype now supports multidimensionalindexed access, e.g. expressions such as
somecol[5][6]withoutany need for explicit casts or type coercions, provided
that the :paramref:
.postgresql.ARRAY.dimensionsparameter is set to thedesired number of dimensions. fixes support direct mult-dimensional ARRAY access based on explicit dimensions #3487
.postgresql.JSONand :class:.postgresql.JSONBwhen using indexed access has been fixed to work like Postgresql itself,
and returns an expression that itself is of type :class:
.postgresql.JSONor :class:
.postgresql.JSONB. Previously, the accessor would return:class:
.NullTypewhich disallowed subsequent JSON-like operators to beused. part of fixes add full control for return type under PG ARRAY, HSTORE, JSON, JSONB indexed (element) access #3503
.postgresql.JSON, :class:.postgresql.JSONBand:class:
.postgresql.HSTOREdatatypes now allow full control over thereturn type from an indexed textual access operation, either
column[someindex].astextfor a JSON type or
column[someindex]for an HSTORE type,via the :paramref:
.postgresql.JSON.astext_typeand:paramref:
.postgresql.HSTORE.text_typeparameters. also part of fixes add full control for return type under PG ARRAY, HSTORE, JSON, JSONB indexed (element) access #3503.postgresql.JSON.Comparator.astextmodifier no longercalls upon :meth:
.ColumnElement.castimplicitly, as PG's JSON/JSONBtypes allow cross-casting between each other as well. Code that
makes use of :meth:
.ColumnElement.caston JSON indexed access,e.g.
col[someindex].cast(Integer), will need to be changedto call :attr:
.postgresql.JSON.Comparator.astextexplicitly. This ispart of the refactor in references add full control for return type under PG ARRAY, HSTORE, JSON, JSONB indexed (element) access #3503 for consistency in operator
use.
→ ceeb033
sqlalchemy-bot commentedon Aug 17, 2015
Michael Bayer (@zzzeek) wrote:
.postgresql.ARRAY,:class:
.postgresql.JSONand :class:.postgresql.HSTOREis nowset to False, which allows these types to be fetchable in ORM
queries that include entities within the row. fixes flip off the "hashable" flag for PG unhashable types: JSON, JSONB (already has it), ARRAY. also NULLTYPE, add/test type_coerce as well as cast() to indexed access #3499
.postgresql.ARRAYtype now supports multidimensionalindexed access, e.g. expressions such as
somecol[5][6]withoutany need for explicit casts or type coercions, provided
that the :paramref:
.postgresql.ARRAY.dimensionsparameter is set to thedesired number of dimensions. fixes support direct mult-dimensional ARRAY access based on explicit dimensions #3487
.postgresql.JSONand :class:.postgresql.JSONBwhen using indexed access has been fixed to work like Postgresql itself,
and returns an expression that itself is of type :class:
.postgresql.JSONor :class:
.postgresql.JSONB. Previously, the accessor would return:class:
.NullTypewhich disallowed subsequent JSON-like operators to beused. part of fixes add full control for return type under PG ARRAY, HSTORE, JSON, JSONB indexed (element) access #3503
.postgresql.JSON, :class:.postgresql.JSONBand:class:
.postgresql.HSTOREdatatypes now allow full control over thereturn type from an indexed textual access operation, either
column[someindex].astextfor a JSON type or
column[someindex]for an HSTORE type,via the :paramref:
.postgresql.JSON.astext_typeand:paramref:
.postgresql.HSTORE.text_typeparameters. also part of fixes add full control for return type under PG ARRAY, HSTORE, JSON, JSONB indexed (element) access #3503.postgresql.JSON.Comparator.astextmodifier no longercalls upon :meth:
.ColumnElement.castimplicitly, as PG's JSON/JSONBtypes allow cross-casting between each other as well. Code that
makes use of :meth:
.ColumnElement.caston JSON indexed access,e.g.
col[someindex].cast(Integer), will need to be changedto call :attr:
.postgresql.JSON.Comparator.astextexplicitly. This ispart of the refactor in references add full control for return type under PG ARRAY, HSTORE, JSON, JSONB indexed (element) access #3503 for consistency in operator
use.
→ ceeb033
sqlalchemy-bot commentedon Aug 17, 2015
Michael Bayer (@zzzeek) wrote:
.postgresql.ARRAY,:class:
.postgresql.JSONand :class:.postgresql.HSTOREis nowset to False, which allows these types to be fetchable in ORM
queries that include entities within the row. fixes flip off the "hashable" flag for PG unhashable types: JSON, JSONB (already has it), ARRAY. also NULLTYPE, add/test type_coerce as well as cast() to indexed access #3499
.postgresql.ARRAYtype now supports multidimensionalindexed access, e.g. expressions such as
somecol[5][6]withoutany need for explicit casts or type coercions, provided
that the :paramref:
.postgresql.ARRAY.dimensionsparameter is set to thedesired number of dimensions. fixes support direct mult-dimensional ARRAY access based on explicit dimensions #3487
.postgresql.JSONand :class:.postgresql.JSONBwhen using indexed access has been fixed to work like Postgresql itself,
and returns an expression that itself is of type :class:
.postgresql.JSONor :class:
.postgresql.JSONB. Previously, the accessor would return:class:
.NullTypewhich disallowed subsequent JSON-like operators to beused. part of fixes add full control for return type under PG ARRAY, HSTORE, JSON, JSONB indexed (element) access #3503
.postgresql.JSON, :class:.postgresql.JSONBand:class:
.postgresql.HSTOREdatatypes now allow full control over thereturn type from an indexed textual access operation, either
column[someindex].astextfor a JSON type or
column[someindex]for an HSTORE type,via the :paramref:
.postgresql.JSON.astext_typeand:paramref:
.postgresql.HSTORE.text_typeparameters. also part of fixes add full control for return type under PG ARRAY, HSTORE, JSON, JSONB indexed (element) access #3503.postgresql.JSON.Comparator.astextmodifier no longercalls upon :meth:
.ColumnElement.castimplicitly, as PG's JSON/JSONBtypes allow cross-casting between each other as well. Code that
makes use of :meth:
.ColumnElement.caston JSON indexed access,e.g.
col[someindex].cast(Integer), will need to be changedto call :attr:
.postgresql.JSON.Comparator.astextexplicitly. This ispart of the refactor in references add full control for return type under PG ARRAY, HSTORE, JSON, JSONB indexed (element) access #3503 for consistency in operator
use.
→ ceeb033
sqlalchemy-bot commentedon Aug 17, 2015
Changes by Michael Bayer (@zzzeek):