Why do I have to set an id
, even if it’s an increment?
This will be handled automatically by the database.
Version: 1.65.2
n8n
November 14, 2024, 1:48pm
2
It looks like your topic is missing some important information. Could you provide the following if applicable.
n8n version:
Database (default: SQLite):
n8n EXECUTIONS_PROCESS setting (default: own, main):
Running n8n via (Docker, npm, n8n cloud, desktop app):
Operating system:
ihortom
November 14, 2024, 7:14pm
3
Hey @renetheastronaut , I suspect this is because you chose “Map each column manually” mode. If you switch to “Map Automatically”, you are not required to use the id. Surely that also implies you have to make sure the property names in you input matches the column names.
thomlov
November 14, 2024, 7:30pm
4
There is an old github issue that was marked as solved regarding this. But it’s not solved, I have the same thing.
n8n-io:master
← n8n-io:node-816-rmc-not-all-id-fields-should-be-required
opened 03:47PM - 04 Jan 24 UTC
## Summary
Postgres columns can be
- [generated as identity](https://www.pos… tgresqltutorial.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.
You can get around it by using the upsert node, or by using Map Automatically as ihortom says.
1 Like
Joejoe
February 5, 2025, 8:53pm
5
Yes, please fix this issue when using “Map columns manually”
Joejoe
February 5, 2025, 8:54pm
6
gualter
February 12, 2025, 9:22pm
7
Hi @Joejoe
The issue mentions the PR that fixed it as 🚀 Release 1.24.0 by github-actions[bot] · Pull Request #8290 · n8n-io/n8n · GitHub
Is this issue happening again on the latest version you say? How did you replicate this?
Thanks!
Yes it’s happening for me as well with a required ‘id’ column that has an auto number. The postgres node is requiring it still for inserts, which is annoying. I’m using v1.79.3.
Found the issue, make sure the Identity setting for the column is ALWAYS and not BY DEFAULT, otherwise it will be required in n8n because the column is marked as required, so no default will be used. It works now as expected, as ALWAYS will make sure an identity is always generated.
system
Closed
June 15, 2025, 1:45am
10
This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.