Javascript Sequelize在插入单字母大写字母时返回小写字母?

Javascript Sequelize在插入单字母大写字母时返回小写字母?,javascript,mysql,sequelize.js,Javascript,Mysql,Sequelize.js,为什么当我插入一个大写字母时,sequelize插入并返回一个小写字母 示例:我插入“N”,它保存的是“N”而不是“N” 我将其插入以下内容: console.log(toBeInserted) // let's say toBeInserted = "N" db.dataset.findOrCreate({ where:{ name: toBeInserted } }) .spread(function(inserted, created) {

为什么当我插入一个大写字母时,sequelize插入并返回一个小写字母

示例:我插入“N”,它保存的是“N”而不是“N”

我将其插入以下内容:

  console.log(toBeInserted) // let's say toBeInserted = "N" 
  db.dataset.findOrCreate({
    where:{
      name: toBeInserted
    }
  })
  .spread(function(inserted, created) {
    console.log(inserted); //here I get back inserted = "n"
  })
查看SQL数据库,我可以看到存储了
“n”
,而不是
“n”

但一旦输入值包含至少两个字母,sequelize将正确保存:

  console.log(toBeInserted) // toBeInserted = "Hi" 
  db.dataset.findOrCreate({
    where:{
      name: toBeInserted
    }
  })
  .spread(function(inserted, created) {
    console.log(inserted); //here I get back inserted = "Hi"
  })
在数据库中,值
“Hi”
已正确保存

有谁能向我解释为什么会发生这种情况,以及我如何才能防止这种情况发生?我希望sequelize保存值,就像我插入它一样,即如果我想插入“N”(大写字母“N”),它应该保存“N”

编辑: Sequelize能够只保存小写和大写一个字母的输入。然而,一旦创建了findOrCreate()方法,它似乎就无法识别大写字母和小写字母

示例:我有一个空数据库,我创建了以下输入:

console.log(toBeInserted) // toBeInserted = "A" 
      db.dataset.findOrCreate({
        where:{
          name: toBeInserted
        }
      })
      .spread(function(inserted, created) {
        console.log(inserted + " " + created); //here I get back inserted = "A true"
      })
我检查了我的数据库,事实上,数据是用正确的大小写保存在那里的

之后,我将创建以下数据:

console.log(toBeInserted) // toBeInserted = "a" 
      db.dataset.findOrCreate({
        where:{
          name: toBeInserted
        }
      })
      .spread(function(inserted, created) {
        console.log(inserted + " " + created); //here I get back inserted = "a false"
      })

我再次检查数据库,数据没有改变。

这可能不是正在进行此操作的sequelize。我测试了它,没有复制你描述的行为。您确定在toBeInserted变量中发送的是“N”而不是“N”吗?或者可能是数据库中的触发器或其他东西导致了这种情况。

否。我用不同的字母测试了它。结果总是一样的。它将保存标准字母,而不是大写字母。但好吧,我会进一步研究。感谢您的回答。简短的问题:如果您已经创建了一个输入,那么让我们使用sequelize在您的DB中说“N”,并且您希望使用findOrCreate()创建另一个单字母输入,在本例中为“N”。sequelize是否创建新数据集“n”或返回现有数据集“n”?如果我发送“n”但它不存在,它将创建它。