Use inverted comma for sql statement generation from annotations in core

Created on 21 October 2014, about 10 years ago
Updated 8 March 2024, 9 months ago

Problem/Motivation

Created an entity with the basetable name "group". Got MySQL error several times. However, my module was fully working. What i noticed is that the error comes from the entity annotation.
It is possible to create a table with MySQL when using prereserved names like group, with, in, select, .. if your SQL statment uses inverted comma. The annotation cannot handle this so the sql statement generator (i have no clue how D8 creates sql statments) should automatically do this.

Example:
Faulty D8 Annotation

/**
 * Defines the select entity
 *
 * @ContentEntityType(
 *   id = "select_entity",
 *   label = @Translation("Selector"),
 *   base_table = "select",
 *   entity_keys = {
 *     "id" = "sid",
 *   },
 * )
 */

SQL generates
CREATE TABLE select (ID int); fails

SQL should generate
CREATE TABLE Β΄selectΒ΄ (ID int); works

Proposed resolution

For developer experience all table names should be available so D8 needs to create statements with inverted comma.

Remaining tasks

  1. Check for contra arguments
  2. Implement the new auto generation for statements
✨ Feature request
Status

Closed: duplicate

Version

11.0 πŸ”₯

Component
DatabaseΒ  β†’

Last updated about 4 hours ago

  • Maintained by
  • πŸ‡³πŸ‡±Netherlands @daffie
Created by

πŸ‡©πŸ‡ͺGermany steamx

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

Production build 0.71.5 2024