n8n/packages/nodes-base/nodes/Postgres
Elias Meire bed04ec122
fix(Postgres Node): Stop marking autogenerated columns as required (#8230)
## Summary

Postgres columns can be
- [generated as
identity](https://www.postgresqltutorial.com/postgresql-tutorial/postgresql-identity-column/)
- [generated by a custom
expression](https://www.postgresql.org/docs/current/ddl-generated-columns.html)

In these 2 cases, the column is not required when inserting a new row.
This PR makes sure these types of column are not marked required in n8n.

### How to test

1. Create a Postgres table with all types of generated columns:
for version >= 10
  ```sql
  CREATE TABLE "public"."test_table" (
      "id" int8 NOT NULL DEFAULT nextval('test_table_id_seq'::regclass),
      "identity_id" bigint GENERATED ALWAYS AS IDENTITY,
      "id_plus" numeric GENERATED ALWAYS AS (id + 5) STORED,
      "title" varchar NOT NULL,
      "created_at" timestamp DEFAULT now(),
      PRIMARY KEY ("id")
  )
  ```
  Before 10 you have to use serial or bigserial types:
  ```sql
  CREATE TABLE distributors (
     did    serial not null primary key,
     name   varchar(40) NOT NULL CHECK (name <> '')
);
  ```
2. Add a postgres node to canvas and try to insert data without the
generated columns
3. Should successfully insert

More info in Linear/Github issue ⬇️ 

## Related tickets and issues
- fixes #7084
-
https://linear.app/n8n/issue/NODE-816/rmc-not-all-id-fields-should-be-required
-
https://linear.app/n8n/issue/NODE-681/postgres-cant-map-automatically-if-database-requires-a-field

## Review / Merge checklist
- [ ] PR title and summary are descriptive. **Remember, the title
automatically goes into the changelog. Use `(no-changelog)` otherwise.**
([conventions](https://github.com/n8n-io/n8n/blob/master/.github/pull_request_title_conventions.md))
- [ ] [Docs updated](https://github.com/n8n-io/n8n-docs) or follow-up
ticket created.
- [ ] Tests included.
> A bug is not considered fixed, unless a test is added to prevent it
from happening again.
   > A feature is not complete without tests.

---------

Co-authored-by: Michael Kret <michael.k@radency.com>
2024-01-05 12:37:33 +01:00
..
test/v2 refactor: Run lintfix (no-changelog) (#7537) 2023-10-27 14:15:02 +02:00
v1 feat(editor): Add fullscreen view to code editor (#8084) 2024-01-04 17:23:24 +01:00
v2 fix(Postgres Node): Stop marking autogenerated columns as required (#8230) 2024-01-05 12:37:33 +01:00
Postgres.node.json fix(nodes-base): fix and harmonize all primaryDocumentation links (#4191) 2022-09-29 13:33:16 +03:00
Postgres.node.ts fix: Make params panel double width for all SQL nodes (#8236) 2024-01-05 12:31:11 +01:00
postgres.svg refactor: Optimize SVG icons for nodes (#8195) 2024-01-02 17:40:08 +01:00
PostgresInterface.ts feat: New trigger PostgreSQL (#5495) 2023-06-07 11:01:57 +02:00
PostgresTrigger.functions.ts refactor: Switch plain errors in nodes-base to ApplicationError (no-changelog) (#7914) 2023-12-05 11:17:08 +01:00
PostgresTrigger.node.json docs: Fix Postgres trigger docs URL (#6403) 2023-06-13 15:06:28 +01:00
PostgresTrigger.node.ts fix(Postgres Trigger Node): Increase manual trigger timeout from 30 to 60 seconds (#8015) 2023-12-13 13:04:16 +00:00