Column comparison manipulation? #2001
-
I am involved in a project that is moving databases from sybase to postgres, the main issue with this is that sybase is natively case insensitive and postgres is not. The patch for this (at the moment) is to use case insensitive comparisons (ILIKE) in the queries embedded in our application (I know that there are issues and tradeoffs with this but it is not my decision - no point discussing it here unless you have some killer alternative). I'm attempting to put together a script to automate this as much as I can - so the question is: How can I isolate column comparisons (= , <> , like, not like) including the column names on both sides - I need to find them and evaluate the columns (comparing to a list of columns that should be case insensitive), then change the comparison operator as appropriate and inject it all back into the original query. Example:
---->
There are 3 examples (comparison in case in select, comparison in join, comparison in where) of the cases I've seen so far, is this possible? I also want to avoid affecting the '=' characters in update statements eg( |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
You can search for the specific AST nodes you mentioned and conditionally See: |
Beta Was this translation helpful? Give feedback.
You can search for the specific AST nodes you mentioned and conditionally
replace
them with the case-insensitive operators of interest. You can also apply a transformation to the whole AST to automatically do this for every target node.See: