-
Notifications
You must be signed in to change notification settings - Fork 28
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[ADQL] Fix escaping of double quotes in delimited identifiers.
A delimited identifier is any sequence of characters between a pair of double quotes. For instance: "123 I am a delimited identifier!". It is of course possible to have double quotes inside this kind of identifier, but they have to be doubled in order to not be mistaken with the end of the identifier. For instance: "Cool ""identifier""". However, this escape option was not taken into account by the ADQL library, though the same mechanism was already in place for string contants.
- Loading branch information
Showing
2 changed files
with
69 additions
and
31 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
package adql.parser; | ||
|
||
import static adql.parser.ADQLParserConstants.DELIMITED_IDENTIFIER; | ||
import static adql.parser.ADQLParserConstants.REGULAR_IDENTIFIER; | ||
import static org.junit.Assert.assertEquals; | ||
|
||
import org.junit.Before; | ||
import org.junit.BeforeClass; | ||
import org.junit.Test; | ||
|
||
import adql.parser.IdentifierItems.IdentifierItem; | ||
|
||
public class TestIdentifierItem { | ||
|
||
@BeforeClass | ||
public static void setUpBeforeClass() throws Exception{} | ||
|
||
@Before | ||
public void setUp() throws Exception{} | ||
|
||
@Test | ||
public void testIdentifierItem(){ | ||
/* A regular identifier (with no special characters) should be returned | ||
* as provided: */ | ||
IdentifierItem identifier = new IdentifierItem(new Token(REGULAR_IDENTIFIER, "m50"), false); | ||
assertEquals("m50", identifier.toString()); | ||
|
||
/* Ensure doubled double quotes are escaped | ||
* (i.e. considered as a single double quote): */ | ||
identifier = new IdentifierItem(new Token(DELIMITED_IDENTIFIER, "m50\"\""), true); | ||
assertEquals("m50\"", identifier.toString()); | ||
} | ||
|
||
} |