[sqlalchemy] bad sql generated for filter_list using firebird

2011-02-28 Thread bigt
generated sql contains invalid reference to table NONE

I don't know where the problem is in Camelot or Sqlalchemy.(latest 0.6
trunk)

I am using a Firebird database.

I think that the sql derives from the following statements

col = getattr( admin.entity, field_name )
query = select([col], distinct=True,
order_by=col.asc()).select_from(table)


ERROR:camelot.view.model_thread.signal_slot_model_thread:exception
caught in model thread while executing get_filters_and_actions -
TableView.set_filters_and_actions
Traceback (most recent call last):
  File /var/git/camelot/camelot/view/model_thread/
signal_slot_model_thread.py, line 57, in execute
result = self._request()
  File /var/git/camelot/camelot/view/controls/tableview.py, line
559, in get_filters_and_actions
return ( admin.get_filters(), admin.get_list_actions() )
  File /var/git/camelot/camelot/view/model_thread/__init__.py, line
57, in wrapper
return original_function(*args, **kwargs)
  File /var/git/camelot/camelot/admin/entity_admin.py, line 364, in
get_filters
return list(filter_generator())
  File /var/git/camelot/camelot/admin/entity_admin.py, line 362, in
filter_generator
yield (filter, filter.get_name_and_options(self))
  File /var/git/camelot/camelot/view/filters.py, line 112, in
get_name_and_options
for value in session.execute(query):
  File /usr/lib/python2.7/site-packages/sqlalchemy/orm/scoping.py,
line 139, in do
return getattr(self.registry(), name)(*args, **kwargs)
  File /usr/lib/python2.7/site-packages/sqlalchemy/orm/session.py,
line 724, in execute
clause, params or {})
  File /usr/lib/python2.7/site-packages/sqlalchemy/engine/base.py,
line 1191, in execute
params)
  File /usr/lib/python2.7/site-packages/sqlalchemy/engine/base.py,
line 1271, in _execute_clauseelement
return self.__execute_context(context)
  File /usr/lib/python2.7/site-packages/sqlalchemy/engine/base.py,
line 1302, in __execute_context
context.parameters[0], context=context)
  File /usr/lib/python2.7/site-packages/sqlalchemy/engine/base.py,
line 1401, in _cursor_execute
context)
  File /usr/lib/python2.7/site-packages/sqlalchemy/engine/base.py,
line 1394, in _cursor_execute
context)
  File /usr/lib/python2.7/site-packages/sqlalchemy/dialects/firebird/
base.py, line 680, in do_execute
cursor.execute(statement, parameters or [])
ProgrammingError: (ProgrammingError) (-204, 'isc_dsql_prepare: \n
Dynamic SQL Error\n  SQL error code = -204\n  Table unknown\n  NONE\n
At line 2, column 19') 'SELECT DISTINCT assets.yr \nFROM assets, None
ORDER BY assets.yr ASC' ()


the table was defined as

create domain D_CURR char (3) default 'EUR' not null;
create domain D_MONEY decimal(10,2) default 0 not null;

recreate table assets(
id integer not null,
yr smallint not null,
cost d_money not null,
curr d_curr not null,
residual d_money not null,
class integer not null,
realised d_money default 0,
constraint pk_asset primary key(id)
);

-- 
You received this message because you are subscribed to the Google Groups 
sqlalchemy group.
To post to this group, send email to sqlalchemy@googlegroups.com.
To unsubscribe from this group, send email to 
sqlalchemy+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/sqlalchemy?hl=en.



Re: [sqlalchemy] bad sql generated for filter_list using firebird

2011-02-28 Thread Michael Bayer

On Feb 28, 2011, at 7:42 AM, bigt wrote:

 generated sql contains invalid reference to table NONE
 
 I don't know where the problem is in Camelot or Sqlalchemy.(latest 0.6
 trunk)
 
 I am using a Firebird database.
 
 I think that the sql derives from the following statements
 
col = getattr( admin.entity, field_name )
query = select([col], distinct=True,
 order_by=col.asc()).select_from(table)
 
 ProgrammingError: (ProgrammingError) (-204, 'isc_dsql_prepare: \n
 Dynamic SQL Error\n  SQL error code = -204\n  Table unknown\n  NONE\n
 At line 2, column 19') 'SELECT DISTINCT assets.yr \nFROM assets, None
 ORDER BY assets.yr ASC' ()
 

this suggests that the variable named table is None.   select_from() is 
usually not needed in any case as the FROM clause is derived from the columns 
and the WHERE clause.


-- 
You received this message because you are subscribed to the Google Groups 
sqlalchemy group.
To post to this group, send email to sqlalchemy@googlegroups.com.
To unsubscribe from this group, send email to 
sqlalchemy+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/sqlalchemy?hl=en.