Prevent foreign key column names from appending _id
See original GitHub issueDBFlow Version: 4.0.0-beta5 Issue Kind (Bug, Question, Feature): Question
Description:
For foreign key references How can I prevent foreign id names from appending _id
at the end?
For example, I have 2 classes like this: organization class:
@Table(database = MyDatabase.class)
public class organization extends BaseModel {
@Column
@PrimaryKey
int id;
@Column
String name;
// getters and setters
}
college class:
@Table(database = MyDatabase.class)
public class college extends BaseModel {
@Column
@PrimaryKey
int id;
@Column
String name;
@Column
@ForeignKey(tableClass = organization.class)
int foo;
// getters and setters
}
But, when I compile, the name foo
becomes foo_id
in the database as well as college_Table class.
Setting @Column(name=“foo”) also doesn’t work. It failes at the compile time only. And gives the following error:
Error:Execution failed for task ':app:compileDebugJavaWithJavac'.
> java.util.MissingFormatArgumentException: Format specifier '%1s'
Is there any way I can prevent this behavior and keep the same name foo
?
Issue Analytics
- State:
- Created 7 years ago
- Comments:7 (5 by maintainers)
Top Results From Across the Web
EF Core, disable foreign key column name generation
I corrected issue by adding ForeignKey attribute to Book class. I borrowed the answer from: The required column 'CustomerId' was not present ...
Read more >3 common foreign key mistakes (and how to avoid them)
Dangling foreign keys 3. Not creating foreign key indexes Bonus: Not using foreign keys Key takeaway: think before you CREATE TABLE.
Read more >Documentation: 15: 5.4. Constraints - PostgreSQL
You can assign your own name for a foreign key constraint, in the usual way. A foreign key can also constrain and reference...
Read more >13.1.18.5 FOREIGN KEY Constraints - MySQL :: Developer Zone
The table must have the correct column names and types. It must also have indexes on the referenced keys. If these requirements are...
Read more >Keys - EF Core | Microsoft Learn
Configuring a primary key; Value generation; Primary key name; Key types and values; Alternate Keys. A key serves as a unique identifier for ......
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 FreeTop 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
Top GitHub Comments
Ill keep this open as a reminder 😃
if you have multiple primary keys:
where: