-
-
Notifications
You must be signed in to change notification settings - Fork 58
Open
Description
I've got a DB model with some metadata and an arbitrary JSON payload (event data from webhooks) that looks something like this:
struct Event(T) < Model
getter id : String
getter type : String
@[DB::Field(converter: Event::Converter(T))]
getter raw : T
getter created_at : Time
module Converter(T)
extend self
def from_rs(rs : DB::ResultSet)
T.new rs.read(JSON::PullParser)
end
end
endI'm getting this error at compile time:
6 | @[DB::Field(converter: Event::Converter(T))]
^
Error: undefined constant T
I don't know what's causing it. This seems like it should work and the macro seems to be generating the correct code:
> 86 | when "raw"
> 87 | __temp_4290 = true
> 88 | begin
> 89 | __temp_4289 =
> 90 |
> 91 | Event::Converter(T).from_rs(rs)
> 92 |
> 93 | rescue exc
> 94 | ::raise ::DB::MappingException.new(exc.message, self.class.to_s, "raw", cause: exc)
> 95 | end
That's the only place the value[:converter] is used in DB::Serializer.
Metadata
Metadata
Assignees
Labels
No labels