import { entityKind } from "../../entity.js";
import { getColumnNameAndConfig } from "../../utils.js";
import { CockroachColumn, CockroachColumnWithArrayBuilder } from "./common.js";
class CockroachIntervalBuilder extends CockroachColumnWithArrayBuilder {
  static [entityKind] = "CockroachIntervalBuilder";
  constructor(name, intervalConfig) {
    super(name, "string", "CockroachInterval");
    this.config.intervalConfig = intervalConfig;
  }
  /** @internal */
  build(table) {
    return new CockroachInterval(
      table,
      this.config
    );
  }
}
class CockroachInterval extends CockroachColumn {
  static [entityKind] = "CockroachInterval";
  fields = this.config.intervalConfig.fields;
  precision = this.config.intervalConfig.precision;
  getSQLType() {
    const fields = this.fields ? ` ${this.fields}` : "";
    const precision = this.precision ? `(${this.precision})` : "";
    return `interval${fields}${precision}`;
  }
}
function interval(a, b = {}) {
  const { name, config } = getColumnNameAndConfig(a, b);
  return new CockroachIntervalBuilder(name, config);
}
export {
  CockroachInterval,
  CockroachIntervalBuilder,
  interval
};
//# sourceMappingURL=interval.js.map