forked from juju/juju
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request juju#17449 from SimonRichardson/lint-sql-files
juju#17449 ~~Requires juju#17428 to land first~~ ---- This formats and lints all the SQL files. We're using sqlfluff for linting and formatting. The style isn't 100% nice, but then again any formatter isn't perfect (see gofmt as an example). The files are 100% consistent though. In addition to formatting, I found a lot of stupid and simple mistakes that the linter found. - using keywords for column names - missing commas - ambiguous column names in joins - duplicated columns in views I'm not even sure how some of the foreign keys worked (unless the sqlite parser is very lenient) because missing commas were present in multiple locations. The point of this is to improve the correctness of our SQL statements. ## Checklist <!-- If an item is not applicable, use `~strikethrough~`. --> - [x] Code style: imports ordered, good names, simple structure, etc - [x] Comments saying why design decisions were made - [x] Go unit tests, with comments saying what you're testing ## QA steps Install sqlfluff. Use an env rather than stomping on the system is probably wise. ```sh $ pip install sqlfluff ``` ## Links **Jira card:** JUJU-
- Loading branch information
Showing
42 changed files
with
1,321 additions
and
1,357 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
[sqlfluff] | ||
dialect = sqlite | ||
max_line_length = 180 | ||
aliasing.column = explicit | ||
capitalisation.keywords = upper | ||
capitalisation.functions = upper | ||
capitalisation.literals = true | ||
convention.not_equal = consistent | ||
|
||
[sqlfluff:indentation] | ||
tab_space_size = 4 | ||
indent_unit = space | ||
indented_joins = false | ||
indented_using_on = true | ||
allow_implicit_indents = true | ||
indented_on_contents = false | ||
indented_ctes = false |
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 |
---|---|---|
@@ -1,9 +1,9 @@ | ||
CREATE TABLE life ( | ||
id INT PRIMARY KEY, | ||
id INT PRIMARY KEY, | ||
value TEXT NOT NULL | ||
); | ||
|
||
INSERT INTO life VALUES | ||
(0, 'alive'), | ||
(1, 'dying'), | ||
(2, 'dead'); | ||
(0, 'alive'), | ||
(1, 'dying'), | ||
(2, 'dead'); |
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
26 changes: 13 additions & 13 deletions
26
domain/schema/controller/sql/0004-changelog-namespaces.sql
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 |
---|---|---|
@@ -1,14 +1,14 @@ | ||
INSERT INTO change_log_namespace VALUES | ||
(0, 'external_controller', 'external controller changes based on the UUID'), | ||
(1, 'controller_node', 'controller node changes based on the controller ID'), | ||
(2, 'controller_config', 'controller config changes based on the key'), | ||
(3, 'model_migration_status', 'model migration status changes based on the UUID'), | ||
(4, 'model_migration_minion_sync', 'model migration minion sync changes based on the UUID'), | ||
(5, 'upgrade_info', 'upgrade info changes based on the UUID'), | ||
(6, 'cloud', 'cloud changes based on the UUID'), | ||
(7, 'cloud_credential', 'cloud credential changes based on the UUID'), | ||
(8, 'autocert_cache', 'autocert cache changes based on the UUID'), | ||
(9, 'upgrade_info_controller_node', 'upgrade info controller node changes based on the upgrade info UUID'), | ||
(10, 'object_store_metadata_path', 'object store metadata path changes based on the path'), | ||
(11, 'secret_backend_rotation', 'secret backend rotation changes based on the backend UUID and next rotation time'), | ||
(12, 'model', 'model changes based on the model UUID'); | ||
(0, 'external_controller', 'external controller changes based on the UUID'), | ||
(1, 'controller_node', 'controller node changes based on the controller ID'), | ||
(2, 'controller_config', 'controller config changes based on the key'), | ||
(3, 'model_migration_status', 'model migration status changes based on the UUID'), | ||
(4, 'model_migration_minion_sync', 'model migration minion sync changes based on the UUID'), | ||
(5, 'upgrade_info', 'upgrade info changes based on the UUID'), | ||
(6, 'cloud', 'cloud changes based on the UUID'), | ||
(7, 'cloud_credential', 'cloud credential changes based on the UUID'), | ||
(8, 'autocert_cache', 'autocert cache changes based on the UUID'), | ||
(9, 'upgrade_info_controller_node', 'upgrade info controller node changes based on the upgrade info UUID'), | ||
(10, 'object_store_metadata_path', 'object store metadata path changes based on the path'), | ||
(11, 'secret_backend_rotation', 'secret backend rotation changes based on the backend UUID and next rotation time'), | ||
(12, 'model', 'model changes based on the model UUID'); |
Oops, something went wrong.