NHSDigital / ndr_error

Error logging Rails engine
MIT License
1 stars 3 forks source link

Searching of numeric :user_id column breaks #2

Closed joshpencheon closed 8 years ago

joshpencheon commented 8 years ago

In existing systems, the user_id column has been a VARCHAR, meaning the SQL lower function is appropriate. However, if the engine is configured with user_id as a standard foreign key to a users table, this breaks:

PG::UndefinedFunction: ERROR: function lower(integer) does not exist

We can introspect on the schema to determine whether the user column should be searchable:

users_searchable = string == NdrError::Log.columns_hash[NdrError.user_column.to_s].type

columns = %w(description error_class)
columns.push NdrError.user_column.to_s if users_searchable

The UI would need to reflect this too.