Skip to content

Commit

Permalink
Add a check to ensure created_at and updated_at are Time (#454)
Browse files Browse the repository at this point in the history
If a column is named `created_at` or `updated_at` is not a type `Time?`, then the following occurs:

```There was a problem expanding macro 'macro_4801706624'

Code in lib/granite/src/granite/transactions.cr:82:5

 82 | {% if @type.instance_vars.select { |ivar| ivar.annotation(Granite::Column) }.map(&.name.stringify).includes? "created_at" %}
      ^
Called macro defined in lib/granite/src/granite/transactions.cr:82:5

 82 | {% if @type.instance_vars.select { |ivar| ivar.annotation(Granite::Column) }.map(&.name.stringify).includes? "created_at" %}

Which expanded to:

 > 1 |
 > 2 |       if mode == :create
 > 3 |         @created_at = time.at_beginning_of_second
                                  ^---------------------
```

this simply adds a type check.
  • Loading branch information
kalinon authored Apr 24, 2023
1 parent d9fca08 commit 5c37572
Showing 0 changed files with 0 additions and 0 deletions.

0 comments on commit 5c37572

Please sign in to comment.