Files
Hein b4ff4334cc
Some checks failed
CI / Lint (push) Successful in -27m53s
CI / Test (1.24) (push) Successful in -27m31s
CI / Build (push) Successful in -28m13s
CI / Test (1.25) (push) Failing after 1m11s
Integration Tests / Integration Tests (push) Failing after -28m15s
feat(models): 🎉 Add GUID field to various models
* Introduced GUID field to Database, Domain, DomainTable, Schema, Table, View, Sequence, Column, Index, Relationship, Constraint, Enum, and Script models.
* Updated initialization functions to assign new GUIDs using uuid package.
* Enhanced DCTX reader and writer to utilize GUIDs from models where available.
2026-01-04 19:53:17 +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

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