mirror of
https://github.com/getredash/redash.git
synced 2025-12-21 18:35:48 -05:00
* Apply black formatting * Add auto formatting when committing to master * Update CONTRIBUTING.md re. Black & Prettier
27 lines
920 B
Python
27 lines
920 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"])
|