Quantcast
Channel: Issues for Drupal core
Viewing all articles
Browse latest Browse all 293343

Use inverted comma for sql statement generation from annotations in core

$
0
0

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

Viewing all articles
Browse latest Browse all 293343

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>