Re: How to get oracle NUMBER with syncdb

2012-10-17 Thread Jani Tiainen

17.10.2012 14:28, Michał Nowotka kirjoitti:

Even if I don't mention inspectdb the problem still persists.
The basic question is how to map oracle NUMBER type from some model type.
If I understand this correctly, currently this is not supported.
In principle models.FloatField should handle it and give and option to
decide if the filed should me mapped into FLOAT or NUMBER.

But maybe (this requires some more oracle knowledge) that FLOAT is
just an alias of NUMBER(38,19).



Actually that is incorrect. Oracle equivalent for python float (and 
Django FloatField) is BINARY_FLOAT.


Oracle NUMBER must map to DecimalField with correct precisions and 
numbers. Since property of NUMBER field is to preserve accuracy (it's 
fixed point field).


Though there is not anyway to do it simply without knowledge of 
underlying database and context of your application. What you can do is 
create your own custom field and use just a NUMBER datatype.


See https://docs.djangoproject.com/en/1.4/howto/custom-model-fields/ for 
more information.


--
Jani Tiainen

- Well planned is half done and a half done has been sufficient before...

--
You received this message because you are subscribed to the Google Groups "Django 
users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: How to get oracle NUMBER with syncdb

2012-10-17 Thread Michał Nowotka
Anyway, Jani, thank you for pointing me to the software, I will give it a try.

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: How to get oracle NUMBER with syncdb

2012-10-17 Thread Michał Nowotka
Even if I don't mention inspectdb the problem still persists.
The basic question is how to map oracle NUMBER type from some model type.
If I understand this correctly, currently this is not supported.
In principle models.FloatField should handle it and give and option to
decide if the filed should me mapped into FLOAT or NUMBER.

But maybe (this requires some more oracle knowledge) that FLOAT is
just an alias of NUMBER(38,19).

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: How to get oracle NUMBER with syncdb

2012-10-17 Thread Jani Tiainen

17.10.2012 12:15, Michał Nowotka kirjoitti:

Hello,
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?

BTW. Don't you think this is bug to generate model with inspectdb
which is invalid if you run it using syncdb?

Kind regards,
Michael Nowotka



https://docs.djangoproject.com/en/1.4/ref/django-admin/#django-admin-inspectdb

As you may have read that, it states few things:

"This feature is meant as a shortcut, not as definitive model 
generation.". No, there is no guarantee that syncdb will work. There 
might be fields that canno't be mapped correctly and particulary order 
might be totally off.


And on top of that, there is note that inspectdb works (only) with 
PostgreSQL, MySQL and SQLite. No Oracle mentioned.


When I mapped my models from Oracle I used 3rd party tool MyGeneration 
[1] to generate mappings. It was more easier and I had full control over 
how to map database to Django ORM. Though ordering problem still was 
persstent but at least I got models more or less right from the very 
beginning.



[1] http://sourceforge.net/projects/mygeneration/



--
Jani Tiainen

- Well planned is half done and a half done has been sufficient before...

--
You received this message because you are subscribed to the Google Groups "Django 
users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



How to get oracle NUMBER with syncdb

2012-10-17 Thread Michał Nowotka
Hello,
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?

BTW. Don't you think this is bug to generate model with inspectdb
which is invalid if you run it using syncdb?

Kind regards,
Michael Nowotka

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.