storm and posgresql no support uppercase

Bug #337562 reported by Hector Miuler Malpica Gallegos
2
Affects Status Importance Assigned to Milestone
Storm
New
Undecided
Unassigned

Bug Description

storm and posgresql no support uppercase

\d "HorometroUpdate"
                 Tabla «public.HorometroUpdate»
       Columna | Tipo | Modificadores
---------------------+--------------------------+---------------
 CodigoUnidad | character varying(50) | not null
 Date | timestamp with time zone | not null
 tz | interval(6) | not null
 HorometroUpdate | integer | not null
 PrevHorometroUpdate | integer |
 UIDL | character varying(50) | not null
Índices:
    «HorometroUpdate_pk» PRIMARY KEY, btree ("CodigoUnidad", "Date")

class HorometroUpdate(object):
    __storm_table__ = "HorometroUpdate"
    __storm_primary__ = "CodigoUnidad", "Date"
    CodigoUnidad = Unicode()
    Date = DateTime()
    tz = TimeDelta()
    HorometroUpdate = Int()
    PrevHorometroUpdate = Int()
    UIDL = Unicode()
    unit = Reference(CodigoUnidad, Unit.codigounidad)
    reportAppUser = Reference(UIDL, ReportAppUser.uidl)

...
...
...
r.count()
[21:05:49.883532] EXECUTE: 'SELECT COUNT(*) FROM HorometroUpdate WHERE HorometroUpdate.CodigoUnidad = %s AND HorometroUpdate."Date" = %s', (u'CSD1', datetime.datetime(2009, 3, 3, 21, 5, 46, 292525, tzinfo=tzoffset('-5', -18000)))
[21:05:49.885037] ERROR: no existe la relación «horometroupdate»

---------------------------------------------------------------------------
ProgrammingError Traceback (most recent call last)

/home/miuler/<ipython console> in <module>()

/home/share/Almacen/Instaladores-Linux/cversiones/bzr/storm/storm/store.pyc in count(self, expr, distinct)
   1205 def count(self, expr=Undef, distinct=False):
   1206 """Get the number of objects represented by this ResultSet."""
-> 1207 return int(self._aggregate(Count(expr, distinct)))
   1208
   1209 def max(self, expr):

/home/share/Almacen/Instaladores-Linux/cversiones/bzr/storm/storm/store.pyc in _aggregate(self, expr, column)
   1194 else:
   1195 select = Select(expr, tables=Alias(self._select))
-> 1196 result = self._store._connection.execute(select)
   1197 value = result.get_one()[0]
   1198 variable_factory = getattr(column, "variable_factory", None)

/home/share/Almacen/Instaladores-Linux/cversiones/bzr/storm/storm/databases/postgres.pyc in execute(self, statement, params, noresult)
    255 return result
    256
--> 257 return Connection.execute(self, statement, params, noresult)
    258
    259 def raw_execute(self, statement, params):

/home/share/Almacen/Instaladores-Linux/cversiones/bzr/storm/storm/database.pyc in execute(self, statement, params, noresult)
    201 params = state.parameters
    202 statement = convert_param_marks(statement, "?", self.param_mark)
--> 203 raw_cursor = self.raw_execute(statement, params)
    204 if noresult:
    205 self._check_disconnect(raw_cursor.close)

/home/share/Almacen/Instaladores-Linux/cversiones/bzr/storm/storm/databases/postgres.pyc in raw_execute(self, statement, params)
    265 # psycopg breaks with unicode statements.

    266 statement = statement.encode("UTF-8")
--> 267 return Connection.raw_execute(self, statement, params)
    268
    269 def to_database(self, params):

/home/share/Almacen/Instaladores-Linux/cversiones/bzr/storm/storm/database.pyc in raw_execute(self, statement, params)
    282 args = (statement,)
    283 try:
--> 284 self._check_disconnect(raw_cursor.execute, *args)
    285 except Exception, error:
    286 trace("connection_raw_execute_error", self, raw_cursor,

/home/share/Almacen/Instaladores-Linux/cversiones/bzr/storm/storm/database.pyc in _check_disconnect(self, function, *args, **kwargs)
    323 """Run the given function, checking for database disconnections."""
    324 try:
--> 325 return function(*args, **kwargs)
    326 except DatabaseError, exc:
    327 if self.is_disconnection_error(exc):

ProgrammingError: no existe la relación «horometroupdate»

Revision history for this message
Hector Miuler Malpica Gallegos (miuler) wrote :

Storm tiene problemas con las tablas que están en mayuscula, esto es lo que ejecuta:

[21:05:49.883532] EXECUTE: 'SELECT COUNT(*) FROM HorometroUpdate WHERE HorometroUpdate.CodigoUnidad = %s AND HorometroUpdate."Date" = %s', (u'CSD1', datetime.datetime(2009, 3, 3, 21, 5, 46, 292525, tzinfo=tzoffset('-5', -18000)))

y el sistema debería generar esto:
[21:05:49.883532] EXECUTE: 'SELECT COUNT(*) FROM "HorometroUpdate" WHERE "HorometroUpdate"."CodigoUnidad" = %s AND "HorometroUpdate"."Date" = %s', (u'CSD1', datetime.datetime(2009, 3, 3, 21, 5, 46, 292525, tzinfo=tzoffset('-5', -18000)))

Revision history for this message
James Henstridge (jamesh) wrote :

So there are two competing issues here:
 1. table and column names that contain upper case must be quoted to be recognised by PostgreSQL.
 2. table and column names consisting of all lower case can be referenced by unquoted strings containing upper case. I know for a fact that there is code inside Launchpad that uses this fact.

So a simple fix of quoting all table and column names containing upper case would break compatibility for a large project.

One option might be to define a str subclass that always gets compiled to a quoted identifier and use that. This might be a bit fragile though, since it would be necessary to make sure the object doesn't get converted back to a plain string.

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.