feat: Allow adding another database group by daycry · Pull Request #34 · codeigniter4/settings · GitHub
Skip to content

feat: Allow adding another database group#34

Merged
kenjis merged 11 commits into
codeigniter4:developfrom
daycry:develop
Sep 21, 2022
Merged

feat: Allow adding another database group#34
kenjis merged 11 commits into
codeigniter4:developfrom
daycry:develop

Conversation

@daycry

@daycry daycry commented Aug 31, 2022

Copy link
Copy Markdown
Contributor
  • Allow adding another database group

- Allow adding another database group
@kenjis

kenjis commented Aug 31, 2022

Copy link
Copy Markdown
Member

@kenjis

kenjis commented Aug 31, 2022

Copy link
Copy Markdown
Member

You must GPG-sign your work, certifying that you either wrote the work or otherwise have the right to pass it on to an open-source project. See Developer's Certificate of Origin.

See https://github.com/codeigniter4/CodeIgniter4/blob/develop/contributing/pull_request.md#signing

@daycry

daycry commented Aug 31, 2022

Copy link
Copy Markdown
Contributor Author

I tried it, but always return an error message.

@kenjis

kenjis commented Aug 31, 2022

Copy link
Copy Markdown
Member

The basic steps:
https://github.com/codeigniter4/CodeIgniter4/blob/develop/contributing/signing.md#secure-signing

What did you do?
and what did you get? the exact error message?

@daycry

daycry commented Aug 31, 2022

Copy link
Copy Markdown
Contributor Author

Done. Key imported

@daycry

daycry commented Aug 31, 2022

Copy link
Copy Markdown
Contributor Author

Who Can review this changes? I think that are interesting changes.

Comment thread composer.json Outdated
Comment thread phpunit.xml.dist
Comment thread src/Database/Migrations/2021-07-04-041948_CreateSettingsTable.php Outdated
@kenjis

kenjis commented Sep 1, 2022

Copy link
Copy Markdown
Member

@kenjis kenjis changed the title - Improvements Allow adding another database group Sep 1, 2022
@kenjis kenjis changed the title Allow adding another database group feat: Allow adding another database group Sep 1, 2022
@MGatner

MGatner commented Sep 1, 2022

Copy link
Copy Markdown
Member

@daycry the development kit here does need to be updated but that should happen in a separate PR. I will try to get that done today, but please remove those changes from this PR in the meantime.

I will wait to review, but generally this looks like a desirable feature!

@kenjis

kenjis commented Sep 1, 2022

Copy link
Copy Markdown
Member

@MGatner I sent #35

@kenjis

kenjis commented Sep 1, 2022

Copy link
Copy Markdown
Member

@daycry We have updated the development kit. Please rebase to resolve conflicts and remove unneeded changes in this PR.
See https://github.com/codeigniter4/CodeIgniter4/blob/develop/contributing/workflow.md#updating-your-branch

@daycry

daycry commented Sep 1, 2022

Copy link
Copy Markdown
Contributor Author

Ok, I Will do It.

Although I have seen that the changes you have made in composer and phpunit are the same as I have done, I will delete my changes and create the pull request again.

thank you!

@daycry

daycry commented Sep 1, 2022

Copy link
Copy Markdown
Contributor Author

I do the signed commit.

@MGatner MGatner left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looking good! Some design thoughts. Also please do try some tests - there should be some there that make a decent starting point.

Comment thread src/Config/Settings.php
use CodeIgniter\Settings\Handlers\DatabaseHandler;

class Settings
class Settings extends BaseConfig

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure if there were recursion issues or something why Lonnie didn't originally make this an actual Config class. @lonnieezell you available to comment?

Comment thread src/Database/Migrations/2021-07-04-041948_CreateSettingsTable.php Outdated

namespace CodeIgniter\Settings\Database\Migrations;

use CodeIgniter\Config\BaseConfig;

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is okay to require the Config to be ours (or an extension thereof):

Suggested change
use CodeIgniter\Config\BaseConfig;
use CodeIgniter\Settings\Config\Settings;


namespace CodeIgniter\Settings\Database\Migrations;

use CodeIgniter\Config\BaseConfig;

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
use CodeIgniter\Config\BaseConfig;
use CodeIgniter\Settings\Config\Settings;


class CreateSettingsTable extends Migration
{
private BaseConfig $config;

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
private BaseConfig $config;
private Settings $config;

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Never mind, see below: this can be dropped altogether.


class AddContextColumn extends Migration
{
private BaseConfig $config;

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
private BaseConfig $config;
private Settings $config;

Comment thread src/Database/Migrations/2021-11-14-143905_AddContextColumn.php Outdated
Comment thread src/Handlers/DatabaseHandler.php Outdated
@daycry

daycry commented Sep 2, 2022 via email

Copy link
Copy Markdown
Contributor Author

@MGatner MGatner left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The error handling is probably a case for going with BaseConnection instead of BaseBuilder, but since these are "things really went wrong" situations it is more of a debug so I'm okay with it. Let's see what @kenjis thinks.

@MGatner MGatner requested a review from kenjis September 5, 2022 11:35
@kenjis

kenjis commented Sep 21, 2022

Copy link
Copy Markdown
Member

@MGatner What do you mean with the error handling?

@kenjis

kenjis commented Sep 21, 2022

Copy link
Copy Markdown
Member

This PR looks good. I'm merging for now.

@kenjis kenjis merged commit c648852 into codeigniter4:develop Sep 21, 2022
@kenjis kenjis added the enhancement New feature or request label Sep 21, 2022
@MGatner

MGatner commented Sep 21, 2022

Copy link
Copy Markdown
Member

@kenjis I meant the way the RuntimeExceptions still rely on BaseConnection instead of BaseBuilder. Either way it isn't proper adherence to Law of Demeter, but in this case the connection is only needed for error handling so isn't really a dependency. It's also an issue with our database classes, that errors are not accessible from the class where they occurred.

So yes: this is good, thanks for merging!

@MGatner

MGatner commented Sep 21, 2022

Copy link
Copy Markdown
Member

(In the future though we should probably be squashing PRs like this that have "train of thought" commits.)

@daycry

daycry commented Oct 11, 2022 via email

Copy link
Copy Markdown
Contributor Author

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants