classMode
final class Mode
implements Mode
@visibility public.The parts of a MySQL session's sql_mode that change how SQL text is read.
Five modes change tokenization: ANSI_QUOTES, PIPES_AS_CONCAT, HIGH_NOT_PRECEDENCE, NO_BACKSLASH_ESCAPES and IGNORE_SPACE. A combination mode such as ANSI turns on the ones it includes. Every other mode name, such as STRICT_TRANS_TABLES or REAL_AS_FLOAT, is read and not recorded: it changes no token, and a fact that depends on it names the session state it is missing. Source: https://dev.mysql.com/doc/refman/8.4/en/sql-mode.html.
\SqlSemantics\Platform\MySql\Mode::fromString('STRICT_TRANS_TABLES,ansi_quotes,NO_BACKSLASH_ESCAPES')->toString() // => 'ANSI_QUOTES,NO_BACKSLASH_ESCAPES'$semantics = new \SqlSemantics\Platform\MySql\Semantics(null, \SqlSemantics\Platform\MySql\Mode::fromString('ANSI_QUOTES'));
$semantics->analyze('SELECT "order" FROM t')->toString() // => 'SELECT `order` FROM t'Properties§
public bool $ansiQuotes = falsepublic bool $pipesAsConcat = falsepublic bool $highNotPrecedence = falsepublic bool $noBackslashEscapes = falsepublic bool $ignoreSpace = falseMethods§
public function __construct(
public bool $ansiQuotes = false,
public bool $pipesAsConcat = false,
public bool $highNotPrecedence = false,
public bool $noBackslashEscapes = false,
public bool $ignoreSpace = false,
)Parameters
$ansiQuotes | bool | Whether double quotes delimit identifiers instead of strings |
$pipesAsConcat | bool | Whether `||` is string concatenation instead of `OR` |
$highNotPrecedence | bool | Whether `NOT` binds as tightly as `!` |
$noBackslashEscapes | bool | Whether a backslash in a string is an ordinary character |
$ignoreSpace | bool | Whether a function name may be followed by spaces before its parenthesis |
public static function fromString(string $modes): selfReads a sql_mode value as SELECT @@SESSION.sql_mode answers it.
Parameters
$modes | string |
Returns
selfTest cases 20
StatementBench::benchLegacySelectcallsPrimaryRuleTest::testSimpleExpressionAppliesCollateAndConcatenationFromTheLeftcallsPrimaryRuleTest::testUnitLowersTheTightNegationOfHighNotPrecedencecallsLiteralRuleTest::testDecodeFollowsTheEscapeSettingOfTheProfilecallsLiteralRuleTest::testEscapesFollowsTheProfilecallsModeTest::testFromStringExpandsCombinationModescallsModeTest::testFromStringReadsTheLexicalModesWhateverTheirCasecallsModeTest::testToStringFixesTheProfileLexicalSettingscallsModeTest::testToStringSpellsTheRecordedModesInCanonicalOrdercallsPlatformTest::testLeafKeysReadTokensUnderTheLexicalSettingscallsPlatformTest::testParserIsCreatedOncePerProfilecallsPlatformTest::testProfileFixesAShippedReleaseUnderAModecallsNotTest::testDeriveScalarRejectsTheLowNegationUnderHighNotPrecedencecallsBinaryCastTest::testRenderCastsAPrefixOperandWithoutParenthesescallsConcatenationTest::testDeriveScalarIsABinaryStringWhenAnOperandIscallsConcatenationTest::testRenderAssociatesToTheLeftcallsEscapeRuleTest::testUnderFollowsTheProfileOfAnAnalysiscallsStringLiteralTest::testRenderKeepsBackslashesUnderTheVerbatimRulecallsTextTest::testLoweredTextFollowsTheEscapeRuleOfTheProfilecallsSelectTest::testRenderReadsADoubleQuotedNameUnderAnsiQuotescalls
Calls 2
- static-call SqlMode::fromString() line 50
- new
selfline 52
public function toString(): stringAnswers the recorded modes in the canonical spelling the language profile keeps.
Returns
stringTest cases 1
Called from 1
Calls 1
- function-call
implodeline 67
Test cases 20§
Test cases that cover or call this symbol, from the coverage report and from the analyzed test sources.
Dedicated tests 4
Other tests reaching this symbol 16
StatementBench::benchLegacySelectcallsPrimaryRuleTest::testSimpleExpressionAppliesCollateAndConcatenationFromTheLeftcallsPrimaryRuleTest::testUnitLowersTheTightNegationOfHighNotPrecedencecallsLiteralRuleTest::testDecodeFollowsTheEscapeSettingOfTheProfilecallsLiteralRuleTest::testEscapesFollowsTheProfilecallsPlatformTest::testLeafKeysReadTokensUnderTheLexicalSettingscallsPlatformTest::testParserIsCreatedOncePerProfilecallsPlatformTest::testProfileFixesAShippedReleaseUnderAModecallsNotTest::testDeriveScalarRejectsTheLowNegationUnderHighNotPrecedencecallsBinaryCastTest::testRenderCastsAPrefixOperandWithoutParenthesescallsConcatenationTest::testDeriveScalarIsABinaryStringWhenAnOperandIscallsConcatenationTest::testRenderAssociatesToTheLeftcallsEscapeRuleTest::testUnderFollowsTheProfileOfAnAnalysiscallsStringLiteralTest::testRenderKeepsBackslashesUnderTheVerbatimRulecallsTextTest::testLoweredTextFollowsTheEscapeRuleOfTheProfilecallsSelectTest::testRenderReadsADoubleQuotedNameUnderAnsiQuotescalls