Modeling relation that doesn't follow naming strategy
See original GitHub issueMy application follow the EntityCaseNamingStrategy
and I don’t wish to change that.
There are two tables that I didn’t design and I would like to accommodate.
Basically Account
has many AccountSegment
s. Here is the abridged DDL
CREATE TABLE "Account" (
"accountNumber" text PRIMARY KEY,
...
);
CREATE TABLE "AccountSegment" (
"segmentId" text PRIMARY KEY,
"accountNumber" text,
...
);
What options do I have to pass to @ManyToOne
and @OneToMany
to accommodate this? I’ve been trying with no luck along the lines of:
@ManyToOne(() => Account, { inversedBy: 'segments', })
account?: IdentifiedReference<Account>;
...
@OneToMany(() => AccountSegment, segment => segment.account, { referenceColumnName: 'accountNumber', })
segments = new Collection<AccountSegment>(this);
Issue Analytics
- State:
- Created 4 years ago
- Comments:18 (9 by maintainers)
Top Results From Across the Web
Naming Conventions in Database Modeling - Vertabelo
Database models require that objects be named. While several facets of naming an object deserve consideration, in this article we'll focus ...
Read more >ActiveRecord Naming Conventions and How to Alias Around ...
A model name is singular and uses CamelCase — the corresponding table uses snake_case and is pluralized using Ruby's pluralize method so you...
Read more >Naming Strategies - Sequelize
Naming Strategies. The underscored option. Sequelize provides the underscored option for a model. When true , this option will set the field option...
Read more >Are there conventions for naming 'through' models in Django
Django has some very clear conventions for naming models: do so in the singular; describe the object the model represents ...
Read more >Fluent API - Relationships - EF6 - Microsoft Learn
Fluent API - Relationships in Entity Framework 6. ... Foreign Key Name That Does Not Follow the Code First Convention; Model Used in...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
That’s not actually the source of the error.
The problem is that
meta.primaryKey
is “accountNumber” but in theentity
(owning side of 1:m), the field has been renamed toaccount
.I brought the definitions to the subclass level and it’s working. Thanks for everything.