I'm not happy about resorting to this "fix" because it is not really a fix.
Explanation of the problem this PR works around. This is a real edge case based on a number of colliding factors:
Oracle version <= 12.1 (i.e. max identifier length 30). Oracle versions <= 12.1 are not exactly rare but not current and will become rarer over time
Primary key column name >= 24 characters. Primary key names tend not to be very wordy
Primary key defined as NUMBER(). Primary key columns tend to be defined as integers of some kind and not the scale unknown NUMBER()
For fractional columns we use a CASE expression when casting to string to cater for an Oracle issue that omits the zero for numbers less than ABS(1), e.g. .123 instead of 0.123. We don't know the scale for a loosely defined NUMBER(*) column so have to check it with the CASE expression.
SQLAlchemy has a weird behaviour of renaming (by alias) columns with a name within 6 characters of the limit. For the Oracle version in play that is a 24 character limit.
Primary key columns with a greater precision than bigint/double are lossy in Pandas and therefore need to be cast to string. Again a loosely defined NUMBER(*) column does not tell us the precision and we therefore have to assume it is large.
The cast to string fails because SQLAlchemy renamed the column because of the long(ish) name
If the column was correctly defined as NUMBER(p,0) then we would no end up in this edge case.
I've invested many hours trying to find an elegant solution and cannot really justify spending more time on it for such an edge case, especially one that will become less likely as we move further away from Oracle versions <= 12.1.
I'm not happy about resorting to this "fix" because it is not really a fix.
Explanation of the problem this PR works around. This is a real edge case based on a number of colliding factors:
I've invested many hours trying to find an elegant solution and cannot really justify spending more time on it for such an edge case, especially one that will become less likely as we move further away from Oracle versions <= 12.1.