Skip to content

Commit

Permalink
#626 reserved keywords update
Browse files Browse the repository at this point in the history
  • Loading branch information
ldhasson committed Aug 20, 2021
1 parent b32062b commit fe85d70
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 2 deletions.
2 changes: 2 additions & 0 deletions src/tilda/parsing/parts/Base.java
Original file line number Diff line number Diff line change
Expand Up @@ -169,10 +169,12 @@ protected boolean Validate(ParserSession PS, Schema ParentSchema)
PS.AddError("Schema '" + _ParentSchema.getFullName() + "' is declaring " + _TildaType.name() + " '" + getBaseName() + "' with a name that's too long: max allowed by your database is " + PS._CGSql.getMaxColumnNameSize() + " vs " + _Name.length() + " for this identifier.");
if (_Name.equals(TextUtil.sanitizeName(_Name)) == false)
PS.AddError("Schema '" + _ParentSchema.getFullName() + "' is declaring " + _TildaType.name() + " '" + getBaseName() + "' with a name containing invalid characters (must all be alphanumeric or underscore).");

if (ValidationHelper.isValidIdentifier(_Name) == false)
PS.AddError("Schema '" + _ParentSchema.getFullName() + "' is declaring " + _TildaType.name() + " '" + getBaseName() + "' with a name '" + _Name + "' which is not valid. " + ValidationHelper._ValidIdentifierMessage);
if (ValidationHelper.isReservedIdentifier(_Name) == true)
PS.AddError("Schema '" + _ParentSchema.getFullName() + "' is declaring " + _TildaType.name() + " '" + getBaseName() + "' with a name '" + _Name + "' which is a reserved identifier.");

if (TextUtil.isNullOrEmpty(_Description) == true)
PS.AddError("Schema '" + _ParentSchema.getFullName() + "' is declaring " + _TildaType.name() + " '" + getBaseName() + "' without a description.");

Expand Down
4 changes: 4 additions & 0 deletions src/tilda/parsing/parts/Column.java
Original file line number Diff line number Diff line change
Expand Up @@ -214,12 +214,16 @@ private void ValidateBase(ParserSession PS, Object ParentObject)
PS.AddError("Column '" + getFullName() + "' didn't define a 'name'. It is mandatory.");
return;
}

if (N.length() > PS._CGSql.getMaxColumnNameSize())
PS.AddError("Column '" + getFullName() + "' has a name that's too long: max allowed by your database is " + PS._CGSql.getMaxColumnNameSize() + " vs " + N.length() + " for this identifier.");

if (ValidationHelper.isValidIdentifier(N) == false)
PS.AddError("Column '" + getFullName() + "' has a name '" + N + "' which is not valid. " + ValidationHelper._ValidIdentifierMessage);

if (ValidationHelper.isReservedIdentifier(_Name) == true)
PS.AddError("Column '" + getFullName() + "' has a name '" + N + "' which is a reserved identifier.");

if (ValidateSameAs(PS) == false)
return;

Expand Down
4 changes: 3 additions & 1 deletion src/tilda/parsing/parts/ViewColumn.java
Original file line number Diff line number Diff line change
Expand Up @@ -189,13 +189,15 @@ else if (_FCT != FrameworkColumnType.TS)
{
_Name = _SameAsObj.getName();
}

if (_Name.length() > PS._CGSql.getMaxColumnNameSize())
PS.AddError("View Column '" + getFullName() + "' has a name that's too long: max allowed by your database is " + PS._CGSql.getMaxColumnNameSize() + " vs " + _Name.length() + " for this identifier.");
if (_Name.equals(TextUtil.sanitizeName(_Name)) == false)
PS.AddError("View Column '" + getFullName() + "' has a name containing invalid characters (must all be alphanumeric or underscore).");
if (ValidationHelper.isValidIdentifier(_Name) == false)
PS.AddError("View Column '" + getFullName() + "' has a name '" + _Name + "' which is not valid. " + ValidationHelper._ValidIdentifierMessage);
if (ValidationHelper.isReservedIdentifier(_Name) == true)
PS.AddError("View Column '" + getFullName() + "' has a name '" + _Name + "' which is a reserved identifier.");


if (_JoinStr != null)
Expand Down
3 changes: 2 additions & 1 deletion src/tilda/parsing/parts/helpers/ValidationHelper.java
Original file line number Diff line number Diff line change
Expand Up @@ -81,12 +81,13 @@ public static boolean isValidIdentifier(String Name)
for (int i = 1; i < chars.length; ++i)
if (Character.isJavaIdentifierPart(chars[i]) == false)
return false;

return true;
}

public static boolean isReservedIdentifier(String name)
{
if (name.equalsIgnoreCase("class") == true)
if (name != null && name.equalsIgnoreCase("class") == true)
return true;

return false;
Expand Down

0 comments on commit fe85d70

Please sign in to comment.