HHH-14152 Preserve end-of-line chars in MultiLineImportExtractor
This commit is contained in:
parent
b49c333198
commit
4716262645
|
@ -56,7 +56,7 @@ script
|
||||||
;
|
;
|
||||||
|
|
||||||
statement
|
statement
|
||||||
: { statementStarted(); } (statementPart)* DELIMITER { statementEnded(); }
|
: { statementStarted(); } (statementPart)* DELIMITER (WS_CHAR)* { statementEnded(); }
|
||||||
;
|
;
|
||||||
|
|
||||||
statementPart
|
statementPart
|
||||||
|
@ -71,8 +71,11 @@ quotedString
|
||||||
;
|
;
|
||||||
|
|
||||||
nonSkippedChar
|
nonSkippedChar
|
||||||
: c:CHAR {
|
: w:WS_CHAR {
|
||||||
out( c );
|
out( w );
|
||||||
|
}
|
||||||
|
| o:OTHER_CHAR {
|
||||||
|
out( o );
|
||||||
}
|
}
|
||||||
;
|
;
|
||||||
|
|
||||||
|
@ -105,18 +108,13 @@ QUOTED_TEXT
|
||||||
protected
|
protected
|
||||||
ESCqs : '\'' '\'' ;
|
ESCqs : '\'' '\'' ;
|
||||||
|
|
||||||
CHAR
|
WS_CHAR
|
||||||
: ( ' ' | '\t' ) => ( ' ' | '\t' )
|
: ' '
|
||||||
| ~( ';' | '\n' | '\r' )
|
| '\t'
|
||||||
|
| ( "\r\n" | '\r' | '\n' ) {newline();}
|
||||||
;
|
;
|
||||||
|
|
||||||
NEWLINE
|
OTHER_CHAR : ~( ';' | ' ' | '\t' | '\n' | '\r' );
|
||||||
: ( '\r' | '\n' | '\r''\n' ) {
|
|
||||||
newline();
|
|
||||||
// skip the entire match from the lexer stream
|
|
||||||
$setType( Token.SKIP );
|
|
||||||
}
|
|
||||||
;
|
|
||||||
|
|
||||||
LINE_COMMENT
|
LINE_COMMENT
|
||||||
// match `//` or `--` followed by anything other than \n or \r until NEWLINE
|
// match `//` or `--` followed by anything other than \n or \r until NEWLINE
|
||||||
|
|
|
@ -44,7 +44,7 @@ public class MultiLineImportExtractorTest {
|
||||||
|
|
||||||
assertThat( commands[1], is( "INSERT INTO test_data VALUES (1, 'sample')" ) );
|
assertThat( commands[1], is( "INSERT INTO test_data VALUES (1, 'sample')" ) );
|
||||||
|
|
||||||
assertThat( commands[2], is( "DELETE FROM test_data" ) );
|
assertThat( commands[2], is( "DELETE\n FROM test_data" ) );
|
||||||
|
|
||||||
assertThat( commands[3], startsWith( "INSERT INTO test_data VALUES (2," ) );
|
assertThat( commands[3], startsWith( "INSERT INTO test_data VALUES (2," ) );
|
||||||
assertThat( commands[3], containsString( "-- line 2" ) );
|
assertThat( commands[3], containsString( "-- line 2" ) );
|
||||||
|
@ -52,7 +52,7 @@ public class MultiLineImportExtractorTest {
|
||||||
assertThat( commands[4], startsWith( "INSERT INTO test_data VALUES (3" ) );
|
assertThat( commands[4], startsWith( "INSERT INTO test_data VALUES (3" ) );
|
||||||
assertThat( commands[4], not( containsString( "third record" ) ) );
|
assertThat( commands[4], not( containsString( "third record" ) ) );
|
||||||
|
|
||||||
assertThat( commands[5], containsString( "INSERT INTO test_data (id, text)" ) );
|
assertThat( commands[5], startsWith( "INSERT INTO test_data\nVALUES\n" ) );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -23,12 +23,14 @@ INSERT INTO test_data VALUES (2, 'Multi-line comment line 1
|
||||||
-- INSERT INTO test_data VALUES (1, NULL);
|
-- INSERT INTO test_data VALUES (1, NULL);
|
||||||
|
|
||||||
INSERT INTO test_data VALUES (3 /* 'third record' */, NULL /* value */); -- with NULL value
|
INSERT INTO test_data VALUES (3 /* 'third record' */, NULL /* value */); -- with NULL value
|
||||||
INSERT INTO test_data (id, text)
|
INSERT INTO test_data
|
||||||
VALUES
|
VALUES
|
||||||
(
|
(
|
||||||
4 -- another record
|
4 -- another record
|
||||||
, NULL
|
, NULL
|
||||||
);
|
);
|
||||||
|
-- comment;
|
||||||
|
-- comment;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
-- comment;
|
|
||||||
-- comment;
|
|
||||||
|
|
Loading…
Reference in New Issue