Telosys doc
WebsiteTwitterLinkedInNews
  • Telosys documentation
  • Telosys CLI
    • Installation on Linux
    • Installation on Windows
    • CLI configuration
    • CLI commands
    • Getting started
  • Telosys with VSCode
    • Extension installation
    • VSCode settings
    • Telosys terminal in VSCode
    • Telosys editor configuration
  • Telosys with JetBrains IDE
  • Project configuration
  • Project variables
  • Project databases
  • Models and entities
    • Model structure
    • Entity
    • Attribute / Link
    • Annotations
    • Tags
    • Examples
    • Model creation
    • Model installation
    • Models management
  • Bundles of templates
    • Bundle structure
    • Bundle creation
    • Bundles installation
    • Bundles management
    • Velocity language
    • Velocity directives
    • Velocity object types
    • Telosys directives
    • Telosys variables
    • Telosys objects
    • Code snippets
  • Code generation
    • "gen" command
    • "genb" command
  • Target languages
    • C++
    • C#
    • Golang
    • Java
    • JavaScript
    • Kotlin
    • PHP
    • Python
    • Scala
    • TypeScript
  • Target databases (SQL)
    • Predefined rules
    • Specific rules
    • Type size and precision
  • Telosys with Git
    • GitHub usage
    • Install with Git
    • Publish with Git
  • Support the project
  • How to contribute
  • Sponsors
  • IDE and editors
  • Telosys 3 Eclipse plugin
    • Eclipse plugin installation
    • Eclipse customization
    • Telosys 3 database model
Powered by GitBook
On this page
  1. Target databases (SQL)

Specific rules

If your database is not part of the predefined databases, or if the generated SQL does not match your needs, you can define your own SQL generation rules.

To do this, you just need to create a file containing the conversion rules.

The rules file can be specified in the template files (.vm) using the following directive:

#set ( $env.databaseConvFile = $myOwnFile )

Examples:

#set ( $env.databaseConvFile = $fn.fileFromBundle('mydb.properties') )
#set ( $env.databaseConvFile = $fn.fileFromModel('mydb.properties') )

Defining specific conversion rules in a file

A specific rules file is a text file (properties file) containing 2 parts:

  • Naming conventions (prefix "conv.")

  • Type conversion (prefix "type.")

1) Naming conventions:

You can set the naming convention to be applied for tables, columns, primary keys and foreign keys.

There are 4 naming standards (choose one of these):

  • camelCase

  • PascalCase

  • snake_case

  • ANACONDA_CASE

Examples:

conv.tableName  = ANACONDA_CASE
conv.columnName = snake_case
conv.pkName = PascalCase
conv.fkName = camelCase

2) Type conversion:

This part defines how to convert a neutral type (Telosys model type) to an SQL type (in the database).

Syntax:

  • Left side: the neutral type with "type." prefix and optionally the ".autoincr" suffix if used for autoincremented attribute

  • Right side: any string to be used as the SQL type for this neutral type with placeholders for "size" and "precision":

    • "(%s)" : size (optional)

    • "(%S)" : size mandatory

    • "(%p)" : precision (optional)

    • "(%P)" : precision mandatory

Examples:

type.string = VARCHAR(%s)
type.string = VARCHAR2(%s)
  
type.byte          = smallint
type.byte.autoincr = smallserial

type.short          = smallint
type.short.autoincr = smallserial

type.int           = integer
type.int.autoincr  = serial

type.long          = bigint
type.long.autoincr = bigserial

type.decimal   = numeric(%p)
type.decimal   = numeric(%P) 
type.float     = real
type.double    = double precision
  
type.boolean   = boolean
type.boolean   = CHAR(1)

type.date      = date

type.time      = time
type.time      = time with time zone

type.timestamp = timestamp
type.timestamp = timestamp with time zone
  
type.binary    = bytea
PreviousPredefined rulesNextType size and precision

Last updated 2 years ago

See for more information

type size and precision