-
Notifications
You must be signed in to change notification settings - Fork 1.9k
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
Better support for NoSQL drivers #4074
Better support for NoSQL drivers #4074
Conversation
* | ||
* @return mixed | ||
*/ | ||
abstract protected function execute(string $sql); | ||
abstract protected function execute($sql); |
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.
As stated, changing the signature may be breaking for existing implementations.
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.
Does the var name $sql
make sense in the context of NoSQL?
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 better name for the context will be $statement
As both QueryClass and $sql string type are BC I'm gonna move the debug toolbar stuff in separate PR |
10c5790
to
8550a96
Compare
DebugToolbar changes are moved to separate pr #4077 |
To preserve BC, how about using a delimiter-based solution to the |
Existing issue: #2969 So it is either preserve BC or push with this one with proper upgrading instructions. |
@paulbalandan I've tried doing it using jsonEncoded array but this all makes it very annoying to write queries as you have to write query as array then encode it each time query is called. The solution here is much more elegant. The only issue is how to get around the BC. IMO it's completely fine merging this one in 4.1 and adding a section in docs on how to do the update. I don't have any clue how many custom driver implementation exist but I don't think at this point there will be a lot of them. So changing this early on and giving users a clear instructions about the change so that we can have better code makes it worthy of a BC change than doing a lot of nasty patches in the future. This will also completely resolve the #2969 |
Also Query Class handling can be resolved without doing a BC by making the query class empty string instead of the hardcoded default value. I can split the Query Class stuff into separate PR and revisit this one once it's merged |
Personally, I'm good with these changes as long as they will be merged to the 4.1 branch with proper instructions for migration and changelog. I think that the alternative of having some helper function to encode/decode the strings every time would be really bad in a long run. |
Ok. I'll go ahead and split the Query Class stuff outside of this one so it can be merged |
Here's the PR for QueryClass #4089 Handling once this one's merged I'll rebase this one on the development |
Now that the Query class is merged, and before you go through the rebase trouble, I had an idea that does not circumvent the breaking nature but might help. Can we define a database-specific |
@MGatner This is not a bad idea but it will require updating all the existing drivers. I'll take a look into it to see what can be done. |
8550a96
to
1a9415a
Compare
@najdanovicivan the |
Wow for real, I thought that was one PHP 8 but your 3v4l seems to suggest it was previous versions as well. In that case we should be in awesome shape, just need a well-thought |
I'll try doing it with BaseStatement class. But in such case we should replace all the exiting Implementations with it. I don't like mixing objects with string. In such case all methods should have type of BaseStatement which will again be BC. But having class for query statements will be very useful especially for NoSQL databases. |
1a9415a
to
1118b4e
Compare
c624425
to
edda844
Compare
edda844
to
e0c72ae
Compare
…tabases use arrays
e0c72ae
to
59dba8b
Compare
@paulbalandan, @MGatner As far as things go with |
In any case the type hint adds problems. Additionally if type of the query is changed to be
|
Any class with a |
@@ -593,11 +593,11 @@ public function addTableAlias(string $table) | |||
/** | |||
* Executes the query against the database. | |||
* | |||
* @param string $sql | |||
* @param mixed $sql |
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.
mixed
means anything. It does not help for code reading.
Can you change it to string|array
?
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.
It may be even needed to use object for such so it can be string|array|object but the main problem is type hint in the method definition. Since merging this one will break all the exiting user implementation where any of these methods have override.
This has been 3 months with no activity. Is this still a desired feature @MGatner @samsonasik @paulbalandan ? |
It's kind of a deadlock. CI4 works very poorly with NoSQL databases, but the changes we would need to make to add support are all breaking (though small). For my NoSQL project (Firestore) I ended up ditching the database layer altogether. My hunch is that because NoSQL implementations don't share a common language that they will be much harder to make "driver-agnostic" and may not be worth integrating into a unified database layer. If that is that case then the focus should be on making Model and Entity classes to maximize support. But I've also worked with @najdanovicivan on some of these NoSQL implementations and he has done a lot of work and had some success, I respect his opinions on the matter. |
I've only used a NoSQL db once, though it was on a pretty large application. My experience then led me to believe the workflow is too different in all but the simplest of cases, to be standardized into a driver-agnostic solution. There are portions that could be included in a NoSQL layer, though I think things would get pretty complex and convoluted if you were to attempt to rearchitect that. Personally, I'm all for simplifying and keeping each in their own lane, so to speak. |
I believe this one can be closed. I found a way to get around this limitation it's not the nice looking solution but at least completely avoids the need to modify all of those files. What I dis was made a custom statement class which implements Stringable where __toString() basically returns serialize($this). So the object can be passed as string to the execute method where it is unserialized to get the query parameters. Maybe better option will be to have some sort of BaseStatement class but it will still be a BC so there is no way to make this one without introducing a BC. |
Closing this for now. Until we can arrive at a solution that meets all of our expectations and reservations, this PR is obviously at a standstill. Thanks for the PR, anyway, @najdanovicivan ! |
Description
Checklist: