Hi Raymond,
The search is working and its much better than anything I did so far.
:-) But I'm hitting a few issues with the way its implemented.
For example in the System mapper we have this:
'Arch':column_property(select([arch_table.c.arch]).correlate(arch_table).label('Arch'),deferred
= True),
even though we also have the following as well:
'arch':relation(Arch,
order_by=[arch_table.c.arch],
secondary=system_arch_map,
backref='systems'),
This extra column is causing the following error to happen at times.
I'm not sure which code is triggering it yet ( I do know its in the csv
import code, possibly when it fails to import a system for one reason or
another it calls expire or expunge).
OperationalError: (OperationalError) (1054, "Unknown column 'arch.arch'
in 'field list'") u'SELECT (SELECT lab_controller.fqdn \nFROM
lab_controller \nWHERE lab_controller.id = system.lab_controller_id) AS
`LabController`, system.private AS system_private, system.serial AS
system_serial, (SELECT system_type.type \nFROM system_type \nWHERE
system_type.id = system.type_id) AS `Type`, (SELECT system_status.status
\nFROM system_status \nWHERE system_status.id = system.status_id) AS
`Status`, system.lender AS system_lender, (SELECT tg_user.user_name
\nFROM tg_user \nWHERE system.user_id = tg_user.user_id) AS `User`,
system.memory AS system_memory, system.shared AS system_shared, (SELECT
arch.arch) AS `Arch`, system.vendor AS system_vendor, system.date_added
AS system_date_added, system.date_modified AS system_date_modified,
system.fqdn AS system_fqdn, (SELECT tg_user.user_name \nFROM tg_user
\nWHERE tg_user.user_id = system.owner_id) AS `Owner`, system.model AS
system_model, system.id AS system_id, system.date_lastcheckin AS
system_date_lastcheckin, system.location AS system_location,
system.owner_id AS system_owner_id, system.user_id AS system_user_id,
system.type_id AS system_type_id, system.status_id AS system_status_id,
system.deleted AS system_deleted, system.checksum AS system_checksum,
system.lab_controller_id AS system_lab_controller_id, system.mac_address
AS system_mac_address, system.loan_id AS system_loan_id \nFROM system
\nWHERE system.id = %s' [97L]
And sure enough I can trigger it if I do the following from tg-admin shell
>>> print system.Arch
Traceback (most recent call last):
File "<console>", line 1, in <module>
File "/usr/lib/python2.6/site-packages/sqlalchemy/orm/attributes.py",
line 158, in __get__
return self.impl.get(instance_state(instance), instance_dict(instance))
File "/usr/lib/python2.6/site-packages/sqlalchemy/orm/attributes.py",
line 374, in get
value = callable_()
File "/usr/lib/python2.6/site-packages/sqlalchemy/orm/strategies.py",
line 297, in __call__
query._get(None, ident=ident, only_load_props=group,
refresh_state=state)
File "/usr/lib/python2.6/site-packages/sqlalchemy/orm/query.py", line
1431, in _get
return q.all()[0]
File "/usr/lib/python2.6/site-packages/sqlalchemy/orm/query.py", line
1198, in all
return list(self)
File "/usr/lib/python2.6/site-packages/sqlalchemy/orm/query.py", line
1292, in __iter__
return self._execute_and_instances(context)
File "/usr/lib/python2.6/site-packages/sqlalchemy/orm/query.py", line
1295, in _execute_and_instances
result = self.session.execute(querycontext.statement,
params=self._params, mapper=self._mapper_zero_or_none())
File "/usr/lib/python2.6/site-packages/sqlalchemy/orm/session.py",
line 755, in execute
clause, params or {})
File "/usr/lib/python2.6/site-packages/sqlalchemy/engine/base.py",
line 824, in execute
return Connection.executors[c](self, object, multiparams, params)
File "/usr/lib/python2.6/site-packages/sqlalchemy/engine/base.py",
line 874, in _execute_clauseelement
return self.__execute_context(context)
File "/usr/lib/python2.6/site-packages/sqlalchemy/engine/base.py",
line 896, in __execute_context
self._cursor_execute(context.cursor, context.statement,
context.parameters[0], context=context)
File "/usr/lib/python2.6/site-packages/sqlalchemy/engine/base.py",
line 950, in _cursor_execute
self._handle_dbapi_exception(e, statement, parameters, cursor, context)
File "/usr/lib/python2.6/site-packages/sqlalchemy/engine/base.py",
line 931, in _handle_dbapi_exception
raise exc.DBAPIError.instance(statement, parameters, e,
connection_invalidated=is_disconnect)
OperationalError: (OperationalError) no such column: arch.arch u'SELECT
(SELECT arch.arch) AS "Arch" \nFROM system \nWHERE system.id = ?' [1]
There must be a better way to do what we want here.. Any thoughts?