question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Issue with snake_case naming strategy

See original GitHub issue

Issue type:

[ ] question [x] bug report [ ] feature request [ ] documentation issue

Database system/driver:

[ ] cordova [ ] mongodb [x] mssql [x] mysql / mariadb [ ] oracle [ ] postgres [ ] sqlite [ ] sqljs [ ] react-native

TypeORM version:

[x] latest [ ] @next [ ] 0.x.x (or put your version here)

Steps to reproduce or a small repository showing the problem:

I have two tables:

product

id

product_attachment

id product_id

var productAttachment = repository.findAndCount({ relations: 'product'});

QueryFailedError: ER_DUP_FIELDNAME: Duplicate column name ‘ProductAttachment_product_id’

This issue happens because query builder generate alias ProductAttachment_product_id twice: product_attachment.product_id -> ProductAttachment_product_id product_attachment.product.id -> ProductAttachment_product_id

Issue Analytics

  • State:open
  • Created 5 years ago
  • Reactions:5
  • Comments:22 (4 by maintainers)

github_iconTop GitHub Comments

22reactions
zwenzacommented, Jul 12, 2019

Can confirm that setting the snake-case naming strategy fixes the issue!

const SnakeNamingStrategy = require('typeorm-naming-strategies').SnakeNamingStrategy;

module.exports = {
   type: "mysql",
   host: "localhost",
   port: 3306,
   ...
   namingStrategy: new SnakeNamingStrategy(),
}
9reactions
cliedeltcommented, Jan 14, 2019

Issue type:

[ ] question [x] bug report [ ] feature request [ ] documentation issue

Database system/driver:

[ ] cordova [ ] mongodb [x] mssql [x] mysql / mariadb [ ] oracle [ ] postgres [ ] sqlite [ ] sqljs [ ] react-native

TypeORM version:

[x] latest [ ] @next [ ] 0.x.x (or put your version here)

Steps to reproduce or a small repository showing the problem:

I have two tables:

product

id

product_attachment

id product_id

var productAttachment = repository.findAndCount({ relations: 'product'});

QueryFailedError: ER_DUP_FIELDNAME: Duplicate column name ‘ProductAttachment_product_id’

This issue happens because query builder generate alias ProductAttachment_product_id twice: product_attachment.product_id -> ProductAttachment_product_id product_attachment.product.id -> ProductAttachment_product_id

how could this not been fixed yet? 😦

Read more comments on GitHub >

github_iconTop Results From Across the Web

What is snake case? - TheServerSide.com
Snake case, or snake_case, is a naming convention that allows a developer to create white space between words in code with an underscore....
Read more >
c# - Is there a built in way of using snake case as the naming ...
C# property naming convention is PascalCase. So, CPU is considered three different words. There two solutions you can use is either use [ ......
Read more >
Snake case - Wikipedia
It is a commonly used naming convention in computing, for example for variable and subroutine names, and for filenames. One study has found...
Read more >
Hibernate 5 Naming Strategy Configuration - Baeldung
In this tutorial, we'll see how to configure those naming strategies to map entities to customized table and column names. For readers who...
Read more >
Snake Case or Camel Case? a Guide to Programming ...
The following names are all valid variable names in nearly every programming language: dogName dog_name DOG_NAME dog-name But which one ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found