Skip to content
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

feat: DBForge::addField() default value raw SQL string support #5957

Merged
merged 5 commits into from
May 25, 2022

Conversation

kenjis
Copy link
Member

@kenjis kenjis commented May 4, 2022

Needs to rebase after merging #5875

Description
Fixes #4174
Supersedes #4222

  • DBForge::addField() default support RawSql
        $fields = [
            'id' => [
                'type'           => 'INT',
                'constraint'     => 5,
                'unsigned'       => true,
                'auto_increment' => true,
            ],
            'ts' => [
                'type'    => 'TIMESTAMP',
                'default' => new RawSql('CURRENT_TIMESTAMP'),
            ],
        ];
        $forge->addField($fields);

Checklist:

  • Securely signed commits
  • [] Component(s) with PHPDoc blocks, only if necessary or adds value
  • Unit testing, with >80% coverage
  • User guide updated
  • Conforms to style guide

@kenjis kenjis marked this pull request as draft May 4, 2022 05:32
@kenjis kenjis added the database Issues or pull requests that affect the database layer label May 4, 2022
@kenjis kenjis changed the title feat: DBForge::addField() default raw SQL string support feat: DBForge::addField() default raw SQL string support May 4, 2022
@kenjis kenjis added the enhancement PRs that improve existing functionalities label May 4, 2022
@kenjis kenjis changed the title feat: DBForge::addField() default raw SQL string support feat: DBForge::addField() default value raw SQL string support May 4, 2022
@michalsn
Copy link
Member

michalsn commented May 4, 2022

Very good idea. This will allow all such cases to be supported 👍

@kenjis kenjis force-pushed the feat-forge-raw-sql branch 3 times, most recently from 09fd5f0 to 300cd7f Compare May 6, 2022 08:08
@kenjis kenjis marked this pull request as ready for review May 24, 2022 06:50
@kenjis
Copy link
Member Author

kenjis commented May 24, 2022

Rebased.

@kenjis kenjis requested a review from michalsn May 24, 2022 06:52
@kenjis kenjis merged commit 3711b49 into codeigniter4:develop May 25, 2022
@kenjis kenjis deleted the feat-forge-raw-sql branch May 25, 2022 05:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
database Issues or pull requests that affect the database layer enhancement PRs that improve existing functionalities
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Bug: forge cant set default value = CURRENT_TIMESTAMP
2 participants