-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Modified AbstractPlatform::getLocateExpression() and ::getSubstringExpression() signatures #3494
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
/** | ||
* {@inheritDoc} | ||
*/ | ||
public function getSubstringExpression($value, $from, $length = null) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is the same as the default implementation.
@@ -96,28 +96,26 @@ public function getTrimExpression(string $str, int $mode = TrimMode::UNSPECIFIED | |||
|
|||
/** | |||
* {@inheritDoc} | |||
* | |||
* SQLite only supports the 2 parameter variant of this function |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is obsolete.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we know since when? We should probably require SQLite to be at least newer than X
@@ -332,7 +332,6 @@ public function testGeneratesSQLSnippets() | |||
self::assertEquals("'1987/05/02' - 10 YEAR", $this->platform->getDateSubYearsExpression("'1987/05/02'", 10)); | |||
self::assertEquals(' WITH RR USE AND KEEP UPDATE LOCKS', $this->platform->getForUpdateSQL()); | |||
self::assertEquals('LOCATE(substring_column, string_column)', $this->platform->getLocateExpression('string_column', 'substring_column')); | |||
self::assertEquals('LOCATE(substring_column, string_column)', $this->platform->getLocateExpression('string_column', 'substring_column')); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a duplicate of the above.
c6e6e20
to
5dd0d27
Compare
* @param int|false $startPos Position to start at, beginning of string by default. | ||
* | ||
* @return string | ||
* @param string $string String to locate the substring in, SQL expression. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This comment is unclear to me - can you rephrase it, please?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is the best I could come up with. Otherwise, it was "The SQL expression which represents the string in which the substring should be located". And this "The SQL expression which represents" will be in a lot of places. Is that better?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Aha, the wording "sql expression" put after the comma did confuse me
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So what do you recommend?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"SQL expression producing the haystack" or something like that?
* | ||
* @return string | ||
* @param string $string String to locate the substring in, SQL expression. | ||
* @param string $substring Substring to locate, SQL expression. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think a better naming could be "needle"
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd keep it closer to the SQL naming, not to PHP. Otherwise, it'd have to be $haystack
and $needle
.
* @return string | ||
* @param string $string String to locate the substring in, SQL expression. | ||
* @param string $substring Substring to locate, SQL expression. | ||
* @param string|null $start Position to start at, SQL expression. Defaults to the beginning of the string. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Alao confusing - why is this a string
? Could we maybe add example usages?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Because it's an SQL expression, not a value (see the test). It could be a reference to another column in the query or a function call or whatever else. There will be a lot of changes like this in the API. Not sure if we want to put an example in every occurrence. What would you suggest?
* | ||
* @return string | ||
* @param string $string String to get a substring in, SQL expression. | ||
* @param string $start Position to start at, SQL expression. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Similar to the above, start
being a string
is confusing to me - we'll need usage examples, IMO
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There are more than 40 methods in this class which accept SQL expressions. We do need some explanation but it doesn't have to be a phpDoc example for every one of them. Maybe it could be some footnote or a link to the online documentation?
I'd like to leave the doc block in a good enough shape and proceed with the code changes. I hope, someone could join later and improve the documentation as well.
@@ -96,28 +96,26 @@ public function getTrimExpression(string $str, int $mode = TrimMode::UNSPECIFIED | |||
|
|||
/** | |||
* {@inheritDoc} | |||
* | |||
* SQLite only supports the 2 parameter variant of this function |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we know since when? We should probably require SQLite to be at least newer than X
No, but at least since 2008. |
5dd0d27
to
297ca6b
Compare
…pression() signatures
297ca6b
to
6c74cf2
Compare
@Ocramius do you still have any concerns or we can proceed? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's proceed 👍
Modified AbstractPlatform::getLocateExpression() and ::getSubstringExpression() signatures
Modified AbstractPlatform::getLocateExpression() and ::getSubstringExpression() signatures
Modified AbstractPlatform::getLocateExpression() and ::getSubstringExpression() signatures
Modified AbstractPlatform::getLocateExpression() and ::getSubstringExpression() signatures
Modified AbstractPlatform::getLocateExpression() and ::getSubstringExpression() signatures
Modified AbstractPlatform::getLocateExpression() and ::getSubstringExpression() signatures
Modified AbstractPlatform::getLocateExpression() and ::getSubstringExpression() signatures
Modified AbstractPlatform::getLocateExpression() and ::getSubstringExpression() signatures
Modified AbstractPlatform::getLocateExpression() and ::getSubstringExpression() signatures
Modified AbstractPlatform::getLocateExpression() and ::getSubstringExpression() signatures
This breaking change is needed to enforce the type of
$start
natively. Additionally, all function arguments that accept an SQL expression will be type-hinted asstring
or?string
, regardless of which SQL type they represent. Function arguments have been rename closer to their SQL analogs.