Open ClausSander opened 4 months ago
The issue is that table names from SHOW TABLES
(e.g. DBO.TABLENAME) are lowercased by DatabaseIntrospection.identifier_converter()
(dbo.tablename) and then later uppercased by DatabaseOperations.quote_name()
which also performs quoting of periods ("DBO"."TABLENAME").
This patch seemed to work for me to introspect a table with a dot in the name:
diff --git a/django_snowflake/introspection.py b/django_snowflake/introspection.py
index 36dff42..c8064f3 100644
--- a/django_snowflake/introspection.py
+++ b/django_snowflake/introspection.py
@@ -194,7 +194,7 @@ class DatabaseIntrospection(BaseDatabaseIntrospection):
cursor.execute('SHOW TABLES')
tables = [
TableInfo(
- self.identifier_converter(row[1]), # table name
+ '"' + row[1] + '"', # table name
't', # 't' for table
row[5], # comment
) for row in cursor.fetchall()
output:
class DboTablename(models.Model):
col1 = models.BigIntegerField(blank=True, null=True)
class Meta:
managed = False
db_table = '"DBO.TABLENAME"'
but only use it temporarily while running inspectdb! A proper solution needs more thought, likely as part of #43.
Thanks for looking into this. However, this patch appears to be working only when running inspectdb on the whole database.
python manage.py inspectdb --database snowflake
But not when inspecting one specific table
python manage.py inspectdb --database snowflake DBO.TABLE
python manage.py inspectdb --database snowflake 'DBO.TABLE'
python manage.py inspectdb --database snowflake '"DBO.TABLE"'
Hi,
Due to legacy reasons, I need to deal with Snowflake tables having a name containing the schema in the format
DBO.TABLENAME
. However, I am unable to perform the inspectdb command. Tables without dots give no issue.This is the output with extended logging enabled:
Other variations of passing the table name, like
'"DBO.TABLENAME"'
, won't work either.However, when creating the model manually as below with the name between
'"..."'
, the database can be queried without issues.