Skip to content

Commit

Permalink
#15 Change default case format settings to lower
Browse files Browse the repository at this point in the history
  • Loading branch information
future-yamada2915 committed Oct 5, 2023
1 parent 43cd6ac commit fbfe595
Show file tree
Hide file tree
Showing 89 changed files with 1,447 additions and 1,447 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -74,8 +74,8 @@ If there is no configuration file, the default values are used.
| [`tab_size`](docs/options/tab_size.md) | int | Tab size used for formatting. | 4 |
| [`complement_alias`](docs/options/complement_alias.md) | bool | Complement aliases. Currently, column names are auto-completed with the same name. (e.g. `COL1``COL1 AS COL1`) | true |
| [`trim_bind_param`](docs/options/trim_bind_param.md) | bool | Trim the contents of the [bind parameters](https://future-architect.github.io/uroborosql-doc/background/#%E3%83%8F%E3%82%99%E3%82%A4%E3%83%B3%E3%83%88%E3%82%99%E3%83%8F%E3%82%9A%E3%83%A9%E3%83%A1%E3%83%BC%E3%82%BF). (e.g. `/* foo */``/*foo*/`) | false |
| [`keyword_case`](docs/options/keyword_case.md) | [`"upper"`, `"lower"`, `"preserve"`] | Unify the case of keywords. (No conversion in case of `"preserve"`) | upper |
| [`identifier_case`](docs/options/identifier_case.md) | [`"upper"`, `"lower"`, `"preserve"`] | Unify the case of identifiers. (No conversion in case of `"preserve"`) | upper |
| [`keyword_case`](docs/options/keyword_case.md) | [`"upper"`, `"lower"`, `"preserve"`] | Unify the case of keywords. (No conversion in case of `"preserve"`) | lower |
| [`identifier_case`](docs/options/identifier_case.md) | [`"upper"`, `"lower"`, `"preserve"`] | Unify the case of identifiers. (No conversion in case of `"preserve"`) | lower |
| [`max_char_per_line`](docs/options/max_char_per_line.md) | int | If the total number of characters in the function name and arguments exceeds `max_char_per_line`, the arguments are formatted with new lines. | 50 |
| [`complement_outer_keyword`](docs/options/complement_outer_keyword.md) | bool | Complement the optional `OUTER`. (e.g. `LEFT JOIN``LEFT OUTER JOIN`) | true |
| [`complement_column_as_keyword`](docs/options/complement_column_as_keyword.md) | bool | Complement `AS` in column aliases. | true |
Expand Down
4 changes: 2 additions & 2 deletions crates/uroborosql-fmt/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -74,9 +74,9 @@ pub(crate) enum Case {
}

impl Default for Case {
/// Caseのデフォルト値(upper)
/// Caseのデフォルト値(lower)
fn default() -> Self {
Case::Upper
Case::Lower
}
}

Expand Down
90 changes: 45 additions & 45 deletions crates/uroborosql-fmt/testfiles/config_test/dst_default/case.sql
Original file line number Diff line number Diff line change
@@ -1,61 +1,61 @@
SELECT
ID AS ID
, CASE
WHEN
GRADE_POINT >= 80
THEN
select
id as id
, case
when
grade_point >= 80
then
'A'
WHEN
GRADE_POINT < 80
AND GRADE_POINT >= 70
THEN
when
grade_point < 80
and grade_point >= 70
then
'B'
WHEN
GRADE_POINT < 70
AND GRADE_POINT >= 60
THEN
when
grade_point < 70
and grade_point >= 60
then
'C'
ELSE
else
'D'
END
AS GRADE
FROM
RISYU
WHERE
SUBJECT_NUMBER = '005'
end
as grade
from
risyu
where
subject_number = '005'
;
SELECT
ID AS ID
, CASE
GRADE
WHEN
select
id as id
, case
grade
when
'A'
THEN
then
5
WHEN
when
'B'
THEN
then
4
WHEN
when
'C'
THEN
then
3
ELSE
else
0
END
AS P
FROM
RISYU
WHERE
SUBJECT_NUMBER = '006'
end
as p
from
risyu
where
subject_number = '006'
;
SELECT
CASE
/*param*/A -- simple case cond
WHEN
select
case
/*param*/a -- simple case cond
when
/*a*/'a'
THEN
then
'A'
ELSE
else
'B'
END
end
12 changes: 6 additions & 6 deletions crates/uroborosql-fmt/testfiles/config_test/dst_default/cast.sql
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
SELECT
CAST('2023-01-01' AS DATE)
, CAST(100 AS CHAR(3))
, CAST((1 + 2) AS CHAR(1))
WHERE
TEST = TEST
select
cast('2023-01-01' as date)
, cast(100 as char(3))
, cast((1 + 2) as char(1))
where
test = test
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
SELECT
IDENTIFIER AS ID
, STUDENT_NAME AS STUDENT_NAME
FROM
JAPANESE_STUDENT_TABLE
select
identifier as id
, student_name as student_name
from
japanese_student_table
56 changes: 28 additions & 28 deletions crates/uroborosql-fmt/testfiles/config_test/dst_default/join.sql
Original file line number Diff line number Diff line change
@@ -1,36 +1,36 @@
SELECT
select
*
FROM
T1
INNER JOIN
T2
ON
T1.NUM = T2.NUM
from
t1
inner join
t2
on
t1.num = t2.num
;
SELECT
select
*
FROM
T1
LEFT OUTER JOIN
T2
ON
T1.NUM = T2.NUM
from
t1
left outer join
t2
on
t1.num = t2.num
;
SELECT
select
*
FROM
T1
RIGHT OUTER JOIN
T2
ON
T1.NUM = T2.NUM
from
t1
right outer join
t2
on
t1.num = t2.num
;
SELECT
select
*
FROM
T1
FULL OUTER JOIN
T2
ON
T1.NUM = T2.NUM
from
t1
full outer join
t2
on
t1.num = t2.num
;
68 changes: 34 additions & 34 deletions crates/uroborosql-fmt/testfiles/config_test/dst_default/keyword.sql
Original file line number Diff line number Diff line change
@@ -1,44 +1,44 @@
SELECT
CASE
WHEN
A = 1
THEN
select
case
when
a = 1
then
'one'
ELSE
else
'other'
END
AS GRADE
FROM
STUDENT STD
WHERE
GRADE BETWEEN /*start1*/60 AND /*end1*/100
AND GRADE NOT BETWEEN /*start2*/70 AND /*end2*/80
end
as grade
from
student std
where
grade between /*start1*/60 and /*end1*/100
and grade not between /*start2*/70 and /*end2*/80
;
UPDATE
WEATHER
SET
(TEMP_LO, TEMP_HI, PRCP) = (TEMP_LO + 1, TEMP_LO + 15, DEFAULT)
WHERE
CITY = 'San Francisco'
update
weather
set
(temp_lo, temp_hi, prcp) = (temp_lo + 1, temp_lo + 15, default)
where
city = 'San Francisco'
;
DELETE
FROM
PRODUCTS
WHERE
OBSOLETION_DATE = 'today'
RETURNING
delete
from
products
where
obsoletion_date = 'today'
returning
*
;
INSERT
INTO
DISTRIBUTORS
insert
into
distributors
(
DID
, DNAME
) VALUES (
DEFAULT
did
, dname
) values (
default
, 'XYZ Widgets'
)
RETURNING
DID
returning
did
;
Original file line number Diff line number Diff line change
@@ -1,39 +1,39 @@
SELECT
NORMAL_FUNC(COL1 + COL2, PARAM2)
select
normal_func(col1 + col2, param2)
;
SELECT
MANY_ARGS_FUNC(PARAM1, PARAM2, PARAM3, PARAM4)
select
many_args_func(param1, param2, param3, param4)
;
SELECT
LONG_ARGS_FUNC(
COL1 + LONGLONGLONGLONGLONGLONGLONG
, PARAM2
select
long_args_func(
col1 + longlonglonglonglonglonglong
, param2
)
;
SELECT
LONGLONGLONGLONGLONGLONGLONGLONGLONGLONGLONGLONG_FUNC(
PARAM1
, PARAM2
, PARAM3
select
longlonglonglonglonglonglonglonglonglonglonglong_func(
param1
, param2
, param3
)
;
SELECT
FUNC1(
CASE
WHEN
Z = 1
THEN
FUNC3(PARAM1, PARAM2, PARAM3, PARAM4, PARAM5)
ELSE
FUNC2(
CASE
WHEN
Z = 1
THEN
select
func1(
case
when
z = 1
then
func3(param1, param2, param3, param4, param5)
else
func2(
case
when
z = 1
then
'ONE'
ELSE
FUNC3(PARAM1, PARAM2, PARAM3, PARAM4, PARAM5)
END
else
func3(param1, param2, param3, param4, param5)
end
)
END
end
)
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
SELECT
COL AS COL
FROM
TAB
ORDER BY
COL ASC -- 昇順
, LONG_COL DESC NULLS FIRST -- 降順
, NULL_COL NULLS FIRST -- NULL先
select
col as col
from
tab
order by
col asc -- 昇順
, long_col desc nulls first -- 降順
, null_col nulls first -- NULL先
Loading

0 comments on commit fbfe595

Please sign in to comment.