Sfoglia il codice sorgente

[librdbms] Fix postgresql table and column fetch queries

The queries sent to Postgres in get_tables were erroneous and thus
returned only database_name to the Navigator. The get_columns
function used MySQL syntax instead of Postgres.

https://github.com/cloudera/hue/pull/110
Ilkka Turunen 11 anni fa
parent
commit
12211ceeed

+ 2 - 2
desktop/libs/librdbms/src/librdbms/server/postgresql_lib.py

@@ -88,13 +88,13 @@ class PostgreSQLClient(BaseRDMSClient):
   def get_tables(self, database, table_names=[]):
     # Doesn't use database and only retrieves tables for database currently in use.
     cursor = self.connection.cursor()
-    cursor.execute("SELECT table_schema,table_name FROM information_schema.tables")
+    cursor.execute("SELECT table_name FROM information_schema.tables WHERE table_schema='%s'" % database)
     self.connection.commit()
     return [row[0] for row in cursor.fetchall()]
 
 
   def get_columns(self, database, table):
     cursor = self.connection.cursor()
-    cursor.execute("SHOW COLUMNS %s.%s" % (database, table))
+    cursor.execute("SELECT column_name FROM information_schema.columns WHERE table_schema='%s' and table_name='%s'" % (database, table))
     self.connection.commit()
     return [row[0] for row in cursor.fetchall()]