HHH-14153 reserve end-of-line chars in MultiLineImportExtractor
This commit is contained in:
parent
203738bbf5
commit
2ab372027e
|
@ -56,7 +56,7 @@ script
|
|||
;
|
||||
|
||||
statement
|
||||
: { statementStarted(); } (statementPart)* DELIMITER { statementEnded(); }
|
||||
: { statementStarted(); } (statementPart)* DELIMITER (WS_CHAR)* { statementEnded(); }
|
||||
;
|
||||
|
||||
statementPart
|
||||
|
@ -71,8 +71,11 @@ quotedString
|
|||
;
|
||||
|
||||
nonSkippedChar
|
||||
: c:CHAR {
|
||||
out( c );
|
||||
: w:WS_CHAR {
|
||||
out( w );
|
||||
}
|
||||
| o:OTHER_CHAR {
|
||||
out( o );
|
||||
}
|
||||
;
|
||||
|
||||
|
@ -105,18 +108,13 @@ QUOTED_TEXT
|
|||
protected
|
||||
ESCqs : '\'' '\'' ;
|
||||
|
||||
CHAR
|
||||
: ( ' ' | '\t' ) => ( ' ' | '\t' )
|
||||
| ~( ';' | '\n' | '\r' )
|
||||
WS_CHAR
|
||||
: ' '
|
||||
| '\t'
|
||||
| ( "\r\n" | '\r' | '\n' ) {newline();}
|
||||
;
|
||||
|
||||
NEWLINE
|
||||
: ( '\r' | '\n' | '\r''\n' ) {
|
||||
newline();
|
||||
// skip the entire match from the lexer stream
|
||||
$setType( Token.SKIP );
|
||||
}
|
||||
;
|
||||
OTHER_CHAR : ~( ';' | ' ' | '\t' | '\n' | '\r' );
|
||||
|
||||
LINE_COMMENT
|
||||
// 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[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], containsString( "-- line 2" ) );
|
||||
|
@ -52,7 +52,7 @@ public class MultiLineImportExtractorTest {
|
|||
assertThat( commands[4], startsWith( "INSERT INTO test_data VALUES (3" ) );
|
||||
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 (3 /* 'third record' */, NULL /* value */); -- with NULL value
|
||||
INSERT INTO test_data (id, text)
|
||||
VALUES
|
||||
(
|
||||
4 -- another record
|
||||
, NULL
|
||||
);
|
||||
INSERT INTO test_data
|
||||
VALUES
|
||||
(
|
||||
4 -- another record
|
||||
, NULL
|
||||
);
|
||||
-- comment;
|
||||
-- comment;
|
||||
|
||||
|
||||
|
||||
-- comment;
|
||||
-- comment;
|
||||
|
|
Loading…
Reference in New Issue