TenantAtlas/apps/platform/.pnpm-store/v10/files/52/57947f17edf0dfd6c95287ad1b9d4db451774a19cc293319cac19e9e6bacf5daf1553ac14d88d675923d1313154c489fc3e1711ce066db1e53d2820a86407a
Ahmed Darrazi 9f74f7a658
Some checks failed
PR Fast Feedback / fast-feedback (pull_request) Failing after 51s
feat: compress governance operator outcomes
2026-04-19 14:15:11 +02:00

40 lines
1.1 KiB
Plaintext

import { entityKind } from "../../entity.js";
import { getColumnNameAndConfig } from "../../utils.js";
import { MySqlColumn, MySqlColumnBuilder } from "./common.js";
class MySqlBinaryBuilder extends MySqlColumnBuilder {
static [entityKind] = "MySqlBinaryBuilder";
constructor(name, length) {
super(name, "string", "MySqlBinary");
this.config.length = length;
}
/** @internal */
build(table) {
return new MySqlBinary(table, this.config);
}
}
class MySqlBinary extends MySqlColumn {
static [entityKind] = "MySqlBinary";
length = this.config.length;
mapFromDriverValue(value) {
if (typeof value === "string") return value;
if (Buffer.isBuffer(value)) return value.toString();
const str = [];
for (const v of value) {
str.push(v === 49 ? "1" : "0");
}
return str.join("");
}
getSQLType() {
return this.length === void 0 ? `binary` : `binary(${this.length})`;
}
}
function binary(a, b = {}) {
const { name, config } = getColumnNameAndConfig(a, b);
return new MySqlBinaryBuilder(name, config.length);
}
export {
MySqlBinary,
MySqlBinaryBuilder,
binary
};
//# sourceMappingURL=binary.js.map