Repository: strapi/strapi

Issue #1198: Tracking Issue - Some words are not handled well for Model names (Pluralization, ect) and reserved words
Created: 2018-05-15T15:28:15Z
Edited by @derrickmehaffy on 2021/03/29
This issue has been converted to a global tracking issue regarding certain english or other language words that fail to work when building models. There are various examples, and for the moment the workarounds mean excluding these words from use and doing things like:
news => newsItem ect

Informations

Node.js version: 8.9.1
npm version: 5.6.0
Strapi version: 3.0.0-alpha.12.1.3
Database: Mongo v3.4.9
Operating system: MacOS 10.13.4

What is the current behavior?
When I create a new content type with a name which have the same plural version, the API generate will loop into a 500
Steps to reproduce the problem

Create a new content type named "Fish" (or "News")
Use a GraphQL IDE or look the terminal


What is the expected behavior?
The problem is that some english words have a specific plural behavior (like child/children) or have the same orthograph
As example : https://github.com/atteo/evo-inflector/blob/master/src/main/java/org/atteo/evo/inflector/English.java#L131
Suggested solutions
Best solution:
Disallow to use "words" which can have an different plural/single mode (ex: fish, news, etc.)
Another solution is to add a flag "all" in front, a.k.a "allFish" (but it add a 2nd behavior so i don't think it's the best solution



 I'm sure that this feature hasn't already been referenced.

Duplicate issue #10710: Unable to update single type if one of its fields is named "where"
Created: 2021-08-08T10:30:30Z
Bug report
Describe the bug
If you have a single type and one of its fields is named where, you cannot update the content (HTTP 400). It seems that the content is not escaped nor sanitized and is being interpreted in SQL queries. Could lead to SQL injections, no?
Steps to reproduce the behavior

Create a single type with a component field named "where"
Go to your single type edit page and fill it with dummy content
Save (it may work there)
Make an edit and save again
A notification is toggled "Invalid input data. Please verify unique constraints"
An error is triggered in console (the one below is my actual one)

Undefined binding(s) detected when compiling SELECT. Undefined column(s): [about_pages_components.about_page_id] query: select distinct `about_pages_components`.* from `about_pages_components` where `field` = ? and `component_type` 
in (?, ?, ?, ?, ?, ?, ?) and `about_pages_components`.`about_page_id` = ? order by `order` asc

Expected behavior
You should be able to name your fields as you want without triggering errors on save. OR at least trigger an error with a more speaking message: I spent 1 hour figuring out what was wrong.
Screenshots
N/A
Code snippets
Single type definition
// api/about-page/about-page.settings.json
{
  "kind": "singleType",
  "collectionName": "about_pages",
  "info": {
    "name": "aboutPage",
    "description": ""
  },
  "options": {
    "increments": true,
    "timestamps": true,
    "draftAndPublish": false
  },
  "pluginOptions": {
    "i18n": {
      "localized": true
    }
  },
  "attributes": {
    "intro": {
      "pluginOptions": {
        "i18n": {
          "localized": true
        }
      },
      "type": "richtext"
    },
    "what": {
      "type": "component",
      "repeatable": false,
      "pluginOptions": {
        "i18n": {
          "localized": true
        }
      },
      "component": "sections.content-block"
    },
  
    "where": {
      "type": "component",
      "repeatable": false,
      "pluginOptions": {
        "i18n": {
          "localized": true
        }
      },
      "component": "sections.content-block"
    }
  }
}
Component used  below
// components/sections/content-block.json
{
  "collectionName": "components_sections_content_blocks",
  "info": {
    "name": "contentBlock",
    "icon": "archive"
  },
  "options": {},
  "attributes": {
    "title": {
      "unique": false,
      "type": "string"
    },
    "content": {
      "unique": false,
      "type": "richtext"
    },
    "picture": {
      "unique": false,
      "model": "file",
      "via": "related",
      "allowedTypes": [
        "files",
        "images",
        "videos"
      ],
      "plugin": "upload",
      "required": false,
      "pluginOptions": {}
    }
  }
}
System

Node.js version: 12.22.1
NPM version: 6.14.12
YARN version: 1.22.10
Strapi version: 3.6.6
Database: tested with both postgres and mysql
Operating system: OSX

Additional context
It may be the same issue with content types (not tested). I guess mongo may not be concerned by this issue.
You may ask yourself "WHY THE HELL DO YOU WANT TO NAME A FIELD WHERE?!". Well: my single type is about page for a next website that presents a project: what, where, when, why, how, how much.
Temp workaround is to change the field name but this issue should be investigated further.

Closing comment (2021-08-09T20:04:44Z): Question is, do we consider this issue a duplicate of #1198 (the tracking issue for words that aren't handled for various reasons)