-
Notifications
You must be signed in to change notification settings - Fork 13
Conversation
@osaris Feel free to choose anoter assignee if you can't follow and review this PR. |
Hello, Good idea but why don't you enclose names in WHERE / HAVING ? The problem is the same no ? |
@Metalaka sure, my bad. Can you add a basic test for your feature ? |
3ff7f56
to
46d2c64
Compare
Done. |
Thanks, everything looks good to me. Thoughts @hoaproject/hoackers ? |
👍 Looks good to me too |
👍 |
@@ -75,6 +75,7 @@ public function from($source) | |||
*/ | |||
public function __toString() | |||
{ | |||
return 'DELETE FROM ' . $this->_from . parent::__toString(); | |||
return 'DELETE FROM ' . $this->enclose($this->_from) . |
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.
CS:
return
'DELETE FROM ' .
$this->_from .
parent::__toString();
When we have multiple concatenation, we prefer this syntax now :-). Had to be formalized though…
Please, add tests when disabling encoding :-). Good job! |
Also, I was thinking, what about renaming “name” into “symbol”? I reckon it's more abstract and then it might be better because more reusable. Thoughts? |
The problem with "enclose symbol" naming is: |
CS & naming fixed. |
Will review as soon as possible. |
->isEqualTo( | ||
'SELECT a, b FROM foo' | ||
); | ||
} |
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.
The default case is missing?
Look really good @Metalaka. I have a last question. Why not having |
12a4d26
to
282a727
Compare
yes, and it's done :) |
*/ | ||
protected function _enclose($name) | ||
{ | ||
if (0 === preg_match('#\s|\(#', $name)) { |
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.
0 !== preg
nop?
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.
Nop, we enclose the symbol only if there is NO space (alias) or parentheses (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.
Ok got it.
We can also rename name into identifier ? |
@Metalaka: An identifier is most of the time unique. Name is not all the time correct. Symbol is good nop? |
@Metalaka |
Thanks for the typo :) |
So let's go for identifier? |
If you're ok ;) |
Done, tests are green. |
Looks very good. Thanks @Metalaka very good job ! |
$this->_closingSymbol = | ||
(null === $closingSymbol) | ||
? $openingSymbol | ||
: $closingSymbol; |
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->_closingSymbol = $closingSymbol ?: $openingSymbol;
may be better. Going to do it by myself.
Awesome new feature, thank you very much! |
Based on #7 (New feature : enclose names)
This PR will allow use of keywords and resolve some case sensitivity problems for
table
,column
andalias
names in the query builder.The PR don't enclose columns names in
WHERE
andHAVING
clause.The feature is disabled by default.
The
Dml
interface have 3 new methods: enable/disable feature and set symbol.A new
EncolseNames
abstract class is used byWhere
andInsert
classes to provide the code of this 3 methods.I did this PR because PostgreSQL need enclosed columns names to be case sensitive.
PS: maybe a method
isEnabled
is missing ?