import { compile, extractZqlResult } from "../../z2s/src/compiler.js";
import { formatPgInternalConvert } from "../../z2s/src/sql.js";
async function executePostgresQuery(dbTransaction, ast, format, schema, serverSchema) {
  const sqlQuery = formatPgInternalConvert(
    compile(serverSchema, schema, ast, format)
  );
  const pgIterableResult = await dbTransaction.query(
    sqlQuery.text,
    sqlQuery.values
  );
  const pgArrayResult = Array.isArray(pgIterableResult) ? pgIterableResult : [...pgIterableResult];
  if (pgArrayResult.length === 0 && format.singular) {
    return void 0;
  }
  return extractZqlResult(pgArrayResult);
}
export {
  executePostgresQuery
};
//# sourceMappingURL=pg-query-executor.js.map
