diff --git a/src/codegen.inc.php b/src/codegen.inc.php index 37ed133..8e5a2cb 100644 --- a/src/codegen.inc.php +++ b/src/codegen.inc.php @@ -40,7 +40,7 @@ function supported_tokens() 'table_pkey', 'table_json_kv', - 'root', + 'data_root', 'bitfields', 'diffable', 'diff_removed', diff --git a/tpl/codegen_bundle.twig b/tpl/codegen_bundle.twig index eca23c2..c412d6c 100644 --- a/tpl/codegen_bundle.twig +++ b/tpl/codegen_bundle.twig @@ -11,7 +11,7 @@ import ( "strconv" "strings" - "git.bit5.ru/backend/meta/v2" + "git.bit5.ru/backend/meta/v3" "git.bit5.ru/backend/versioning" "git.bit5.ru/gomodules/metadb" "github.com/go-logr/logr" diff --git a/tpl/macros_struct.twig b/tpl/macros_struct.twig index f62ff49..5926716 100644 --- a/tpl/macros_struct.twig +++ b/tpl/macros_struct.twig @@ -9,7 +9,7 @@ {% endif %} {% endif %} -{% if has_token(s, 'root') %} +{% if has_token(s, 'data_root') %} {{ _self.root_save(s) }} {{ _self.root_delete(s) }} {{ _self.root_save_diff(s) }} @@ -223,7 +223,7 @@ func Save{{ s.name }}Diff(ctx context.Context, dbe metadb.Execer, rec {{ s.name {% macro root_delete(s) %} -{% set delete_by = meta_field(token(s, 'root')) %} +{% set delete_by = meta_field(token(s, 'data_root')) %} func Delete{{ s.name }}(ctx context.Context, dbe metadb.Execer, {{ delete_by|varname }} {{ delete_by.type|go_type }}) error { {%~ for f in s.fields %} {%~ if f.type is array %} @@ -727,7 +727,7 @@ func (s *{{ name|default(s.name) }}) ReadFields(reader meta.Reader) error { {% macro meta_write(o, name) %} func (s *{{ name|default(o.name) }}) Write(writer meta.Writer) error { - if err := writer.BeginAssocContainer({{ get_all_fields(o)|length }}, ""); err != nil { + if err := writer.BeginContainer({{ get_all_fields(o)|length }}, ""); err != nil { return err } if err := s.WriteFields(writer); err != nil { @@ -762,7 +762,7 @@ func (s *{{ name|default(o.name) }}) WriteFields(writer meta.Writer) error { return err } {% elseif type is struct %} - if err := writer.BeginAssocContainer({{ get_all_fields(type)|length }}, "{{ alias }}"); err != nil { + if err := writer.BeginContainer({{ get_all_fields(type)|length }}, "{{ alias }}"); err != nil { return err } if err := {{ fname }}.WriteFields(writer); err != nil { @@ -772,13 +772,13 @@ func (s *{{ name|default(o.name) }}) WriteFields(writer meta.Writer) error { return err } {% elseif type is array %} - if err := writer.BeginContainer(len({{ fname }}), "{{ alias }}"); err != nil { + if err := writer.BeginCollection(len({{ fname }}), "{{ alias }}"); err != nil { return err } for _, v := range {{ fname }} { {{ _self.meta_write_field(type.value, 'v') }} } - if err := writer.EndContainer(); err != nil { + if err := writer.EndCollection(); err != nil { return err } {% else %}