Domanda

I have some legacy oracle database against which I run inspectdb command. One column in the DB has type NUMBER (without precision and scale) and what I got from django is:

entity_id = models.DecimalField(unique=True, null=True, max_digits=0, decimal_places=-127, blank=True)

If I now run syndb trying to generate schema from the model I will get the error:

Error: One or more models did not validate:
DecimalFields require a "decimal_places" attribute that is a non-negative integer.
DecimalFields require a "max_digits" attribute that is a positive integer.

My question is: how should I modify entity_id type oin the model to get NUMBER generated in oracle?

È stato utile?

Soluzione

I think I figured out the answer. It looks like django is actually very smart and produce this wired values on purpose. The goal is to prevent creation a model from this schema without developer looking at it. This makes sense as in general using NUMBER type without scale and precision leaves django without any clue what actually this field should be. NUMBER is most generic number type and can fit boolean values, integers with and without sign and numbers that should be floating point. This is why educated decision from developer is needed here.

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top