Hi all, I'm still a bit noob when it comes to Ruby and Sequel so sorry if this seems trivial.
I'm working with a legacy MSSQL database which is primarily updated by a 3rd party app which I have no control over. This 3rd party app likes to insert string values padded with spaces, which in turn forces me to call .strip on most values I access. I was looking for a way to make this automatic. I found I can just override getters on the module that just do `super.strip' but since there are many such columns on different models, this does not seem very optimal. Is there a way to override getters en masse (e.g. for a list of columns, or for columns of particular type)? Also, I was searching through the list archives and found I could probably (ab)use typecasting for that. E.g. I've seen typecast_value_string may be the place to do it, but I'm not sure if this is a good idea? If it is, what would be a good way to extend it? Or would it be even better to do the transformations on database side, e.g. replacing columns in select with e.g. `replace(tbl.col, ' ', '') as col'? Also a related question, if a database uses e.g. type char for some columns, but they really are integers, and I'd prefer to work with them as integers, what are my options? Thanks in advance for any pointers! -- Michael Gliwinski Henderson Group Information Services 9-11 Hightown Avenue, Newtownabby, BT36 4RT Phone: 028 9034 3319 ********************************************************************************************** The information in this email is confidential and may be legally privileged. It is intended solely for the addressee and access to the email by anyone else is unauthorised. If you are not the intended recipient, any disclosure, copying, distribution or any action taken or omitted to be taken in reliance on it, is prohibited and may be unlawful. When addressed to our clients, any opinions or advice contained in this e-mail are subject to the terms and conditions expressed in the governing client engagement leter or contract. If you have received this email in error please notify [email protected] John Henderson (Holdings) Ltd Registered office: 9 Hightown Avenue, Mallusk, County Antrim, Northern Ireland, BT36 4RT. Registered in Northern Ireland Registration Number NI010588 Vat No.: 814 6399 12 ********************************************************************************* -- You received this message because you are subscribed to the Google Groups "sequel-talk" group. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/sequel-talk?hl=en.
