self.write_double_key(response)
return response
- def resolve_table(self, qualified_table):
+ def resolve_normalized_table(self, qualified_table):
'''Return (schema, table) tuple of table name, or raise exception
if not resolvable.
'''
raise
return self.cur.fetchone()
+ def resolve_table(self, qualified_table):
+ '''Return (schema, table) tuple of table name or raise exception
+ if character case is wrong
+ '''
+ (schema, table) = self.resolve_normalized_table(qualified_table)
+ norm_qualified_table = qualified_table.lower()
+ if schema:
+ norm_schema = schema.lower()
+ len_schema = len(schema)
+ if (norm_qualified_table[0:len_schema] == norm_schema
+ and qualified_table[0:len_schema] != schema):
+ raise upload_ex.MissingSchemaError(
+ 'No such schema',
+ (f'The schema ({qualified_table[0:len_schema]}) does '
+ 'not exist, but the same-but-for-character-case '
+ f'schema ({schema}) does'))
+ norm_table = table.lower()
+ len_table = len(table)
+ if (norm_qualified_table[- len_table:] == norm_table
+ and qualified_table[- len_table:] != table):
+ raise upload_ex.MissingTableError(
+ 'No such table or view',
+ (f'The table ({qualified_table[- len_table:]}) does '
+ 'not exist, but the same-but-for-character-case '
+ f'table ({table}) does'))
+ return (schema, table)
+
def good_table(self, schema, table):
'''Is the supplied table or view insertable?
'''