dctx

package
v1.0.21 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 31, 2026 License: Apache-2.0 Imports: 7 Imported by: 0

README

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

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Writer

type Writer struct {
	// contains filtered or unexported fields
}

Writer implements the writers.Writer interface for DCTX format

func NewWriter

func NewWriter(options *writers.WriterOptions) *Writer

NewWriter creates a new DCTX writer with the given options

func (*Writer) WriteDatabase

func (w *Writer) WriteDatabase(db *models.Database) error

WriteDatabase is not implemented for DCTX

func (*Writer) WriteSchema

func (w *Writer) WriteSchema(schema *models.Schema) error

WriteSchema writes a schema to the writer in DCTX format

func (*Writer) WriteTable

func (w *Writer) WriteTable(table *models.Table) error

WriteTable writes a single table to the writer in DCTX format

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL