Skip to content

Commit 1477852

Browse files
authored
Merge pull request #378 from domaframework/chore/format
Format SQL files and annotations for improved readability
2 parents 4d489ac + 326192e commit 1477852

File tree

35 files changed

+754
-555
lines changed

35 files changed

+754
-555
lines changed

common/src/main/resources/META-INF/example/common/dao/ScriptDao/create.script

Lines changed: 242 additions & 175 deletions
Large diffs are not rendered by default.
Lines changed: 13 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,13 @@
1-
drop sequence employee_seq;
2-
drop table employee;
3-
drop table department;
4-
5-
drop table if exists review;
6-
drop table if exists payment;
7-
drop table if exists order_item;
8-
drop table if exists "order";
9-
drop table if exists product_category;
10-
drop table if exists category;
11-
drop table if exists product;
12-
drop table if exists user_role;
13-
drop table if exists role;
14-
drop table if exists "user";
1+
DROP sequence employee_seq ;
2+
DROP TABLE employee ;
3+
DROP TABLE department ;
4+
DROP TABLE IF EXISTS review ;
5+
DROP TABLE IF EXISTS payment ;
6+
DROP TABLE IF EXISTS order_item ;
7+
DROP TABLE IF EXISTS "order" ;
8+
DROP TABLE IF EXISTS product_category ;
9+
DROP TABLE IF EXISTS category ;
10+
DROP TABLE IF EXISTS product ;
11+
DROP TABLE IF EXISTS user_role ;
12+
DROP TABLE IF EXISTS role ;
13+
DROP TABLE IF EXISTS "user" ;

example-geometric-type/src/main/java/example/geometric/type/dao/CircleZoneDao.java

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,12 @@
99
@Dao
1010
public interface CircleZoneDao {
1111

12-
@Sql("select /*%expand */* from circle_zone where id = /* id */0")
12+
@Sql(
13+
"""
14+
SELECT /*%expand */*
15+
FROM circle_zone
16+
WHERE id = /* id */0
17+
""")
1318
@Select
1419
CircleZone selectById(Integer id);
1520

example-geometric-type/src/main/java/example/geometric/type/dao/LandmarkDao.java

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,12 @@
99
@Dao
1010
public interface LandmarkDao {
1111

12-
@Sql("select /*%expand */* from landmark where id = /* id */0")
12+
@Sql(
13+
"""
14+
SELECT /*%expand */*
15+
FROM landmark
16+
WHERE id = /* id */0
17+
""")
1318
@Select
1419
Landmark selectById(Integer id);
1520

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
1-
CREATE TABLE landmark (
2-
id INTEGER PRIMARY KEY,
3-
name TEXT NOT NULL,
4-
location POINT NOT NULL
5-
);
6-
7-
CREATE TABLE circle_zone (
8-
id INTEGER PRIMARY KEY,
9-
name TEXT NOT NULL,
10-
boundary CIRCLE NOT NULL
11-
);
1+
CREATE TABLE landmark
2+
(
3+
id INTEGER PRIMARY KEY
4+
, name TEXT NOT NULL
5+
, location POINT NOT NULL
6+
) ;
7+
CREATE TABLE circle_zone
8+
(
9+
id INTEGER PRIMARY KEY
10+
, name TEXT NOT NULL
11+
, boundary CIRCLE NOT NULL
12+
) ;
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
DROP TABLE landmark;
2-
DROP TABLE circle_zone;
1+
DROP TABLE landmark ;
2+
DROP TABLE circle_zone ;

example-jpms/src/main/java/example/jpms/dao/EmployeeDao.java

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,10 @@ public interface EmployeeDao {
1010

1111
@Sql(
1212
"""
13-
select
14-
/*%expand*/*
15-
from
16-
employee
17-
where
18-
id = /* id */0
19-
""")
13+
SELECT /*%expand*/*
14+
FROM employee
15+
WHERE id = /* id */0
16+
""")
2017
@Select
2118
Employee selectById(Integer id);
2219
}
Lines changed: 185 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,185 @@
1-
create sequence employee_seq start with 100 increment by 1;
2-
create table department (id integer not null primary key,name varchar(255) not null, version integer not null);
3-
create table employee (id integer not null primary key,name varchar(255) not null,age integer not null,salary integer,job_type varchar(20),hiredate timestamp, department_id integer, version integer not null, insertTimestamp timestamp, updateTimestamp timestamp);
4-
insert into department values(1,'ACCOUNTING',1);
5-
insert into department values(2,'RESEARCH',1);
6-
insert into department values(3,'SALES',1);
7-
insert into employee values(1,'ALLEN',30,1600,'SALESMAN','2008-01-20 12:34:56',1,1,CURRENT_TIMESTAMP,null);
8-
insert into employee values(2,'WARD',32,1250,'ANALYST','2008-02-20 12:34:56',2,1,CURRENT_TIMESTAMP,null);
9-
insert into employee values(3,'JONES',38,2975,'MANAGER','2008-03-20 12:34:56',3,1,CURRENT_TIMESTAMP,null);
10-
insert into employee values(4,'MARTIN',40,1250,'SALESMAN','2008-04-20 12:34:56',1,1,CURRENT_TIMESTAMP,null);
11-
insert into employee values(5,'BLAKE',50,2850,'SALESMAN','2008-05-20 12:34:56',2,1,CURRENT_TIMESTAMP,null);
12-
insert into employee values(6,'CLARK',23,2450,'MANAGER','2008-06-20 12:34:56',3,1,CURRENT_TIMESTAMP,null);
13-
insert into employee values(7,'SCOTT',28,3000,'SALESMAN','2008-07-20 12:34:56',1,1,CURRENT_TIMESTAMP,null);
14-
insert into employee values(8,'KING',38,5000,'CLERK','2008-08-20 12:34:56',2,1,CURRENT_TIMESTAMP,null);
15-
insert into employee values(9,'TURNER',33,1500,'ANALYST','2008-09-20 12:34:56',3,1,CURRENT_TIMESTAMP,null);
16-
insert into employee values(10,'ADAMS',62,1100,'SALESMAN','2008-10-20 12:34:56',1,1,CURRENT_TIMESTAMP,null);
17-
insert into employee values(11,'JAMES',44,950,'CLERK','2008-11-20 12:34:56',2,1,CURRENT_TIMESTAMP,null);
18-
insert into employee values(12,'FORD',55,3000,'ANALYST','2008-12-20 12:34:56',3,1,CURRENT_TIMESTAMP,null);
19-
insert into employee values(13,'MILLER',51,1300,'MANAGER','2009-01-20 12:34:56',1,1,CURRENT_TIMESTAMP,null);
20-
insert into employee values(14,'SMITH',410,800,'PRESIDENT','2009-02-20 12:34:56',2,1,CURRENT_TIMESTAMP,null);
1+
CREATE sequence employee_seq start
2+
WITH 100 increment BY 1 ;
3+
CREATE TABLE department
4+
( id integer NOT NULL PRIMARY KEY
5+
, name varchar(255) NOT NULL
6+
, version integer NOT NULL
7+
) ;
8+
CREATE TABLE employee
9+
( id integer NOT NULL PRIMARY KEY
10+
, name varchar(255) NOT NULL
11+
, age integer NOT NULL
12+
, salary integer
13+
, job_type varchar(20)
14+
, hiredate timestamp
15+
, department_id integer
16+
, version integer NOT NULL
17+
, insertTimestamp timestamp
18+
, updateTimestamp timestamp
19+
) ;
20+
INSERT INTO department
21+
VALUES ( 1
22+
, 'ACCOUNTING'
23+
, 1 ) ;
24+
INSERT INTO department
25+
VALUES ( 2
26+
, 'RESEARCH'
27+
, 1 ) ;
28+
INSERT INTO department
29+
VALUES ( 3
30+
, 'SALES'
31+
, 1 ) ;
32+
INSERT INTO employee
33+
VALUES ( 1
34+
, 'ALLEN'
35+
, 30
36+
, 1600
37+
, 'SALESMAN'
38+
, '2008-01-20 12:34:56'
39+
, 1
40+
, 1
41+
, CURRENT_TIMESTAMP
42+
, NULL ) ;
43+
INSERT INTO employee
44+
VALUES ( 2
45+
, 'WARD'
46+
, 32
47+
, 1250
48+
, 'ANALYST'
49+
, '2008-02-20 12:34:56'
50+
, 2
51+
, 1
52+
, CURRENT_TIMESTAMP
53+
, NULL ) ;
54+
INSERT INTO employee
55+
VALUES ( 3
56+
, 'JONES'
57+
, 38
58+
, 2975
59+
, 'MANAGER'
60+
, '2008-03-20 12:34:56'
61+
, 3
62+
, 1
63+
, CURRENT_TIMESTAMP
64+
, NULL ) ;
65+
INSERT INTO employee
66+
VALUES ( 4
67+
, 'MARTIN'
68+
, 40
69+
, 1250
70+
, 'SALESMAN'
71+
, '2008-04-20 12:34:56'
72+
, 1
73+
, 1
74+
, CURRENT_TIMESTAMP
75+
, NULL ) ;
76+
INSERT INTO employee
77+
VALUES ( 5
78+
, 'BLAKE'
79+
, 50
80+
, 2850
81+
, 'SALESMAN'
82+
, '2008-05-20 12:34:56'
83+
, 2
84+
, 1
85+
, CURRENT_TIMESTAMP
86+
, NULL ) ;
87+
INSERT INTO employee
88+
VALUES ( 6
89+
, 'CLARK'
90+
, 23
91+
, 2450
92+
, 'MANAGER'
93+
, '2008-06-20 12:34:56'
94+
, 3
95+
, 1
96+
, CURRENT_TIMESTAMP
97+
, NULL ) ;
98+
INSERT INTO employee
99+
VALUES ( 7
100+
, 'SCOTT'
101+
, 28
102+
, 3000
103+
, 'SALESMAN'
104+
, '2008-07-20 12:34:56'
105+
, 1
106+
, 1
107+
, CURRENT_TIMESTAMP
108+
, NULL ) ;
109+
INSERT INTO employee
110+
VALUES ( 8
111+
, 'KING'
112+
, 38
113+
, 5000
114+
, 'CLERK'
115+
, '2008-08-20 12:34:56'
116+
, 2
117+
, 1
118+
, CURRENT_TIMESTAMP
119+
, NULL ) ;
120+
INSERT INTO employee
121+
VALUES ( 9
122+
, 'TURNER'
123+
, 33
124+
, 1500
125+
, 'ANALYST'
126+
, '2008-09-20 12:34:56'
127+
, 3
128+
, 1
129+
, CURRENT_TIMESTAMP
130+
, NULL ) ;
131+
INSERT INTO employee
132+
VALUES ( 10
133+
, 'ADAMS'
134+
, 62
135+
, 1100
136+
, 'SALESMAN'
137+
, '2008-10-20 12:34:56'
138+
, 1
139+
, 1
140+
, CURRENT_TIMESTAMP
141+
, NULL ) ;
142+
INSERT INTO employee
143+
VALUES ( 11
144+
, 'JAMES'
145+
, 44
146+
, 950
147+
, 'CLERK'
148+
, '2008-11-20 12:34:56'
149+
, 2
150+
, 1
151+
, CURRENT_TIMESTAMP
152+
, NULL ) ;
153+
INSERT INTO employee
154+
VALUES ( 12
155+
, 'FORD'
156+
, 55
157+
, 3000
158+
, 'ANALYST'
159+
, '2008-12-20 12:34:56'
160+
, 3
161+
, 1
162+
, CURRENT_TIMESTAMP
163+
, NULL ) ;
164+
INSERT INTO employee
165+
VALUES ( 13
166+
, 'MILLER'
167+
, 51
168+
, 1300
169+
, 'MANAGER'
170+
, '2009-01-20 12:34:56'
171+
, 1
172+
, 1
173+
, CURRENT_TIMESTAMP
174+
, NULL ) ;
175+
INSERT INTO employee
176+
VALUES ( 14
177+
, 'SMITH'
178+
, 410
179+
, 800
180+
, 'PRESIDENT'
181+
, '2009-02-20 12:34:56'
182+
, 2
183+
, 1
184+
, CURRENT_TIMESTAMP
185+
, NULL ) ;
Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
drop sequence employee_seq;
2-
drop table employee;
3-
drop table department;
1+
DROP sequence employee_seq ;
2+
DROP TABLE employee ;
3+
DROP TABLE department ;

example-jpms/src/main/resources/logback.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,6 @@
99
<logger name="org.seasar.doma.jdbc.LogKind.SQL.SCRIPT" level="off"/>
1010

1111
<root level="info">
12-
<appender-ref ref="STDOUT" />
12+
<appender-ref ref="STDOUT"/>
1313
</root>
1414
</configuration>

0 commit comments

Comments
 (0)