lovasoa / SQLpage

SQL-only webapp builder, empowering data analysts to build websites and applications quickly
https://sql.ophir.dev
MIT License
882 stars 62 forks source link

Render Composite Types in Tables #376

Open guspower opened 4 weeks ago

guspower commented 4 weeks ago

What are you building with SQLPage ?

A system for capturing technical requirements and examples.

What is your problem ? A description of the problem, not the solution you are proposing.

I have a number of postgreSQL composite types in my schema. When I list these fields in a table component nothing is rendered. It would be great if SQLPage could render something in that area rather than having to explicitly list out each subfield using (column).attribute syntax.

What are you currently doing ? Since your solution is not implemented in SQLPage currently, what are you doing instead ?

I am listing out each subfield using (column).attribute syntax.

Describe the solution you'd like

SQLPage "magically" figures out how to render the composite type somehow. I have no idea how it might do this. I could imagine it adding columns based on the union of the column name and composite type field name e.g. column_field.

Describe alternatives you've considered

Just select the column values explicitly.

Additional context

I use composite types to make it easier to deal with data from a number of APIs that have embedded values like money (combination of currency and amount). An example of a composite type in postgreSQL might be:

CREATE TYPE monetary_value AS (
    amount real,
    currency character varying
);

CREATE TABLE balance (
    yesterday monetary_value NOT NULL,
    today monetary_value NOT NULL
);

SELECT (yesterday).amount, (today).amount FROM balance;
lovasoa commented 3 weeks ago

Hello ! That's interesting. I'll keep that in mind and try to implement it later.