Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

181
Visualizações
Why does Sequelize pluralize 'media' to medium

I'm having a really big issue with sequelize trying to give me its best guess at what it thinks my table name is.

I have 3 tables. Properties, Media and a junction table PropertyMedia

For some reason when I do a join query with sequelize it gives me the error

error: column Properties->PropertyMedia.medium_id does not exist

I have done a global search to make sure that I don't have the word medium anywhere and I don't

let Media = sequelize.define('Media', {
    url: DataTypes.STRING,
    isVideo: DataTypes.BOOLEAN
}, { freezeTableName: true, tableName: 'media' });

let PropertyMedia = sequelize.define('PropertyMedia', {
    propertyId: DataTypes.INTEGER,
    mediaId: DataTypes.INTEGER
}, { freezeTableName: true, tableName: 'property_media' });
about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

It doesn't pluralize to "medium", it singularizes to "medium".

That is because "media" is the plural of "medium" and by default table names use the plural and references use the singular, just like you'd have user_id (singular) reference users (plural), so here medium_id (not media_id) is expected to reference media.

It's true that nowadays in English another (usually) uncountable noun "media" emerged from that (probably1 from people forgetting that it does originate from the Latin word medium in plural), but that's a special case Sequelize doesn't know about, really, and also it couldn't discern which of the two nouns you meant.

For this reason, Sequelize has ways to override the singular/plural forms.


1: I'm not an etymologist so please take this with a grain of salt.

about 4 years ago · Juan Pablo Isaza Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda