Problem/Motivation

In the parent, we introduced value objects to define DB schema in place of arrayPI.

Now we can leverage on those to validate the schema.

For example, we cannot set a default value for a serial column. Or define a Null default if notNull is true. Or add a string default to a numeric column. Or add scale and precision properties to a text column. And so forth.

Proposed resolution

Determine the relevant validations and implement them during value objects construction.

Validations todo:

  • add validation to ensure 'length' is passed for varchar columns
  • check primary/unique/foreign keys/index columns match the ones defined for the table
  • ensure primary key is not using nullable columns (or at least one column is not nullable? investigate)
  • when array arguments are passed, ensure they are not empty
  • Only specify size on these types: 'blob', 'float', 'int', 'text'

done in the MR:

  • $binary is only compatible with 'char', 'varchar' or 'text' columns
  • $length is only valid for type 'char', 'varchar' or 'text' fields
  • $unsigned is only valid for type 'int', 'float' and 'numeric' fields
  • can only add $scale and $precision properties to a 'numeric' column
  • $serialize is only compatible with text/blob columns
  • validate value types of array-based properties
  • equivalent of #3082239: Forbid limited length primary and unique keys, allow only in indexes
  • cannot set a default value for a serial column
  • serial column: adding notNull and unsigned is redundant
  • cannot define a Null default if notNull is true
  • cannot add a string default to a numeric column
  • default values should be restricted depending on the column type

Remaining tasks

User interface changes

API changes

Data model changes

Release notes snippet

Issue fork drupal-3558426

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

mondrake created an issue. See original summary.

mondrake’s picture

Issue summary: View changes
mondrake’s picture

Issue summary: View changes

mondrake’s picture

Issue summary: View changes
mondrake’s picture

Issue summary: View changes
mondrake’s picture

Issue summary: View changes
mondrake’s picture

Issue summary: View changes
mondrake’s picture

Issue summary: View changes
mondrake’s picture

Issue summary: View changes
mondrake’s picture

Issue summary: View changes
mondrake’s picture

Issue summary: View changes
mondrake’s picture

mondrake’s picture

Issue summary: View changes
mondrake’s picture

Issue summary: View changes
mondrake’s picture

Category: Feature request » Task

Version: 11.x-dev » main

Drupal core is now using the main branch as the primary development branch. New developments and disruptive changes should now be targeted to the main branch.

Read more in the announcement.

mondrake’s picture

Status: Postponed » Active
mondrake’s picture

Status: Active » Closed (outdated)

Now that this issue is closed, review the contribution record.

As a contributor, attribute any organization that helped you, or if you volunteered your own time.

Maintainers, credit people who helped resolve this issue.

mondrake’s picture