-
Notifications
You must be signed in to change notification settings - Fork 4.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Base duplicate index on column names (#4600)
* increase duplicate column names based on the original column name and not the number of duplicates detected * add fetch columns test for base query runner --------- Co-authored-by: Omer Lachish <[email protected]> Co-authored-by: Guido Petri <[email protected]>
- Loading branch information
1 parent
1ef63fc
commit 2d6f5b0
Showing
2 changed files
with
39 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
import unittest | ||
|
||
from redash.query_runner import BaseQueryRunner | ||
|
||
|
||
class TestBaseQueryRunner(unittest.TestCase): | ||
def setUp(self): | ||
self.query_runner = BaseQueryRunner({}) | ||
|
||
def test_duplicate_column_names_assigned_correctly(self): | ||
original_column_names = [ | ||
("name", bool), | ||
("created_at", bool), | ||
("updated_at", bool), | ||
("name", bool), | ||
("created_at", bool), | ||
("updated_at", bool), | ||
] | ||
expected = [ | ||
{"name": "name", "friendly_name": "name", "type": bool}, | ||
{"name": "created_at", "friendly_name": "created_at", "type": bool}, | ||
{"name": "updated_at", "friendly_name": "updated_at", "type": bool}, | ||
{"name": "name1", "friendly_name": "name1", "type": bool}, | ||
{"name": "created_at1", "friendly_name": "created_at1", "type": bool}, | ||
{"name": "updated_at1", "friendly_name": "updated_at1", "type": bool}, | ||
] | ||
|
||
new_columns = self.query_runner.fetch_columns(original_column_names) | ||
|
||
self.assertEqual(new_columns, expected) | ||
|
||
|
||
if __name__ == "__main__": | ||
unittest.main() |