n8n/packages/workflow/src
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
..
errors refactor(core): Instrument multi-main to report failures to renew lease (#7970) 2023-12-11 09:45:08 +01:00
Extensions docs: Improve documentation for the toTitleCase function (no-changelog) (#8140) 2023-12-22 14:22:05 +00:00
NativeMethods
NodeParameters feat(editor): Filter component + implement in If node (#7490) 2023-12-13 14:45:22 +01:00
AugmentObject.ts refactor(core): Use a Set for deletedProperties in AugmentObject (no-changelog) (#7131) 2023-09-07 15:07:32 +02:00
Authentication.ts refactor(core)!: Remove basic-auth, external-jwt-auth, and no-auth options (#6362) 2023-06-22 20:03:47 +02:00
Constants.ts feat(editor): Create separate components for JS and JSON editors (no-changelog) (#8156) 2023-12-29 10:49:27 +01:00
Cron.ts
DeferredPromise.ts
ErrorReporterProxy.ts refactor(core): Instrument multi-main to report failures to renew lease (#7970) 2023-12-11 09:45:08 +01:00
ExecutionStatus.ts refactor: Stop using .d.ts files for type-collection files (no-changelog) (#6634) 2023-07-10 19:35:34 +02:00
Expression.ts refactor(core): Switch plain errors in workflow to ApplicationError (no-changelog) (#7877) 2023-11-30 12:46:45 +01:00
ExpressionEvaluatorProxy.ts feat(core): Add Tournament as the new default expression evaluator (#6964) 2023-09-21 13:57:45 +01:00
GlobalState.ts refactor(core): Avoid passing around static state like default timezone (no-changelog) (#7221) 2023-10-27 14:17:52 +02:00
index.ts fix(core): Remove circular references before serializing executions in public API (#8043) 2023-12-15 16:01:41 +01:00
Interfaces.ts feat(HTTP Request Node): Interval Between Requests option for pagination (#8224) 2024-01-04 17:11:16 +02:00
LoggerProxy.ts refactor(core): Make Logger a service (no-changelog) (#7494) 2023-10-25 16:35:22 +02:00
MessageEventBus.ts
NodeHelpers.ts fix(Postgres Node): Stop marking autogenerated columns as required (#8230) 2024-01-05 12:37:33 +01:00
ObservableObject.ts refactor: Clear unused ESLint directives from BE packages (no-changelog) (#6798) 2023-07-31 11:00:48 +02:00
RoutingNode.ts fix(core): Unsafe isAxiosError property access (no-changelog) (#8197) 2024-01-03 20:43:31 +02:00
TelemetryHelpers.ts refactor(core): Switch plain errors in workflow to ApplicationError (no-changelog) (#7877) 2023-11-30 12:46:45 +01:00
type-guards.ts feat(editor): Filter component + implement in If node (#7490) 2023-12-13 14:45:22 +01:00
types.d.ts fix(core): Serialize BigInts (#6805) 2023-07-31 16:53:30 +02:00
TypeValidation.ts feat(n8n Form Trigger Node): Improvements (#7571) 2023-12-13 17:00:51 +02:00
utils.ts fix(core): Remove circular references before serializing executions in public API (#8043) 2023-12-15 16:01:41 +01:00
VersionedNodeType.ts
Workflow.ts feat(core): Add closeFunction support to Sub-Nodes (#7708) 2023-12-21 14:21:09 +01:00
WorkflowDataProxy.ts refactor(core): Switch plain errors in workflow to ApplicationError (no-changelog) (#7877) 2023-11-30 12:46:45 +01:00
WorkflowHooks.ts refactor: Clear unused ESLint directives from BE packages (no-changelog) (#6798) 2023-07-31 11:00:48 +02:00