mirror of
https://github.com/getredash/redash.git
synced 2026-03-22 10:00:17 -04:00
* Postgres: make sure table from the public schema doesn't get merged with a table from another schema. * PEP8 updates
23 lines
841 B
Python
23 lines
841 B
Python
|
|
from unittest import TestCase
|
|
from redash.query_runner.pg import build_schema
|
|
|
|
|
|
class TestBuildSchema(TestCase):
|
|
def test_handles_dups_between_public_and_other_schemas(self):
|
|
results = {
|
|
'rows': [
|
|
{'table_schema': 'public', 'table_name': 'main.users', 'column_name': 'id'},
|
|
{'table_schema': 'main', 'table_name': 'users', 'column_name': 'id'},
|
|
{'table_schema': 'main', 'table_name': 'users', 'column_name': 'name'},
|
|
]
|
|
}
|
|
|
|
schema = {}
|
|
|
|
build_schema(results, schema)
|
|
|
|
self.assertIn('main.users', schema.keys())
|
|
self.assertListEqual(schema['main.users']['columns'], ['id', 'name'])
|
|
self.assertIn('public."main.users"', schema.keys())
|
|
self.assertListEqual(schema['public."main.users"']['columns'], ['id']) |