/**
 * Sybase column type builders.
 *
 * Creates column objects that pass drizzle-orm's `is(col, Column)` check
 * by using the same entityKind symbol mechanism. This ensures compatibility
 * with drizzle-orm operators (eq, ne, gt, sql template, etc.).
 *
 * Does NOT depend on drizzle-orm/mssql-core.
 */
// We use the entityKind symbol to make our classes recognized by drizzle-orm's
// `is()` function without needing to extend the heavily-generic base classes.
const entityKind = Symbol.for("drizzle:entityKind");
// ---------------------------------------------------------------------------
// SybaseColumn — the built column instance attached to tables
// ---------------------------------------------------------------------------
/**
 * Column instance that is attached to tables. Recognized by drizzle-orm's
 * `is(col, Column)` because our prototype chain includes a class with
 * `static [entityKind] = "Column"`.
 */
export class SybaseColumn {
    static [entityKind] = "SybaseColumn";
    // Properties expected by drizzle-orm sql.js when processing Column chunks
    name;
    table;
    isAlias = false;
    // Properties used by our query builders
    primary;
    notNull;
    default;
    defaultFn;
    onUpdateFn;
    hasDefault;
    dataType;
    columnType;
    identity;
    mapFromDriverValue;
    mapToDriverValue;
    constructor(table, config) {
        this.table = table;
        this.name = config.name;
        this.primary = config.primaryKey ?? false;
        this.notNull = config.notNull ?? false;
        this.default = config.default;
        this.defaultFn = config.defaultFn;
        this.onUpdateFn = config.onUpdateFn;
        this.hasDefault = config.hasDefault ?? false;
        this.dataType = config.dataType ?? "string";
        this.columnType = config.columnType ?? "SybaseColumn";
        this.identity = config.identity ?? false;
        this.mapFromDriverValue = config.mapFromDriverValue ?? ((v) => v);
        this.mapToDriverValue = config.mapToDriverValue ?? ((v) => v);
    }
    getSQLType() {
        return this.dataType;
    }
    shouldDisableInsert() {
        return this.identity;
    }
    // SQLWrapper interface — required for drizzle-orm sql template embedding
    getSQL() {
        // Return a minimal SQL wrapper that references this column.
        // The actual SQL generation happens in drizzle-orm's sql.js buildQueryFromSourceParams
        // which checks `is(chunk, Column)` and reads chunk.name/chunk.table directly.
        return { queryChunks: [this] };
    }
}
// Make SybaseColumn pass `is(col, Column)` by inserting a marker
// with entityKind = "Column" in the prototype chain.
function _createColumnMarker() {
    function DrizzleColumnMarker() { }
    Object.defineProperty(DrizzleColumnMarker, entityKind, { value: "Column" });
    return DrizzleColumnMarker;
}
const _ColumnMarker = _createColumnMarker();
Object.setPrototypeOf(SybaseColumn.prototype, _ColumnMarker.prototype);
Object.setPrototypeOf(SybaseColumn, _ColumnMarker);
// ---------------------------------------------------------------------------
// SybaseColumnBuilder — fluent builder used in table definitions
// ---------------------------------------------------------------------------
export class SybaseColumnBuilder {
    /** @internal */
    _config;
    constructor(name, sqlType) {
        this._config = {
            name,
            dataType: sqlType,
            columnType: "SybaseColumn",
            primaryKey: false,
            notNull: false,
            hasDefault: false,
            identity: false
        };
    }
    primaryKey() {
        this._config.primaryKey = true;
        this._config.notNull = true;
        return this;
    }
    notNull() {
        this._config.notNull = true;
        return this;
    }
    identity() {
        this._config.identity = true;
        return this;
    }
    default(value) {
        this._config.default = value;
        this._config.hasDefault = true;
        return this;
    }
    $defaultFn(fn) {
        this._config.defaultFn = fn;
        this._config.hasDefault = true;
        return this;
    }
    $onUpdateFn(fn) {
        this._config.onUpdateFn = fn;
        return this;
    }
    /**
     * Set a custom mapToDriverValue function for this column.
     */
    $mapToDriver(fn) {
        this._config.mapToDriverValue = fn;
        return this;
    }
    /**
     * Set a custom mapFromDriverValue function for this column.
     */
    $mapFromDriver(fn) {
        this._config.mapFromDriverValue = fn;
        return this;
    }
    /** @internal — called by sybaseTable to produce the final Column object */
    build(table) {
        return new SybaseColumn(table, this._config);
    }
}
// ---------------------------------------------------------------------------
// Column type factory functions
// ---------------------------------------------------------------------------
export const int = (name) => new SybaseColumnBuilder(name, "int");
export const bigint = (name) => new SybaseColumnBuilder(name, "bigint");
export const smallint = (name) => new SybaseColumnBuilder(name, "smallint");
export const tinyint = (name) => new SybaseColumnBuilder(name, "tinyint");
export const varchar = (name, opts) => new SybaseColumnBuilder(name, opts?.length ? `varchar(${opts.length})` : "varchar");
export const nvarchar = (name, opts) => new SybaseColumnBuilder(name, opts?.length ? `nvarchar(${opts.length})` : "nvarchar");
export const char = (name, opts) => new SybaseColumnBuilder(name, opts?.length ? `char(${opts.length})` : "char");
export const nchar = (name, opts) => new SybaseColumnBuilder(name, opts?.length ? `nchar(${opts.length})` : "nchar");
export const text = (name) => new SybaseColumnBuilder(name, "text");
export const ntext = (name) => new SybaseColumnBuilder(name, "ntext");
export const datetime = (name) => new SybaseColumnBuilder(name, "datetime");
export const smalldatetime = (name) => new SybaseColumnBuilder(name, "smalldatetime");
export const numeric = (name, opts) => {
    let type = "numeric";
    if (opts?.precision !== undefined) {
        type =
            opts.scale !== undefined
                ? `numeric(${opts.precision},${opts.scale})`
                : `numeric(${opts.precision})`;
    }
    return new SybaseColumnBuilder(name, type);
};
export const decimal = (name, opts) => {
    let type = "decimal";
    if (opts?.precision !== undefined) {
        type =
            opts.scale !== undefined
                ? `decimal(${opts.precision},${opts.scale})`
                : `decimal(${opts.precision})`;
    }
    return new SybaseColumnBuilder(name, type);
};
export const float = (name) => new SybaseColumnBuilder(name, "float");
export const real = (name) => new SybaseColumnBuilder(name, "real");
export const money = (name) => new SybaseColumnBuilder(name, "money");
export const smallmoney = (name) => new SybaseColumnBuilder(name, "smallmoney");
export const bit = (name) => new SybaseColumnBuilder(name, "bit");
export const binary = (name, opts) => new SybaseColumnBuilder(name, opts?.length ? `binary(${opts.length})` : "binary");
export const varbinary = (name, opts) => new SybaseColumnBuilder(name, opts?.length ? `varbinary(${opts.length})` : "varbinary");
export const image = (name) => new SybaseColumnBuilder(name, "image");
//# sourceMappingURL=index.js.map