appsmithorg / appsmith

Platform to build admin panels, internal tools, and dashboards. Integrates with 25+ databases and any API.
https://www.appsmith.com
Apache License 2.0
34.56k stars 3.73k forks source link

[Feature]: auto generate form from SQL query and identify foreign key constraints #13750

Open sumitsum opened 2 years ago

sumitsum commented 2 years ago

Is there an existing issue for this?

Summary

Ref: https://community.appsmith.com/t/define-foreign-key-drop-downs/955 From community:

Given the following table in a postgresql database:

CREATE TABLE IF NOT EXISTS public.mf_shift_outputs
(
id bigint NOT NULL DEFAULT nextval(‘mf_shift_outputs_id_seq’::regclass),
mf_shift_id bigint NOT NULL,
stitem_id bigint NOT NULL,
uom_id bigint NOT NULL,
output numeric NOT NULL,
planned_time numeric NOT NULL,
run_time_speed numeric NOT NULL,
operators numeric NOT NULL,
work_order_id bigint,
usercompanyid bigint NOT NULL,
created timestamp without time zone DEFAULT now(),
createdby character varying COLLATE pg_catalog.“default”,
alteredby character varying COLLATE pg_catalog.“default”,
lastupdated timestamp without time zone DEFAULT now(),
CONSTRAINT mf_shift_outputs_pkey PRIMARY KEY (id),
CONSTRAINT mf_shift_outputs_shift_id_fkey FOREIGN KEY (mf_shift_id)
REFERENCES public.mf_shifts (id) MATCH SIMPLE
ON UPDATE CASCADE
ON DELETE CASCADE,
CONSTRAINT mf_shift_outputs_stitem_id_fkey FOREIGN KEY (stitem_id)
REFERENCES public.st_items (id) MATCH SIMPLE
ON UPDATE CASCADE
ON DELETE CASCADE,
CONSTRAINT mf_shift_outputs_uom_id_fkey FOREIGN KEY (uom_id)
REFERENCES public.st_uoms (id) MATCH SIMPLE
ON UPDATE CASCADE
ON DELETE CASCADE,
CONSTRAINT mf_shift_outputs_usercompanyid_fkey FOREIGN KEY (usercompanyid)
REFERENCES public.system_companies (id) MATCH SIMPLE
ON UPDATE CASCADE
ON DELETE CASCADE,
CONSTRAINT mf_shift_outputs_work_order_id_fkey FOREIGN KEY (work_order_id)
REFERENCES public.mf_workorders (id) MATCH SIMPLE
ON UPDATE CASCADE
ON DELETE CASCADE
)

Can Appsmith auto generate a form and resolve the foregn keys from the constraints so that, say, a description for a referenced id could be shown in a drop down?

I am guessing not because form generation from a query on the table presents the foreign key ‘lookups’ as id columns.

Thanks
Martyn

Why should this be worked on?

Makes it easier to create forms.

dilippitchika commented 1 year ago

@momcilo-appsmith this looks like a similar problem where the starting point is a CREATE query than a form or table

ecmonsen commented 10 months ago

This is a needed feature for me too.