Opened 17 years ago

Closed 17 years ago

#5740 closed (invalid)

oracle inspectdb CharFields missing "max_length"

Reported by: Carl Karsten <carl@…> Owned by: nobody
Component: inspectdb Version: dev
Severity: Keywords: oracle
Cc: Triage Stage: Unreviewed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no


forgive the flimsy report - I don't have an oracle db to confirm this. I hacked the oracle code up to work with ceODBC, and inspectdb generated
td_fil = models.CharField(blank=True)

which causes syncdb:
"td_fil": CharFields require a "max_length" attribute.


"CharField has an extra required argument, max_length, the maximum length (in characters) of the field. The max_length is enforced at the database level and in Django’s validation."

I don't think my hacks caused that. but it would be really nice if someone could confirm it.

Change History (3)

comment:1 by Carl Karsten <carl@…>, 17 years ago

This may be a bug/issue with ceODBC's cursor.description(). or not. here is some relevant code:


for i, row in enumerate(introspection_module.get_table_description(cursor, table_name)):


# Add max_length for all CharFields.
if field_type == 'CharField' and row[3]:

extra_paramsmax_length = row[3]


field_desc = '%s = models.%s' % (att_name, field_type)
if extra_params:

if not field_desc.endswith('('):

field_desc += ', '

field_desc += ', '.join(% (k, v) for k, v in extra_params.items())

field_desc += ')'
if comment_notes:

field_desc += ' # ' + ' '.join(comment_notes)

yield ' %s' % field_desc

def get_table_description(cursor, table_name):

"Returns a description of the table, with the DB-API cursor.description interface."
sql="SELECT * FROM %s " % quote_name(table_name)
return cursor.description

comment:2 by Carl Karsten <carl@…>, 17 years ago

pretty sure it is a bug with ceODBC's cursor.description()

comment:3 by Carl Karsten <carl@…>, 17 years ago

Resolution: invalid
Status: newclosed

100% sure:

odbc:	('cd_fil', 'STRING', 16, 16, 0, 0, 1)
ceODBC:	('cd_fil', <type 'ceODBC.StringVar'>, None, None, 16, 0, True),
Note: See TracTickets for help on using tickets.
Back to Top