classAlterationProblems
final class AlterationProblems
Reports what the declared columns of a table rule out in an ALTER TABLE request.
Rule: SQLITE-ALTER-PROBLEMS-001. Column names are compared without regard to ASCII case. Nothing is reported about the columns while the column list of the table is not completely known. A table is taken as STRICT when a declared column of it is. The default of an added column is read by SQLITE-LITERAL-DEFAULT-001: a NOT NULL column needs a default that is not NULL, and a default must be one SQLite can compute when the column is added; a default that is not constant at all is reported by the column definition and not again here. Diagnostics: see AlterAddColumn, AlterDropColumn and AlterRenameColumn. Terminates: one pass over the columns. Source: https://sqlite.org/lang_altertable.html. Status: Implemented.
Methods§
public function occurrences(RelationFact $table, Name $column, Derivation $derivation): ?intCounts the known columns of a table that have a name, or answers null when its column list is not completely known.
Parameters
$table | RelationFact | |
$column | Name | |
$derivation | Derivation |
Returns
?intTest cases 2
Called from 4
- method-call SqlSemantics\Platform\Sqlite\Rules\Definition\AlterationProblems::added() packages/sql-semantics-sqlite/src/Rules/Definition/AlterationProblems.php:94
- method-call SqlSemantics\Platform\Sqlite\Rules\Definition\AlterationProblems::dropped() packages/sql-semantics-sqlite/src/Rules/Definition/AlterationProblems.php:132
- method-call SqlSemantics\Platform\Sqlite\Rules\Definition\AlterationProblems::renamed() packages/sql-semantics-sqlite/src/Rules/Definition/AlterationProblems.php:145
- method-call SqlSemantics\Platform\Sqlite\Rules\Definition\AlterationProblems::renamed() packages/sql-semantics-sqlite/src/Rules/Definition/AlterationProblems.php:148
public function strict(RelationFact $table): boolTells whether the existing table is STRICT, as far as its declared columns show.
Parameters
$table | RelationFact |
Returns
boolTest cases 1
Called from 2
- method-call SqlSemantics\Platform\Sqlite\Rules\Definition\AlterationProblems::slot() packages/sql-semantics-sqlite/src/Rules/Definition/AlterationProblems.php:84
- method-call SqlSemantics\Platform\Sqlite\Rules\Definition\AlterationProblems::added() packages/sql-semantics-sqlite/src/Rules/Definition/AlterationProblems.php:97
public function slot(RelationFact $table, ColumnDefinition $column): OutputSlotAnswers the slot a new column adds to the shape of its table.
Parameters
$table | RelationFact | |
$column | ColumnDefinition |
Returns
Called from 1
Calls 8
- new OutputSlot line 82
- new Known line 84
- method-call TypeRecording::domain() line 84
- new TypeRecording line 84
- method-call AlterationProblems::strict() line 84
- method-call ColumnDefinition::notNull() line 85
- class-const Nullability::NotNull() line 85
- class-const Nullability::Nullable() line 85
public function added(
RelationFact $table,
ColumnDefinition $column,
Derivation $derivation,
): voidReports what rules out adding a column.
Parameters
$table | RelationFact | |
$column | ColumnDefinition | |
$derivation | Derivation |
Called from 1
Calls 23
- method-call AlterationProblems::occurrences() line 94
- method-call Derivation::report() line 95
- new DuplicateColumn line 95
- method-call TypeRecording::domain() line 97
- new TypeRecording line 97
- method-call AlterationProblems::strict() line 97
- new StrictTypeViolation line 99
- new LiteralDefaults line 105
- method-call LiteralDefaults::defaults() line 108
- method-call LiteralDefaults::null() line 109
- method-call LiteralDefaults::literal() line 110
- method-call Limits::nonConstant() line 110
- new Limits line 110
- method-call ColumnDefinition::generated() line 112
- method-call ColumnDefinition::primaryKey() line 114
- class-const AlterationObstacle::PrimaryKeyColumn() line 114
- class-const AlterationObstacle::UniqueColumn() line 115
- class-const GeneratedStorage::Stored() line 116
- class-const AlterationObstacle::StoredColumn() line 116
- method-call ColumnDefinition::notNull() line 117
- class-const AlterationObstacle::NotNullWithoutDefault() line 117
- class-const AlterationObstacle::DefaultNotConstant() line 118
- new AlterationRefused line 122
public function dropped(RelationFact $table, Name $column, Derivation $derivation): voidReports what rules out dropping a column.
Parameters
$table | RelationFact | |
$column | Name | |
$derivation | Derivation |
Called from 1
Calls 6
- method-call AlterationProblems::occurrences() line 132
- method-call Derivation::report() line 134
- new UnknownColumn line 134
- function-call
countline 135 - new AlterationRefused line 136
- class-const AlterationObstacle::LastColumn() line 136
public function renamed(
RelationFact $table,
Name $column,
Name $newName,
Derivation $derivation,
): voidReports what rules out renaming a column.
Parameters
$table | RelationFact | |
$column | Name | |
$newName | Name | |
$derivation | Derivation |
Called from 1
Calls 4
- method-call AlterationProblems::occurrences() line 145
- method-call Derivation::report() line 146
- new UnknownColumn line 146
- new DuplicateColumn line 149
Test cases 6§
Test cases that cover or call this symbol, from the coverage report and from the analyzed test sources.
Dedicated tests 6
AlterationProblemsTest::testDroppedReportsAnUnknownColumnAndTheOnlyColumncallsAlterationProblemsTest::testOccurrencesCountsTheColumnsWithANameWithoutRegardToCasecallsAlterationProblemsTest::testOccurrencesIsNullWhileTheColumnsAreNotKnowncallsAlterationProblemsTest::testRenamedReportsAnUnknownOldNameAndATakenNewNamecallsAlterationProblemsTest::testSlotHasTheRecordedTypeAndTheNullFactOfTheNewColumncallsAlterationProblemsTest::testStrictIsReadFromTheDeclaredColumnscalls
Relations§
Instantiated in 4
- new SqlSemantics\Platform\Sqlite\Statement\Schema\AlterAddColumn::deriveStatement() packages/sql-semantics-sqlite/src/Statement/Schema/AlterAddColumn.php:70
- new SqlSemantics\Platform\Sqlite\Statement\Schema\AlterAddColumn::deriveRelation() packages/sql-semantics-sqlite/src/Statement/Schema/AlterAddColumn.php:83
- new SqlSemantics\Platform\Sqlite\Statement\Schema\AlterDropColumn::deriveStatement() packages/sql-semantics-sqlite/src/Statement/Schema/AlterDropColumn.php:59
- new SqlSemantics\Platform\Sqlite\Statement\Schema\AlterRenameColumn::deriveStatement() packages/sql-semantics-sqlite/src/Statement/Schema/AlterRenameColumn.php:58
Method calls 4
- method-call SqlSemantics\Platform\Sqlite\Statement\Schema\AlterAddColumn::deriveStatement() packages/sql-semantics-sqlite/src/Statement/Schema/AlterAddColumn.php:70
- method-call SqlSemantics\Platform\Sqlite\Statement\Schema\AlterAddColumn::deriveRelation() packages/sql-semantics-sqlite/src/Statement/Schema/AlterAddColumn.php:83
- method-call SqlSemantics\Platform\Sqlite\Statement\Schema\AlterDropColumn::deriveStatement() packages/sql-semantics-sqlite/src/Statement/Schema/AlterDropColumn.php:59
- method-call SqlSemantics\Platform\Sqlite\Statement\Schema\AlterRenameColumn::deriveStatement() packages/sql-semantics-sqlite/src/Statement/Schema/AlterRenameColumn.php:58