avro-schema icon indicating copy to clipboard operation
avro-schema copied to clipboard

Consider adding package level constants for types

Open vasiliy-t opened this issue 7 years ago • 2 comments

Problem statement

Schema definition requires type declaration, which is for now is string, e.g.:

{name = "field", type = "int"}

which results in no help from ide preventing dumb typos

Proposed solution

Introduce package level constants, or a sub package for constants for all supported types, e.g.

{name = "field", type = avro_schema.int_type}

this results in a bit more typing, but much safer for usage.

Sub package seems a better solution as it could be scaled in future for example to contain "well known types" like in protobuf

vasiliy-t avatar Oct 23 '18 08:10 vasiliy-t

It does not save us from a typo, because will give nil in the case. So it'll give an error on avro_schema.create() as well as it doing now. Don't see much value.

Totktonada avatar Oct 23 '18 10:10 Totktonada

NB: We can add a metatable that'll give an error on attempt to access a non-existent constant (like it is proposed in https://github.com/tarantool/tarantool/issues/4923).

Totktonada avatar Aug 18 '20 03:08 Totktonada