Skip to content

Support for composite types. #74

@AlexanderVanDamme

Description

@AlexanderVanDamme

At first i had just a jsonb for these preferred positions, but since this was untyped i decided to create a composite type for them:

CREATE TYPE preferred_position_type AS (
    position player_position,
    preference preference_type
);

this player_position and preference type is both an enum

CREATE TYPE player_position AS ENUM (
    'GK', 'RB', 'CB', 'LB', 'LWB', 'RWB', 'CDM', 'CM', 'CAM', 
    'RM', 'LM', 'RW', 'LW', 'CF', 'ST'
);

CREATE TYPE preference_type AS ENUM (
    'preferred', 'filler', 'veto'
);

ALTER TABLE players ADD COLUMN preferred_positions preferred_position_type[] DEFAULT '{}';

But when i run it i get the following error

gleam run -m squirrel
Compiled in 0.03s
Running squirrel.main
Error: Unsupported type

 ╭─ ./src/squirrels/sql/get_all_players.sql

One of the rows returned by this query has type
preferred_position_type which I cannot currently generate code
for.

If you would like for this type to be supported, please open an
issue at
https://github.com/giacomocavalieri/squirrel/issues/new

🥜 I could still generate 4 queries.

Would be nice if such typing would be supported, would cleanup the decoders needed for it !
(or maybe there's other ways to type such data?)

Metadata

Metadata

Labels

enhancementNew feature or request

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions