import { entityKind } from "../entity.js";
import { TransactionRollbackError } from "../errors.js";
import { sql } from "../sql/sql.js";
import { MsSqlDatabase } from "./db.js";
class PreparedQuery {
  static [entityKind] = "MsSqlPreparedQuery";
  /** @internal */
  joinsNotNullableMap;
}
class MsSqlSession {
  constructor(dialect) {
    this.dialect = dialect;
  }
  static [entityKind] = "MsSqlSession";
  execute(query) {
    return this.prepareQuery(
      this.dialect.sqlToQuery(query),
      void 0
    ).execute();
  }
  getSetTransactionSQL(config) {
    const parts = [];
    if (config.isolationLevel) {
      parts.push(`isolation level ${config.isolationLevel}`);
    }
    return parts.length ? sql.join(["set transaction ", parts.join(" ")]) : void 0;
  }
  getStartTransactionSQL(_config) {
    return sql`begin transaction`;
  }
}
class MsSqlTransaction extends MsSqlDatabase {
  constructor(dialect, session, schema, nestedIndex) {
    super(dialect, session, schema);
    this.schema = schema;
    this.nestedIndex = nestedIndex;
  }
  static [entityKind] = "MsSqlTransaction";
  rollback() {
    throw new TransactionRollbackError();
  }
}
export {
  MsSqlSession,
  MsSqlTransaction,
  PreparedQuery
};
//# sourceMappingURL=session.js.map