Files
Hein 666eab7cec
Some checks failed
CI / Test (1.24) (push) Failing after -24m41s
CI / Test (1.25) (push) Failing after -24m25s
CI / Lint (push) Failing after -25m49s
CI / Build (push) Successful in -26m3s
Updated Readme files
2025-12-28 10:34:20 +02:00
..
2025-12-28 10:34:20 +02:00
2025-12-17 22:52:24 +02:00
2025-12-17 22:52:24 +02:00
2025-12-18 13:38:32 +02:00

DCTX Writer

Generates Clarion database dictionary (DCTX) files from database schema information.

Overview

The DCTX Writer converts RelSpec's internal database model representation into Clarion dictionary XML format, used by the Clarion development platform.

Features

  • Generates DCTX XML format
  • Creates file (table) definitions
  • Defines fields (columns) with Clarion types
  • Includes keys (indexes)
  • Handles relationships

Usage

Basic Example

package main

import (
    "git.warky.dev/wdevs/relspecgo/pkg/models"
    "git.warky.dev/wdevs/relspecgo/pkg/writers"
    "git.warky.dev/wdevs/relspecgo/pkg/writers/dctx"
)

func main() {
    options := &writers.WriterOptions{
        OutputPath: "database.dctx",
    }

    writer := dctx.NewWriter(options)
    err := writer.WriteDatabase(db)
    if err != nil {
        panic(err)
    }
}

CLI Examples

# Generate DCTX from PostgreSQL database (for Clarion migration)
relspec --input pgsql \
  --conn "postgres://localhost/mydb" \
  --output dctx \
  --out-file app.dctx

# Convert GORM models to DCTX
relspec --input gorm --in-file models.go --output dctx --out-file legacy.dctx

# Convert JSON schema to DCTX
relspec --input json --in-file schema.json --output dctx --out-file database.dctx

Type Mapping

Converts standard SQL types to Clarion types:

SQL Type Clarion Type Notes
VARCHAR(n) STRING(n) Fixed-length string
TEXT STRING Variable length
INTEGER LONG 32-bit integer
BIGINT DECIMAL(20,0) Large integer
SMALLINT SHORT 16-bit integer
NUMERIC(p,s) DECIMAL(p,s) Decimal number
REAL, FLOAT REAL Floating point
BOOLEAN BYTE 0/1 value
DATE DATE Date field
TIME TIME Time field
TIMESTAMP LONG Unix timestamp

DCTX Structure

DCTX files are XML-based with this structure:

<?xml version="1.0"?>
<dictionary>
  <file name="USERS" driver="TOPSPEED">
    <record>
      <field name="ID" type="LONG" />
      <field name="USERNAME" type="STRING" bytes="50" />
      <field name="EMAIL" type="STRING" bytes="100" />
    </record>
    <key name="KEY_PRIMARY" primary="true">
      <field name="ID" />
    </key>
  </file>
</dictionary>

Features

  • File definitions (equivalent to tables)
  • Field definitions with Clarion-specific types
  • Key definitions (primary and foreign)
  • Relationships between files
  • Driver specifications (TOPSPEED, SQL, etc.)

Notes

  • DCTX is specific to Clarion development
  • Useful for legacy system integration
  • Field names are typically uppercase in Clarion
  • Supports Clarion-specific attributes
  • Can be imported into Clarion IDE