mirror of
https://github.com/pachli/pachli-android.git
synced 2025-02-02 02:16:48 +01:00
c81bb0238e
The database queries in the @Query annotations were in a range of different styles which made them difficult to read, and difficult to write new ones in a consistent style. Fix this. Write a new tool, `sqlfmt`. This processes the DAO files looking for `@Query(...)` annotations. It extracts the SQL from those annotations and calls `sqlfluff` (https://github.com/sqlfluff/sqlfluff, which must be installed separately) to lint and fix formatting issues in the SQL. The file is re-written with the newly formatted SQL queries.
fmtsql
Synopsis
fmtsql
formats the SQL in @Query
annotations using sqlfluff
, which must be installed on your system.
Usage
From the parent directory, run:
./runtools fmtsql
The result may not be 100% ktlint compatible, so then run:
./gradlew ktlintformat
Verify the modifications made to the DAO files, and commit the result.
Options
--dir
: Path to the DAO files containing@Query
annotations. The default is the path to Pachli DAO files--sqlfluff
: Full path to thesqlfluff
executable
Configuration
SQL formatting is controlled by the .sqlfluff
configuration file in the project's root directory.