myyang / django-pb-model

Protobuf mixin for django model
Other
112 stars 22 forks source link

repeated sintax on proto appears a string instead of empty array after migration #34

Open davidgacc opened 2 years ago

davidgacc commented 2 years ago

i have a proto :

enumx{
   VALUE1 = 0;
   VALUE2 = 0;
}

proto_test{
  repeated enumx variable_test;
}

django model

class modelx(ProtoBufMixin, Model):
  pb_model = proto_test_pb2.model
  pb_2_dj_fields = "__all__"

when i do a migration , I expected as a result to created an empty array on variable_test, however after the migration I got a empty string. How can I solve this problem? .

As you can see the default on migration shows as empty array, however I got a empty string


class Migration(migrations.Migration):

    dependencies = [
        ('bla', '0054_xxxx'),
    ]

    operations = [
        migrations.AddField(
            model_name='modeltext',
            name='variable',
            field=pb_model.fields.ArrayField(default=[]),
            preserve_default=False,
        ),
    ]

result:

{'_state': <django.db.models.base.ModelState at 0x7f94aab7f090>,
 'id': 34fssd35,
 'created_time': datetime.datetime(2022, 1, 3, 14, 1, 15, 528382),
 'updated_time': datetime.datetime(2022, 1, 3, 21, 22, 36, 303208),
 'description': 'automatically created with default configurations',
 'company_id': 232,
 'validity_start_time': datetime.datetime(2022, 1, 3, 0, 0),
 'billing_mode': 1,
 'billing_cycle': 4,
 'fiscal_document_files_to_exclude': ""}
myyang commented 2 years ago

I'm not sure about which field in result, is it 'fiscal_document_files_to_exclude' ?

davidgacc commented 2 years ago

´fiscal_document_files_to_exclude´ is an empty array defined in proto.