File tree Expand file tree Collapse file tree 1 file changed +8
-8
lines changed Expand file tree Collapse file tree 1 file changed +8
-8
lines changed Original file line number Diff line number Diff line change @@ -9,14 +9,13 @@ fn main() {
9
9
let mut line = String :: new ( ) ;
10
10
let mut table_name = String :: new ( ) ;
11
11
let mut fields = String :: new ( ) ;
12
- let re = Regex :: new ( r"^COPY ([\w\.] +) \(([\w, ] +)\) FROM stdin;" ) . unwrap ( ) ;
12
+ let re = Regex :: new ( r"^COPY (. +) \((. +)\) FROM stdin;" ) . unwrap ( ) ;
13
13
let mut insert_mode = false ;
14
14
while stdin. read_line ( & mut line) . unwrap ( ) > 0 {
15
15
if insert_mode {
16
16
if line == "\\ .\n " {
17
17
insert_mode = false ;
18
- }
19
- else {
18
+ } else {
20
19
let mut values = String :: new ( ) ;
21
20
line. pop ( ) ;
22
21
for s in line. replace ( "'" , "''" ) . split ( "\t " ) {
@@ -30,18 +29,19 @@ fn main() {
30
29
}
31
30
values. pop ( ) ;
32
31
values. pop ( ) ;
33
- println ! ( "INSERT INTO {} ({}) VALUES ({});" ,
34
- table_name, fields, values) ;
32
+ println ! (
33
+ "INSERT INTO {} ({}) VALUES ({});" ,
34
+ table_name, fields, values
35
+ ) ;
35
36
}
36
- }
37
- else {
37
+ } else {
38
38
match re. captures ( & line) {
39
39
None => print ! ( "{}" , line) ,
40
40
Some ( caps) => {
41
41
table_name = String :: from ( caps. get ( 1 ) . map_or ( "" , |m| m. as_str ( ) ) ) ;
42
42
fields = String :: from ( caps. get ( 2 ) . map_or ( "" , |m| m. as_str ( ) ) ) ;
43
43
insert_mode = true ;
44
- } ,
44
+ }
45
45
} ;
46
46
}
47
47
line. clear ( ) ;
You can’t perform that action at this time.
0 commit comments