(db-postgres): Non-standard column names between _rels
tables and tables created from arrays (i.e. _parent_id
and parent_id
)
#8201
Replies: 4 comments
-
In the postgres adaptor I've seen code like this:
const baseExtraConfig: BaseExtraConfig = {
orderIdx: (cols) => index(`${selectTableName}_order_idx`).on(cols.order),
parentFk: (cols) =>
foreignKey({
name: `${selectTableName}_parent_fk`,
columns: [cols.parent],
foreignColumns: [adapter.tables[parentTableName].id],
}).onDelete('cascade'),
parentIdx: (cols) => index(`${selectTableName}_parent_idx`).on(cols.parent),
} So I wonder in the case of arrays is what you're seeing just an empty string in that case, hence the leading |
Beta Was this translation helpful? Give feedback.
-
Good find! I was thinking the same thing - it smells of string concatenation. |
Beta Was this translation helpful? Give feedback.
-
@BlainMaguire - looks like a little above that in the file is where the array column names are specified: const baseColumns: Record<string, PgColumnBuilder> = {
_order: integer('_order').notNull(),
_parentID: parentIDColumnMap[parentIDColType]('_parent_id').notNull(),
} |
Beta Was this translation helpful? Give feedback.
-
We used Does that answer the question? It would be trivial for us to add to the db adapter configuration additional properties for I'm interested in your feedback. I'm changing this to a discussion since I don't see any issue here. |
Beta Was this translation helpful? Give feedback.
-
Link to reproduction
https://github.com/DapperMountain/payload-3-bun-template
Environment Info
Describe the Bug
_rels
tables and tables created from arrays have different column naming syntax for some reason.Additionally (nit): The
id
field in the array table (users_tenants
) should be positioned as the first column in the table and uses a different UUID format than the otherid
fields.Example
users_rels
tableorder
andparent_id
users_tenants
table_order
and_parent_id
Reproduction Steps
Set up a users collection like this. It should create the tables for us to reproduce the issue.
Adapters and Plugins
db-postgres
Beta Was this translation helpful? Give feedback.
All reactions