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

🐛 CreatedAt behavior default value error #32

Open
1 task done
hiscaler opened this issue Apr 24, 2024 · 1 comment
Open
1 task done

🐛 CreatedAt behavior default value error #32

hiscaler opened this issue Apr 24, 2024 · 1 comment
Assignees
Labels
status:to be verified Needs to be reproduced and validated. type:bug Bug

Comments

@hiscaler
Copy link

No duplicates 🥲.

  • I have searched for a similar issue in our bug tracker and didn't find any solutions.

What happened?

Error

`created_at` DATETIME NOT NULL DEFAULT 'CURRENT_TIMESTAMP',

The right is

`created_at` DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,

Version

entity-behavior v1.3.0
orm v2.7.1,
PHP 8.1

@hiscaler hiscaler added status:to be verified Needs to be reproduced and validated. type:bug Bug labels Apr 24, 2024
@hiscaler
Copy link
Author

Change

namespace Cycle\Database\Schema;

 public function defaultValue(mixed $value): self
  {
      $this->defaultValue = match (true) {
          $value === self::DATETIME_NOW => new Fragment(static::DATETIME_NOW),
          static::isJson($this) !== false && \is_array($value) => Jsoner::toJson($value),
          default => $value
      };

      return $this;
  }

Use Fragment include.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status:to be verified Needs to be reproduced and validated. type:bug Bug
Projects
None yet
Development

No branches or pull requests

3 participants