linkyndy/remodel

Plurals automatically in table names?

felixsanz opened this issue · 4 comments

Is remodel converting my "business" table into "businesses" with this piece of code?

import remodel.utils
import remodel.connection
from remodel.models import Model
from remodel.helpers import create_tables, create_indexes
remodel.connection.pool.configure(db="book")

class Business(Model):
has_one = ('BusinessTypes',)

class BusinessTypes(Model):
belongs_to = ('Business',)

create_tables()
create_indexes()

How can i avoid it?

Indeed, when declaring a model, remodel assumes several conventions in order to keep it's interface simple and configuration to a minimum. Here's the line that tableizes the model name.

Currently there is no way to "officially" bypass this convention, but I guess you can monkey-patch self._table after a class has been created. I may think of having a way to explicitly define the table to use, but I also want to keep remodel as simple and configuration-free as possible.

having an option to override it it's almost a must in my opinion

Indeed. I'll think about it. Or you contribute yourself to add this feature :)

This is done, now in the develop branch, soon in a new release on master.