classLiteralDefaults
final class LiteralDefaults
Reads the DEFAULT clauses of a column the way ALTER TABLE ADD COLUMN does.
Rule: SQLITE-LITERAL-DEFAULT-001. When a column is added, SQLite computes its default once, with the routine that turns a literal expression into a value: it looks through parentheses, a unary plus or minus and a CAST, and accepts a number, a string, a BLOB, NULL, TRUE, FALSE and the identifier after DEFAULT; everything else, CURRENT_TIME, CURRENT_DATE and CURRENT_TIMESTAMP included, is "a column with non-constant default". A default written as the literal NULL, in parentheses or not, is read as no default at all. Terminates: each step removes one wrapper of a finite expression. Source: https://sqlite.org/lang_altertable.html#alter_table_add_column (and sqlite3AlterFinishAddColumn() in alter.c and valueFromExpr() in vdbemem.c of the release). Status: Implemented.
Methods§
public function defaults(list<ColumnConstraint> $constraints): list<DefaultLiteral|DefaultExpression|DefaultWord>Answers the DEFAULT clauses of a column in written order.
Parameters
$constraints | list<ColumnConstraint> |
Returns
Test cases 3
public function null(DefaultLiteral|DefaultExpression|DefaultWord $default): boolTells whether a DEFAULT clause is the literal NULL that SQLite reads as no default.
Parameters
Returns
boolTest cases 1
Called from 1
Calls 1
- method-call LiteralDefaults::core() line 67
public function literal(DefaultLiteral|DefaultExpression|DefaultWord $default): boolTells whether SQLite computes a value from a DEFAULT clause when the column is added.
Parameters
Returns
boolCalled from 1
Calls 1
- method-call LiteralDefaults::constant() line 79
public function constant(Scalar $expression): boolTells whether an expression is a literal under parentheses, signs and casts.
Parameters
$expression | Scalar |
Returns
boolTest cases 1
Called from 1
Calls 3
- class-const UnaryOperator::Plus() line 90
- class-const UnaryOperator::Minus() line 90
- function-call
str_starts_withline 97
Test cases 5§
Test cases that cover or call this symbol, from the coverage report and from the analyzed test sources.
Dedicated tests 5
LiteralDefaultsTest::testConstantLooksThroughParenthesesSignsAndCastscallsLiteralDefaultsTest::testCoreRemovesTheParenthesescallsLiteralDefaultsTest::testDefaultsAnswersTheDefaultClausesInWrittenOrdercallsLiteralDefaultsTest::testLiteralTellsTheDefaultsSqliteComputesWhenAColumnIsAddedcallsLiteralDefaultsTest::testNullIsTheLiteralNullWithOrWithoutParenthesescalls
Relations§
Instantiated in 1
Method calls 3
- method-call SqlSemantics\Platform\Sqlite\Rules\Definition\AlterationProblems::added() packages/sql-semantics-sqlite/src/Rules/Definition/AlterationProblems.php:108
- method-call SqlSemantics\Platform\Sqlite\Rules\Definition\AlterationProblems::added() packages/sql-semantics-sqlite/src/Rules/Definition/AlterationProblems.php:109
- method-call SqlSemantics\Platform\Sqlite\Rules\Definition\AlterationProblems::added() packages/sql-semantics-sqlite/src/Rules/Definition/AlterationProblems.php:110