home / django_tickets / tickets

tickets: 785

This data as json

id created changetime last_pulled_from_trac stage status component type severity version resolution summary description owner reporter keywords easy has_patch needs_better_patch needs_tests needs_docs ui_ux
785 2005-11-14 03:47:53 2007-12-02 01:21:14 2022-03-06 03:21:39.560674 Accepted closed Database layer (models, ORM) enhancement normal dev duplicate many2many table and legacy databases. hi. I have the following table in a legacy database. {{{ CREATE TABLE `hostgroup_membership` ( `hostid` int(11) NOT NULL default '0', `groupid` int(11) NOT NULL default '0', KEY `hostid` (`hostid`), KEY `groupid` (`groupid`), CONSTRAINT `hostgroup_membership_ibfk_1` FOREIGN KEY (`hostid`) REFERENCES `host` (`id`) ON DELETE CA SCADE, CONSTRAINT `hostgroup_membership_ibfk_2` FOREIGN KEY (`groupid`) REFERENCES `hostgroup` (`id`) ON DEL ETE CASCADE ) ENGINE=InnoDB DEFAULT CHARSET=latin1 COMMENT='Hostgroup membership'; }}} and i would like to use a many2many field in my model to represent this. right now I have 2 limitations. 1. I can not specify the table name. 2. I can not specify the field names and what they map too. what I would like to be able to do is somehow specify the tablename, as well as how the fields map to their respective column names. something like {{{ class Host(meta.model): Groups = meta.manyTomanyfield(Groups, db_table='foo', columns={self_col:'hostid', to_col:'groupid' }) }}} and have the manytomany code do the right thing. nobody Ian@holsman.net   0 1 1 0 0 0
Powered by Datasette · Queries took 0.922ms