Hello,

    You can get this new version of the patch at the following URL:
    http://www.xsoli.com/sqlobject-inheritance-2a.patch

    Here is a new patch that add simple inheritance to SQLObject 0.8.1.
    For those who tried one of my patch, here are the modification from the first and second patch:
    With this patch, the following code:
class Person(SQLObject):
    _inheritable = 1        # I want this class to be inherited
    firstName = StringCol()
    lastName = StringCol()

class Employee(Person):
    _inheritable = 0        # If I don't want this class to be inherited
    position = StringCol()
    will generate the following tables:
CREATE TABLE person (
    id INT PRIMARY KEY,
    child_name TEXT,
    first_name TEXT,
    last_name TEXT
);

CREATE TABLE employee (
    id INT PRIMARY KEY,
    position TEXT
)
 
    A new class attribute '_inheritable' is added.  When this new attribute is set to 1, the class is marked 'inheritable' and a new colomns will automatically be added: childName (TEXT).

    Each class that inherits from a parent class will get the same ID as the parent class.  So, there is no need to keep track of parent ID and child ID as they are the same.

    The column childName will contain the name of the child class (for exemple 'Employee').  This will permit to a class to always return its child class if available (a person that is also an employee will always return an instance of the employee class).

    For exemple, the following code:
p = Person(firstName='John', lastName='Doe')
e = Employee(firstName='Jane', lastName='Doe', position='Chief')
p2 = Person(1)

    Will create the following data in the database:
Person
id
child_name
first_name
last_name
0
Null
John
Doe
1
Employee
Jane
Doe

Employee
id
position
1
Chief

    You will still be able to ask for the attribute normally:
e.firstName will return Jane and setting it will write the new value in the person table.

    If you use p2, as p2 is a person object, you will get an employee object.
person(0) will return a Person instance and will have the following attributes: firstName and lastName
person(1) or employee(1) will each return the same Employee instance and will have the following attributes: firstName, lastName and position

    Also, deleting a person or an employee that are linked will destroy both entries as one would expect.

    The SQLObject q magic also work.  Using this select are valid:
Employee.select(Employee.q.firstName == 'Jane' & Employee.q.position == 'Chief') will return Jane Doe
Employee.select(Person.q.firstName == 'Jane' & Employee.q.position == 'Chief') will return Jane Doe
Employee.select(Employee.q.lastName == 'Doe') will only return Jane Doe (as Joe isn't an employee)
Person.select(Person.q.lastName == 'Doe') will return both entries

    The SQL where clause will contain additional clauses when used with 'inherited' classes.  These clauses are the link between the id and the parent id.  This will look like the following request:
    SELECT employee.id, employee.id, employee.first_name, employee.last_name, from employee FROM person, employee WHERE person.first_name = 'Jane' AND employee.position = 'Chief' AND person.id = employee.id

    Some limitation or notice about this patch:

Thanks,
Daniel Savard
XSOLI Inc.