classColumnFlags
final class ColumnFlags
Applies the attributes of a column definition in written order, as the server sets its column flags.
Rule: MYSQL-COLUMN-FLAGS-001. The type SERIAL sets NOT NULL (it is BIGINT UNSIGNED NOT NULL AUTO_INCREMENT UNIQUE). NOT NULL, AUTO_INCREMENT, SERIAL DEFAULT VALUE and PRIMARY KEY (or KEY) set NOT NULL; NULL clears it and marks the column explicitly nullable; a later attribute overrides an earlier one (PT_null_column_attr, PT_not_null_column_attr, PT_auto_increment_column_attr, PT_serial_default_value_column_attr, PT_primary_key_column_attr in sql/parse_tree_column_attrs.h; the attribute actions of sql_yacc.yy in 5.6 and 5.7). A primary key column is NOT NULL: "If they are not explicitly declared as NOT NULL, MySQL declares
- them so implicitly (and silently)"; one that is still explicitly NULL is an
error from 5.7 on (MYSQL-TABLE-PROBLEMS-001). A TIMESTAMP column without NULL or NOT NULL is NOT NULL when the server variable explicit_defaults_for_timestamp is OFF and nullable when it is ON; the profile does not carry that variable, so its NULL fact is Dependent. The last of VISIBLE and INVISIBLE decides the visibility. Terminates: one pass over the attributes. Source: https://dev.mysql.com/doc/refman/8.4/en/create-table.html, https://dev.mysql.com/doc/refman/8.4/en/numeric-type-syntax.html (SERIAL), https://dev.mysql.com/doc/refman/8.4/en/server-system-variables.html#sysvar_explicit_defaults_for_timestamp, https://dev.mysql.com/doc/refman/8.4/en/invisible-columns.html. Status: Implemented.
Methods§
public function flags(ColumnSpecification $specification): array{bool, bool, bool}Answers the flags the attributes leave: whether NOT NULL is set, whether NULL is written explicitly and still in force, and whether the column is a primary key by an attribute.
Parameters
$specification | ColumnSpecification |
Returns
array{bool, bool, bool}Test cases 1
Called from 2
- method-call SqlSemantics\Platform\MySql\Rules\TableDefinition\ColumnFlags::nullability() packages/sql-semantics-mysql/src/Rules/TableDefinition/ColumnFlags.php:75
- method-call SqlSemantics\Platform\MySql\Rules\TableDefinition\TableProblems::report() packages/sql-semantics-mysql/src/Rules/TableDefinition/TableProblems.php:65
Calls 12
- method-call ColumnSpecification::dataType() line 51
- class-const ElementaryKind::Serial() line 52
- method-call ColumnSpecification::columnAttributes() line 55
- class-const ColumnKeyword::PrimaryKey() line 59
- class-const ColumnKeyword::Null() line 61
- class-const ColumnKeyword::NotNull() line 62
- class-const ColumnKeyword::AutoIncrement() line 62
- class-const ColumnKeyword::SerialDefaultValue() line 62
- class-const ColumnKeyword::NotSecondary() line 63
- class-const ColumnKeyword::Unique() line 63
- class-const ColumnKeyword::Visible() line 63
- class-const ColumnKeyword::Invisible() line 63
public function nullability(
ColumnSpecification $specification,
bool $keyed = false,
): NullabilityAnswers the NULL fact of a column; $keyed tells whether a table-level primary key includes it.
Parameters
$specification | ColumnSpecification | |
$keyed | bool |
Returns
Test cases 1
Called from 1
Calls 6
- method-call ColumnFlags::flags() line 75
- class-const Nullability::NotNull() line 77
- method-call ColumnSpecification::dataType() line 79
- class-const TemporalKind::Timestamp() line 81
- class-const Nullability::Dependent() line 81
- class-const Nullability::Nullable() line 81
public function invisible(ColumnSpecification $specification): boolTells whether the column is INVISIBLE: the last visibility attribute written says INVISIBLE.
Parameters
$specification | ColumnSpecification |
Returns
boolTest cases 1
Called from 2
- method-call SqlSemantics\Platform\MySql\Rules\TableChange\ColumnChanges::invisible() packages/sql-semantics-mysql/src/Rules/TableChange/ColumnChanges.php:315
- method-call SqlSemantics\Platform\MySql\Rules\TableDefinition\TableDeclaration::split() packages/sql-semantics-mysql/src/Rules/TableDefinition/TableDeclaration.php:150
Calls 3
- method-call ColumnSpecification::columnAttributes() line 90
- class-const ColumnKeyword::Visible() line 91
- class-const ColumnKeyword::Invisible() line 91
Test cases 3§
Test cases that cover or call this symbol, from the coverage report and from the analyzed test sources.
Relations§
Instantiated in 4
- new SqlSemantics\Platform\MySql\Rules\TableChange\ColumnChanges::invisible() packages/sql-semantics-mysql/src/Rules/TableChange/ColumnChanges.php:315
- new SqlSemantics\Platform\MySql\Rules\TableDefinition\TableDeclaration::column() packages/sql-semantics-mysql/src/Rules/TableDefinition/TableDeclaration.php:76
- new SqlSemantics\Platform\MySql\Rules\TableDefinition\TableDeclaration::split() packages/sql-semantics-mysql/src/Rules/TableDefinition/TableDeclaration.php:148
- new SqlSemantics\Platform\MySql\Rules\TableDefinition\TableProblems::report() packages/sql-semantics-mysql/src/Rules/TableDefinition/TableProblems.php:65
Method calls 4
- method-call SqlSemantics\Platform\MySql\Rules\TableChange\ColumnChanges::invisible() packages/sql-semantics-mysql/src/Rules/TableChange/ColumnChanges.php:315
- method-call SqlSemantics\Platform\MySql\Rules\TableDefinition\TableDeclaration::column() packages/sql-semantics-mysql/src/Rules/TableDefinition/TableDeclaration.php:76
- method-call SqlSemantics\Platform\MySql\Rules\TableDefinition\TableDeclaration::split() packages/sql-semantics-mysql/src/Rules/TableDefinition/TableDeclaration.php:150
- method-call SqlSemantics\Platform\MySql\Rules\TableDefinition\TableProblems::report() packages/sql-semantics-mysql/src/Rules/TableDefinition/TableProblems.php:65