I remember reading that SO does not support multi column keys, but does
that mean explicitly at the database level?
I am working with some legacy tables that do not have any explicit
primary keys defined for a table but they do have implicit keys, in the
sense that they are good about unique values, though in some cases those
keys are multivalued.
My problem is, for a class like this:
class Acct(SQLObject):
trsAcctNo = StringCol(length=7, dbName='TRS_ACCT_NO')
trsSeqNo = StringCol(length=6, dbName='TRS_SEQ_NO')
trsSeqSub = StringCol(length=2, dbName='TRS_SEQ_SUB')
trsAmt = FloatCol(dbName='TRS_AMT')
The true primary key is the concatenation of the first the fields.
I am really just interested in queries, so creating tables via SO
doesn't matter to me and even updates aren't so important in this case.
Could I do something like override the getter for the id column and
return the concatenation of the first 3 fields? Maybe like:
def _get_id(self):
return self.trsAcctNo+self.trsSeqNo+self.trsSeqSub
And if I did this, what would I specify for the idName in the sqlmeta class?
As it stands now, because the column I specify as the id column is not a
unique column by itself, I get the same row over and over when I run a
Acct.select().
An alternative approach would be to create a view of the table at the
database level with all of the same fields, but add a single column
which would be the 3 columns colmbined as a single field primary key.
Regards,
Aaron
-------------------------------------------------------------------------
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
_______________________________________________
sqlobject-discuss mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/sqlobject-discuss