Package com.clickhouse.client.api.sql
Class SQLUtils
java.lang.Object
com.clickhouse.client.api.sql.SQLUtils
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic StringenquoteIdentifier(String identifier) Escapes and quotes an SQL identifier, always adding quotes.static StringenquoteIdentifier(String identifier, boolean quotesRequired) Escapes and quotes an SQL identifier (e.g., table or column name) by enclosing it in double quotes.static StringenquoteLiteral(String str) Escapes and quotes a string literal for use in SQL queries.static Stringstatic booleanisSimpleIdentifier(String identifier) Checks if the given string is a valid simple SQL identifier using a compiled regex pattern.static StringunquoteIdentifier(String str)
-
Constructor Details
-
SQLUtils
public SQLUtils()
-
-
Method Details
-
enquoteLiteral
Escapes and quotes a string literal for use in SQL queries.- Parameters:
str- the string to be quoted, cannot be null- Returns:
- the quoted and escaped string
- Throws:
IllegalArgumentException- if the input string is null
-
enquoteIdentifier
Escapes and quotes an SQL identifier (e.g., table or column name) by enclosing it in double quotes. Any existing double quotes in the identifier are escaped by doubling them.- Parameters:
identifier- the identifier to be quoted, cannot be nullquotesRequired- if false, the identifier will only be quoted if it contains special characters- Returns:
- the quoted and escaped identifier, or the original identifier if quoting is not required
- Throws:
IllegalArgumentException- if the input identifier is null
-
enquoteIdentifier
Escapes and quotes an SQL identifier, always adding quotes.- Parameters:
identifier- the identifier to be quoted, cannot be null- Returns:
- the quoted and escaped identifier
- Throws:
IllegalArgumentException- if the input identifier is null- See Also:
-
isSimpleIdentifier
Checks if the given string is a valid simple SQL identifier using a compiled regex pattern. A simple identifier must match the pattern: ^[a-zA-Z][a-zA-Z0-9_]{0,127}$- Parameters:
identifier- the identifier to check- Returns:
- true if the identifier is a valid simple SQL identifier, false otherwise
- Throws:
IllegalArgumentException- if the input identifier is null
-
unquoteIdentifier
-
escapeSingleQuotes
-