John Lenton
2004-06-22 21:00:08 UTC
Sender: John Lenton <***@martina.fsl.org.ar>
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 = self.externalNameQuoteCharacter()
str += 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ébastien 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ébastien, how had you thought you'd do this?
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 = self.externalNameQuoteCharacter()
str += 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ébastien 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ébastien, how had you thought you'd do this?
--
John Lenton (***@vialibre.org.ar) -- Random fortune:
Ir contra la corriente, casi nunca es conveniente.
John Lenton (***@vialibre.org.ar) -- Random fortune:
Ir contra la corriente, casi nunca es conveniente.