( documentation for Telosys generator version 4.0.0 )
Object for schema creation in SQL language (for a relational database)
with functions for :
- names conversion (table name, column name, pk/fk name)
- field type conversion (neutral type to SQL column type)
It is designed to facilitate DDL commands generation
( CREATE TABLE, ADD CONSTRAINT FOREIGN KEY, etc)
Each instance of this object is dedicated to a database type
To get a new instance use : $factory.newSql('DatabaseName')
or $factory.newSql('DatabaseName', specificConventionsFileName)
Example :
## Get predefined conventions for a standard database (eg 'PostgreSQL')
## Known databases names : 'SQL-ANSI', 'PostgreSQL', 'Oracle', 'SQLServer'
## Database name is not case sensitive
#set( $sql = $factory.newSql('PostgreSQL') )
## Get specific conventions using a specific file located in the bundle of templates
#set( $sql = $factory.newSql('PostgreSQL', $fn.fileFromBundle('postgresql.properties') ) )
Since : 3.4.0
Attributes and methods |
.columnConstraints(AttributeInContext attribute) : String
Returns the column constraints for the given attribute |
.columnName(AttributeInContext attribute) : String
Returns the database column name for the given attribute |
.columnType(AttributeInContext attribute) : String
Converts the attribute neutral type to the corresponding SQL type |
.convertToColumnName(String originalName) : String
Converts the given string to column naming style |
.convertToColumnType(String neutralType, boolean autoInc, BigDecimal size) : String
Converts the given neutral type to column type |
.convertToFkName(String originalName) : String
Converts the given string to foreign key naming style |
.convertToPkName(String originalName) : String
Converts the given string to primary key naming style |
.convertToTableName(String ?) : String
Converts the given string to table naming style |
.databaseConfigFile : String
Returns the target database configuration file |
.databaseName : String
Returns the target database name |
.fkColumns(ForeignKeyInContext ?) : String
Returns a string containing the names of all the columns composing the foreign key |
.fkName(ForeignKeyInContext ?) : String
Returns the name of the given Foreign Key |
.fkOriginTable(ForeignKeyInContext ?) : String
Returns the name of the table for the given Foreign Key |
.fkReferencedColumns(ForeignKeyInContext ?) : String
Returns a string containing the names of all the columns referenced by the foreign key |
.fkReferencedTable(ForeignKeyInContext ?) : String
Returns the name of the referenced table for the given Foreign Key |
.pkColumns(EntityInContext ?) : String
Returns a string containing the names of all the columns composing the primary key |
.tableName(EntityInContext ?) : String
Returns the database table name for the given entity |