Opened 10 years ago

Closed 11 months ago

#19884 closed Bug (fixed)

Inspectdb on Oracle doesn't produce correct field types

Reported by: Anssi Kääriäinen Owned by: nobody
Component: Database layer (models, ORM) Version: 1.9
Severity: Normal Keywords:
Cc: felisiak.mariusz@… Triage Stage: Accepted
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description (last modified by Mariusz Felisiak)

The test inspectdb.test_field_types() has multiple errors, at least:

  • CharField lengths not correctly inspected (returns double the length of generated field)
  • FloatField not correctly inspected (returns DecimalField with max_digits=-127)
  • DateTimeField is inspected as TimeField (cannot be distinguished)

Getting all these to work correctly will be somewhat hard. So, the suggested short-term fix is to just mark the test as expectedFailure on Oracle. Inspectdb isn't high-priority as the output should be hand-edited in any case.

Change History (14)

comment:1 Changed 10 years ago by Anssi Kääriäinen <akaariai@…>

In f565c6f9994b2559a5164dc709a926eac7ebd5fe:

Marked a test as expected failure. Refs #19884

comment:2 Changed 9 years ago by Shai Berger <shai@…>

In ad975c64fcdf3faa67cacd51665c4f95a2c5b060:

Made Oracle introspect boolean fields

Fixed failing test schema.tests.SchemaTests.test_add_field_temp_default_boolean
Refs #19884

comment:3 Changed 9 years ago by Shai Berger

I just posted PR 2225 which breaks inspectdb.test_field_types() in two: a test_number_field_types() which passes (the PR includes a fix to the FloatField issue), and test_field_types() which does all the rest and is still marked expectedFailure; most of the fields tested there are CharFields under Oracle, so fixing makes little sense indeed.

I would have committed this immediately, except that the breaking of the test method includes some not-entirely-trivial factoring-out of code, and I'd like a second eye on that.

Last edited 9 years ago by Shai Berger (previous) (diff)

comment:4 Changed 9 years ago by Shai Berger <shai@…>

In e9d12bae1e59e51738c11c492c620f56f96106bf:

Made Oracle introspect FloatFields correctly

Broke InspectDBTestCase.test_field_types in two:

  • a test_number_field_types, which now passes on Oracle too
  • a test_field_types, for all non-numeric fields, which is still expected to fail

Also made some pep8 fixes in the tests file. Refs #19884

Thanks Tim Graham for review.

comment:5 Changed 9 years ago by Shai Berger

Description: modified (diff)

comment:6 Changed 9 years ago by Shai Berger <shai@…>

In 0573120cb406066041b0235a3912dc38bc9f10ef:

[1.6.x] Made Oracle introspect boolean fields

Refs #19884

Backport of ad975c64fc from master

comment:7 Changed 9 years ago by Shai Berger <shai@…>

In 5f42c0219550b62e62db6e0f3834671a994e3cd8:

[1.6.x] Made Oracle introspect FloatFields correctly

Broke InspectDBTestCase.test_field_types in two:

  • a test_number_field_types, which now passes on Oracle too
  • a test_field_types, for all non-numeric fields, which is still expected to fail

Also made some pep8 fixes in the tests file. Refs #19884

Thanks Tim Graham for review.

Backport of e9d12ba from master

comment:8 Changed 9 years ago by Shai Berger

#17202 was closed as a duplicate of this bug.

comment:9 Changed 7 years ago by JorisBenschop

Version: 1.41.9

comment:10 Changed 7 years ago by JorisBenschop

Because this problem is still present in 1.9 I updated the version number

comment:11 Changed 6 years ago by Tim Graham <timograham@…>

In 3e43d24:

Refs #19884 -- Added CharField max_length introspection on Oracle.

comment:12 Changed 6 years ago by Mariusz Felisiak

Cc: felisiak.mariusz@… added
Description: modified (diff)

comment:13 Changed 6 years ago by Tim Graham <timograham@…>

In cc0bb07:

Refs #19884 -- Removed DatabaseFeatures.can_introspect_max_length.

Unused (always True) after 3e43d24ad36d45cace57e6a7efd34638577ae744.

comment:14 Changed 11 months ago by Mariusz Felisiak

Description: modified (diff)
Resolution: fixed
Status: newclosed

Both DateTimeField and TimeField use exactly the same datatype i.e. TIMESTAMP, they cannot be distinguished in introspection. IMO, we can treat this ticket as fixed.

Note: See TracTickets for help on using tickets.
Back to Top