﻿id	summary	reporter	owner	description	type	status	component	version	severity	resolution	keywords	cc	stage	has_patch	needs_docs	needs_tests	needs_better_patch	easy	ui_ux
23647	Auto-generated PK field name is not easily configurable	TJ Kells	nobody	"Due to the way that Model inherits from ModelBase which takes a non-customizable Options class, there is no way to inject your own naming preferences into the auto generated PK field name. The most common use-case would be for auto-naming your PK fields something more standard to RBDMS like '{modelname}_id'.

I would propose either some refactoring of the Model/ModelBase to allow some hooks for customization (probably fairly difficult) OR probably more realistically how about a logging-style formatting string exposed through the settings. Something like:

  {{{#!python
  # Default
  AUTO_PK_NAME = 'id'

  # Override
  # This string just gets run through a logging-like formatter that exposes (some?) of the 
  # available properties of the Option instance ie - self.model_name, self.module_name etc.
  AUTO_PK_NAME = '%(module_name)s_%(model_name)s_id'
  
  # Possibly a more modern interface setup for .format
  AUTO_PK_NAME = '{module_name}_{model_name}_id'
  }}}

The only area that I can see this being problematic for is that >=1.7 the built-in migrations have the column 'id' effectively hard-coded into them. The _prepare method on the options would potentially have to determine if the model is in 'user space' or not. I'm open to any solutions for working around that issue though.
"	New feature	closed	Database layer (models, ORM)	1.7	Normal	wontfix			Unreviewed	0	0	0	0	0	0
