ldbc.schemaspy.builder.DbmsMetaBuilder.scala Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of ldbc-schemaspy_3 Show documentation
Show all versions of ldbc-schemaspy_3 Show documentation
Project to generate SchemaSPY documentation
The newest version!
/**
* Copyright (c) 2023-2024 by Takahiko Tominaga
* This software is licensed under the MIT License (MIT).
* For more information see LICENSE or https://opensource.org/licenses/MIT
*/
package ldbc.schemaspy.builder
import scala.jdk.CollectionConverters.*
import org.schemaspy.model.DbmsMeta
import ldbc.core.Database
class DbmsMetaBuilder(database: Database):
def build: DbmsMeta =
val builder = new DbmsMeta.Builder()
builder.productName(database.databaseType.toString)
builder.productVersion("5.7.39")
builder.sqlKeywords((DbmsMetaBuilder.sql92Keywords ++ DbmsMetaBuilder.sqlKeywords).asJava)
builder.systemFunctions(
"DATABASE,USER,SYSTEM_USER,SESSION_USER,PASSWORD,ENCRYPT,LAST_INSERT_ID,VERSION".split(",").toSet.asJava
)
builder.stringFunctions(
"ASCII,BIN,BIT_LENGTH,CHAR,CHARACTER_LENGTH,CHAR_LENGTH,CONCAT,CONCAT_WS,CONV,ELT,EXPORT_SET,FIELD,FIND_IN_SET,HEX,INSERT,INSTR,LCASE,LEFT,LENGTH,LOAD_FILE,LOCATE,LOCATE,LOWER,LPAD,LTRIM,MAKE_SET,MATCH,MID,OCT,OCTET_LENGTH,ORD,POSITION,QUOTE,REPEAT,REPLACE,REVERSE,RIGHT,RPAD,RTRIM,SOUNDEX,SPACE,STRCMP,SUBSTRING,SUBSTRING,SUBSTRING,SUBSTRING,SUBSTRING_INDEX,TRIM,UCASE,UPPER"
.split(",")
.toSet
.asJava
)
builder.numericFunctions(
"ABS,ACOS,ASIN,ATAN,ATAN2,BIT_COUNT,CEILING,COS,COT,DEGREES,EXP,FLOOR,LOG,LOG10,MAX,MIN,MOD,PI,POW,POWER,RADIANS,RAND,ROUND,SIN,SQRT,TAN,TRUNCATE"
.split(",")
.toSet
.asJava
)
builder.timeDateFunctions(
"DAYOFWEEK,WEEKDAY,DAYOFMONTH,DAYOFYEAR,MONTH,DAYNAME,MONTHNAME,QUARTER,WEEK,YEAR,HOUR,MINUTE,SECOND,PERIOD_ADD,PERIOD_DIFF,TO_DAYS,FROM_DAYS,DATE_FORMAT,TIME_FORMAT,CURDATE,CURRENT_DATE,CURTIME,CURRENT_TIME,NOW,SYSDATE,CURRENT_TIMESTAMP,UNIX_TIMESTAMP,FROM_UNIXTIME,SEC_TO_TIME,TIME_TO_SEC"
.split(",")
.toSet
.asJava
)
builder.getDbmsMeta
object DbmsMetaBuilder:
private[ldbc] val sqlKeywords: Set[String] =
"ACCESSIBLE,ADD,ANALYZE,ASC,BEFORE,CASCADE,CHANGE,CONTINUE,DATABASE,DATABASES,DAY_HOUR,DAY_MICROSECOND,DAY_MINUTE,DAY_SECOND,DELAYED,DESC,DISTINCTROW,DIV,DUAL,ELSEIF,EMPTY,ENCLOSED,ESCAPED,EXIT,EXPLAIN,FIRST_VALUE,FLOAT4,FLOAT8,FORCE,FULLTEXT,GENERATED,GROUPS,HIGH_PRIORITY,HOUR_MICROSECOND,HOUR_MINUTE,HOUR_SECOND,IF,IGNORE,INDEX,INFILE,INT1,INT2,INT3,INT4,INT8,IO_AFTER_GTIDS,IO_BEFORE_GTIDS,ITERATE,JSON_TABLE,KEY,KEYS,KILL,LAG,LAST_VALUE,LEAD,LEAVE,LIMIT,LINEAR,LINES,LOAD,LOCK,LONG,LONGBLOB,LONGTEXT,LOOP,LOW_PRIORITY,MAXVALUE,MEDIUMBLOB,MEDIUMINT,MEDIUMTEXT,MIDDLEINT,MINUTE_MICROSECOND,MINUTE_SECOND,NO_WRITE_TO_BINLOG,NTH_VALUE,NTILE,OPTIMIZE,OPTIMIZER_COSTS,OPTION,OPTIONALLY,OUTFILE,PURGE,READ,READ_WRITE,REGEXP,RENAME,REPEAT,REPLACE,REQUIRE,RESIGNAL,RESTRICT,RLIKE,SCHEMA,SCHEMAS,SECOND_MICROSECOND,SEPARATOR,SHOW,SIGNAL,SPATIAL,SQL_BIG_RESULT,SQL_CALC_FOUND_ROWS,SQL_SMALL_RESULT,SSL,STARTING,STORED,STRAIGHT_JOIN,TERMINATED,TINYBLOB,TINYINT,TINYTEXT,UNDO,UNLOCK,UNSIGNED,USAGE,USE,UTC_DATE,UTC_TIME,UTC_TIMESTAMP,VARBINARY,VARCHARACTER,VIRTUAL,WHILE,WRITE,XOR,YEAR_MONTH,ZEROFILL"
.split(",")
.toSet
private[ldbc] val sql92Keywords: Set[String] =
("ADA" +
"| C | CATALOG_NAME | CHARACTER_SET_CATALOG | CHARACTER_SET_NAME" +
"| CHARACTER_SET_SCHEMA | CLASS_ORIGIN | COBOL | COLLATION_CATALOG" +
"| COLLATION_NAME | COLLATION_SCHEMA | COLUMN_NAME | COMMAND_FUNCTION | COMMITTED" +
"| CONDITION_NUMBER | CONNECTION_NAME | CONSTRAINT_CATALOG | CONSTRAINT_NAME" +
"| CONSTRAINT_SCHEMA | CURSOR_NAME" +
"| DATA | DATETIME_INTERVAL_CODE | DATETIME_INTERVAL_PRECISION | DYNAMIC_FUNCTION" +
"| FORTRAN" +
"| LENGTH" +
"| MESSAGE_LENGTH | MESSAGE_OCTET_LENGTH | MESSAGE_TEXT | MORE | MUMPS" +
"| NAME | NULLABLE | NUMBER" +
"| PASCAL | PLI" +
"| REPEATABLE | RETURNED_LENGTH | RETURNED_OCTET_LENGTH | RETURNED_SQLSTATE" +
"| ROW_COUNT" +
"| SCALE | SCHEMA_NAME | SERIALIZABLE | SERVER_NAME | SUBCLASS_ORIGIN" +
"| TABLE_NAME | TYPE" +
"| UNCOMMITTED | UNNAMED" +
"| ABSOLUTE | ACTION | ADD | ALL | ALLOCATE | ALTER | AND" +
"| ANY | ARE | AS | ASC" +
"| ASSERTION | AT | AUTHORIZATION | AVG" +
"| BEGIN | BETWEEN | BIT | BIT_LENGTH | BOTH | BY" +
"| CASCADE | CASCADED | CASE | CAST | CATALOG | CHAR | CHARACTER | CHAR_LENGTH" +
"| CHARACTER_LENGTH | CHECK | CLOSE | COALESCE | COLLATE | COLLATION" +
"| COLUMN | COMMIT | CONNECT | CONNECTION | CONSTRAINT" +
"| CONSTRAINTS | CONTINUE" +
"| CONVERT | CORRESPONDING | COUNT | CREATE | CROSS | CURRENT" +
"| CURRENT_DATE | CURRENT_TIME | CURRENT_TIMESTAMP | CURRENT_USER | CURSOR" +
"| DATE | DAY | DEALLOCATE | DEC | DECIMAL | DECLARE | DEFAULT | DEFERRABLE" +
"| DEFERRED | DELETE | DESC | DESCRIBE | DESCRIPTOR | DIAGNOSTICS" +
"| DISCONNECT | DISTINCT | DOMAIN | DOUBLE | DROP" +
"| ELSE | END | END-EXEC | ESCAPE | EXCEPT | EXCEPTION" +
"| EXEC | EXECUTE | EXISTS" +
"| EXTERNAL | EXTRACT" +
"| FALSE | FETCH | FIRST | FLOAT | FOR | FOREIGN | FOUND | FROM | FULL" +
"| GET | GLOBAL | GO | GOTO | GRANT | GROUP" +
"| HAVING | HOUR" +
"| IDENTITY | IMMEDIATE | IN | INDICATOR | INITIALLY | INNER | INPUT" +
"| INSENSITIVE | INSERT | INT | INTEGER | INTERSECT | INTERVAL | INTO | IS" +
"| ISOLATION" +
"| JOIN" +
"| KEY" +
"| LANGUAGE | LAST | LEADING | LEFT | LEVEL | LIKE | LOCAL | LOWER" +
"| MATCH | MAX | MIN | MINUTE | MODULE | MONTH" +
"| NAMES | NATIONAL | NATURAL | NCHAR | NEXT | NO | NOT | NULL" +
"| NULLIF | NUMERIC" +
"| OCTET_LENGTH | OF | ON | ONLY | OPEN | OPTION | OR" +
"| ORDER | OUTER" +
"| OUTPUT | OVERLAPS" +
"| PAD | PARTIAL | POSITION | PRECISION | PREPARE | PRESERVE | PRIMARY" +
"| PRIOR | PRIVILEGES | PROCEDURE | PUBLIC" +
"| READ | REAL | REFERENCES | RELATIVE | RESTRICT | REVOKE | RIGHT" +
"| ROLLBACK | ROWS" +
"| SCHEMA | SCROLL | SECOND | SECTION | SELECT | SESSION | SESSION_USER | SET" +
"| SIZE | SMALLINT | SOME | SPACE | SQL | SQLCODE | SQLERROR | SQLSTATE" +
"| SUBSTRING | SUM | SYSTEM_USER" +
"| TABLE | TEMPORARY | THEN | TIME | TIMESTAMP | TIMEZONE_HOUR | TIMEZONE_MINUTE" +
"| TO | TRAILING | TRANSACTION | TRANSLATE | TRANSLATION | TRIM | TRUE" +
"| UNION | UNIQUE | UNKNOWN | UPDATE | UPPER | USAGE | USER | USING" +
"| VALUE | VALUES | VARCHAR | VARYING | VIEW" +
"| WHEN | WHENEVER | WHERE | WITH | WORK | WRITE" +
"| YEAR" +
"| ZONE").split("| ").toSet