Files
warkanum 96281c9f03
Release / test (push) Failing after 2m20s
Release / release (push) Skipped
Release / pkg-aur (push) Skipped
Release / pkg-deb (push) Skipped
Release / pkg-rpm (push) Skipped
chore(ci): add govulncheck, staticcheck, go vet, gofumpt gates
* Add lint/format checks to the Gitea release workflow and Makefile
  (targets: vet, fmt, fmt-check, staticcheck, govulncheck, check)
* Switch .golangci.json formatter from gofmt to gofumpt (extra.group-params)
* Bump golang.org/x/text 0.37.0 -> 0.39.0 for GO-2026-5970; re-vendor
* Fix staticcheck S1011 in pkg/diff; drop unused pgsql writer helpers
* Fix gocritic unnamedResult (pkg/diff) and rangeValCopy (pkg/pgsql)
* Apply gofumpt + goimports formatting across the tree
2026-09-03 21:17:03 +02:00
..
2025-12-28 10:34:20 +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