Budibase / budibase

Low code platform for building business apps and workflows in minutes. Supports PostgreSQL, MySQL, MariaDB, MSSQL, MongoDB, Rest API, Docker, K8s, and more 🚀
https://budibase.com
Other
22.68k stars 1.57k forks source link

Save Row (insert) action to postgres fails, but row still inserts #2673

Closed mjashanks closed 3 years ago

mjashanks commented 3 years ago

I have 2 postgres tables

One Vehicles has Many ServiceLog

Create scripts for tables, with data are attached.

Now, I ....

  1. create a "New Row" form, for "ServiceLog"
  2. Remove unnecessary fields - VehicleId and ID
  3. Run my application, and open my screen
  4. Fill out form and press save

RESULT:

My Request

{
  "Vehicle": [
    "%5B'7'%5D"
  ],
  "Mileage": 444444,
  "ServiceDate": "2021-09-29T23:00:00.000Z",
  "Description": "hello",
  "__valid": true,
  "__currentStep": 1,
  "__currentStepValid": true,
  "Category": "Brakes",
  "tableId": "datasource_plus_238519b3a39b417cb2e58646988e1d67__ServiceLog"
}

This request works... I got this by inserting a row via the builder

{
  "Category": "cat",
  "Description": "description",
  "ServiceDate": "2021-09-08T11:00:00.000Z",
  "VehicleId": "",
  "Mileage": 66666,
  "id": null,
  "Vehicle": [
    "%5B'3'%5D"
  ],
  "tableId": "datasource_plus_238519b3a39b417cb2e58646988e1d67__ServiceLog"
}

Create script for tables...

CREATE TABLE IF NOT EXISTS public."Vehicles"
(
    id bigint NOT NULL GENERATED ALWAYS AS IDENTITY ( INCREMENT 1 START 1 MINVALUE 1 MAXVALUE 9223372036854775807 CACHE 1 ),
    "Registration" text COLLATE pg_catalog."default",
    "Make" text COLLATE pg_catalog."default",
    "Model" text COLLATE pg_catalog."default",
    "Colour" text COLLATE pg_catalog."default",
    "Year" smallint,
    CONSTRAINT "Vehicles_pkey" PRIMARY KEY (id)
)

TABLESPACE pg_default;

CREATE TABLE IF NOT EXISTS public."ServiceLog"
(
    id bigint NOT NULL GENERATED ALWAYS AS IDENTITY ( INCREMENT 1 START 1 MINVALUE 1 MAXVALUE 9223372036854775807 CACHE 1 ),
    "Description" text COLLATE pg_catalog."default",
    "VehicleId" bigint,
    "ServiceDate" timestamp without time zone,
    "Category" text COLLATE pg_catalog."default",
    "Mileage" bigint,
    CONSTRAINT "ServiceLog_pkey" PRIMARY KEY (id),
    CONSTRAINT vehicle_foreign_key FOREIGN KEY ("VehicleId")
        REFERENCES public."Vehicles" (id) MATCH SIMPLE
        ON UPDATE NO ACTION
        ON DELETE NO ACTION
)

TABLESPACE pg_default;

INSERT INTO public."Vehicles"("Registration", "Make", "Model", "Colour", "Year")
VALUES ('FAZ 9837','Volkswagen','Polo','White',2002);
INSERT INTO public."Vehicles"("Registration", "Make", "Model", "Colour", "Year")
VALUES ('JHI 8827','BMW','M3','Black',2013);
INSERT INTO public."Vehicles"("Registration", "Make", "Model", "Colour", "Year")
VALUES ('D903PI','Volvo','XC40','Grey',2014);
INSERT INTO public."Vehicles"("Registration", "Make", "Model", "Colour", "Year")
VALUES ('YFI002','Volkswagen','Golf','Dark Blue',2018);
INSERT INTO public."Vehicles"("Registration", "Make", "Model", "Colour", "Year")
VALUES ('HGT5677','Skoda','Octavia','Graphite',2009);
INSERT INTO public."Vehicles"("Registration", "Make", "Model", "Colour", "Year")
VALUES ('PPF9276','Skoda','Octavia','Graphite',2021);
INSERT INTO public."Vehicles"("Registration", "Make", "Model", "Colour", "Year")
VALUES ('J893FT','Toyota','Corolla','Red',2015);
INSERT INTO public."Vehicles"("Registration", "Make", "Model", "Colour", "Year")
VALUES ('MJK776','Honda','HR-V','Silver',2015);

INSERT INTO public."ServiceLog"("Description", "VehicleId", "ServiceDate", "Category", "Mileage")
VALUES ('Change front brakes', 1, '2021-05-04', 'Brakes', 20667);
INSERT INTO public."ServiceLog"("Description", "VehicleId", "ServiceDate", "Category", "Mileage")
VALUES ('Tyres - full set', 1, '2021-05-04', 'Brakes', 20667);
INSERT INTO public."ServiceLog"("Description", "VehicleId", "ServiceDate", "Category", "Mileage")
VALUES ('Engine tune up', 2, '2021-07-14', 'Brakes', 50889);
INSERT INTO public."ServiceLog"("Description", "VehicleId", "ServiceDate", "Category", "Mileage")
VALUES ('Replace transmission', 3, '2021-09-26', 'Transmission', 98002);
mike12345567 commented 3 years ago

Closing as PR with fix merged.