[Modeling-users] quoting entity and attribute names
Status: Abandoned
Brought to you by:
sbigaret
From: John L. <jo...@vi...> - 2004-06-22 22:59:23
|
Sender: John Lenton <jo...@ma...> Hi all. In a project I'm currently working on there is a class that we'd like to call "User", but we can't call it that and use Modeling in its current state: it's not quoting the names of entities (nor attributes), and user is a reserved word. I looked into it, and I actually got it working, but I then saw that in SQLExpression there's a method `externalNameQuoteCharacter'; is the purpose of this method to be used (something like) this: [ in _addTableJoinsForAlias ] quoteChar =3D self.externalNameQuoteCharacter() str +=3D quoteChar + self._internals.entityExternalNameForAlias(alias) = + quoteChar + ' ' + alias ? What I did was actually add a static method called quotedExternalName, thus: def quotedExternalName(name): return name which I then overrode in PostgresqlSQLExpression, def quotedExternalName(name): return '"%s"' % (name,) and in MySQLSQLExpression, def quotedExternalName(name): return '`%s`' % (name,) (no idea how sqlite nor oracle do this) this and the appropriate modifications where the SQL is computed got me to where I could use the objects in Modeling once the database was created (I didn't run extensive tests, however); on looking into what it took to make mdl_generate_DB_schema quote its chars I came across that method that I'd overlooked before, which gave me pause, because obviously S=E9bastien has already thought about this, so he probably has a preferred way of doing it. So... rounding up what shouldn't've become such a long mail: S=E9bastien, how had you thought you'd do this? --=20 John Lenton (jo...@vi...) -- Random fortune: Ir contra la corriente, casi nunca es conveniente. |