-
-
Notifications
You must be signed in to change notification settings - Fork 369
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
Error on removing default connection #581
Comments
Thank you, I did the change. However, how you reached that situation? The default connection is added in the |
My connection stay in file Connection.ini with other name, then when I adds support to Active Record, the connection name it is set with the other name.
|
Another point when you remove a connection, it is not necessary to raise an exception case the connection name does not exist. |
danieleteti#581 - Fix error on removing default connection;
I think there is a misunderstanding here. When you define your firedac connection name (let's say "myconnection"), this connection become your "default" connection in the ActiveRecordConnectionRegistry. So, it is compulsory to remove the connection with the default name, because you actually added it. |
@danieleteti ok? |
No, the Check the code, and the samples, it should be clear. Let me know |
@danieleteti I have tested it several times and error always occurs. Disabling unnecessary message error on just calling this method works fine because I have another connection with another name and everything works fine. |
If there is a connection with the name "default", then the system will remove this connection normally, but if it does not exist there is no reason to display an error message, because another connection will be activated as in my case. And in the last case a more specific error in other methods will occur because there is no available connection to the database. |
ok? |
Sorry, I still don't get the point. Can you send me a self contained sample which show the problem? |
@marcelojaloto Skip adding the ActiveRecord Middleware
And then remember to remove default connection in OnAfterAction This works for me :) If you don't like this solution or it can't fit in your setup - then please ignore this. |
@marcelojaloto and @Microcom-Bjarne |
@danieleteti |
As soon as I have some free time, I'll try to send you an example. I'd like it to reflect the following: If you need to remove a DEFAULT connection that doesn't exist, then the RemoveDefaultConnection method assumes that it has already been removed. Right? DMVC already provides this in the RaiseExceptionIfNotAvailable parameter of the RemoveDefaultConnection method. Otherwise, justify me why an exception must be generated that impairs the proper functioning of the system? Does your solution work fine, but will everyone who uses DMVC need to implement it or another solution, if you just passing False in the parameter of the RemoveDefaultConnection method in the OnAfterRouting event call? I really appreciate your contribution, if my PR doesn't get approved I'll try to take it into consideration. I made this contribution hoping to help the entire community. |
Here is modified sample application using 2 databases. Please adjust connections.ini and fddrivers.ini to match your setup. With this setup type - I cannot see a way of using the Middleware setup. Since it will only add the "default" connection. This will get more visible when using BOTH connections in one endpoint. |
@Microcom-Bjarne |
@danieleteti yes - but my current setup allows me to edit the connections.ini file to add or remove connections, without having to stop my api. It will simply reload the connections.ini. |
@Microcom-Bjarne For your particular case, where the connections can be updated without stopping the service, I'd use a timestamp check and reload the "Connections.ini" only if its "last modified" timestamp is changed. Also, deep test the solution (with automated test) in concurrent environment. |
@danieleteti I'll have a look at it - probably over the weekend. |
@Microcom-Bjarne yes, but checking the timestamp allows to reload connections also if something else, apart the connection name, changes (eg. password, hostname, some other configurations). Also what about connection "removing"? I don't know you scenario, maybe this is needed. |
any news on this? |
* Issue #546 was missing from the merge. * #581 - Fix error on removing default connection; * #583 - Fixes bugs 'Invalid class typecast' when using Active Record and Enumerated Type; * Fixes rendering in Swagger documentation for TArray type fields. * It also allows overriding the MapTValueToParam method of the TMVCActiveRecord class.
On the event OnAfterRouting in the class TMVCActiveRecordMiddleware the DMVC framework try to remove default connection, but when you haven't the "default" connection in the file connection.ini then occurr the erro below:
Debugger Exception Notification
Project Server.exe raised exception class Exception with message 'Unknown connection default'.
The solution for this problem it is just to deactivate the param 'RaiseExceptionIfNotAvailable' in the method RemoveDefaultConnection.
Unit: MVCFramework.Middleware.ActiveRecord
Line: 131
@danieleteti
Can I send a pull request for you with the fix?
The text was updated successfully, but these errors were encountered: