PASTAplus / PASTA

Repository for the Provenance Aware Synthesis Tracking Architecture (PASTA) project.
12 stars 3 forks source link

Entity names with semicolons in position less than or equal to 30 result in create failure #86

Closed servilla closed 2 years ago

servilla commented 2 years ago

Entity names with semicolons in the character position less than or equal to 30 results in a table create failure. Susanne Remillard reported an issue with "knb-lter-and.4023.10" from a previous attempt where the data entity

<entityName>Tree seedling density; subplot-scale means derived from entity 5</entityName>

resulted in the following error:

SQLException while generating data table 'Tree_seedling_density;_subplot' for entity 'Tree seedling density; subplot-scale means derived from entity 5': ERROR: syntax error at end of input Position: 35 CREATE TABLE Tree_seedling_density;_subplot("DBCODE" TEXT,"ENTITY" TEXT,"YEAR" TEXT,"SAMPLEDATE" TIMESTAMP,"PLOTID" TEXT,"PLOT" TEXT,"TMT" TEXT,"XSTART" TEXT,"XEND" TEXT,"YSTART" TEXT,"YEND" TEXT,"SUBPLOTID" TEXT,"TREESPECIES" TEXT,"HTCLASS" TEXT,"SEEDLINGS_MN" TEXT,"COMMENT" TEXT);
servilla commented 2 years ago

The error occurs because the entity name contains a semicolon character ";" within the first 30 characters of the entity name. A semicolon in this position results in a premature evaluation of the CREATE statement (see the error above). The error message notes the position value of 35 as the source of the error. This position refers to the full SQL statement and maps directly to the position of the semicolon.

CREATE TABLE Tree_seedling_density;_subplot("DBCODE"...
                      Position 35 ^

The method getLegalDBTableName in the edu.lternet.past.dml.database.DatabaseAdapter.java class attempts to replace illegal SQL characters with underscores, but the semicolon was not in this list of illegal characters. The solution is to replace all "semicolons" in entity names with an underscore.