Initial commit
This commit is contained in:
61
node_modules/drizzle-orm/mysql-core/session.js
generated
vendored
Normal file
61
node_modules/drizzle-orm/mysql-core/session.js
generated
vendored
Normal file
@ -0,0 +1,61 @@
|
||||
import { entityKind } from "../entity.js";
|
||||
import { TransactionRollbackError } from "../errors.js";
|
||||
import { sql } from "../sql/sql.js";
|
||||
import { MySqlDatabase } from "./db.js";
|
||||
class MySqlPreparedQuery {
|
||||
static [entityKind] = "MySqlPreparedQuery";
|
||||
/** @internal */
|
||||
joinsNotNullableMap;
|
||||
}
|
||||
class MySqlSession {
|
||||
constructor(dialect) {
|
||||
this.dialect = dialect;
|
||||
}
|
||||
static [entityKind] = "MySqlSession";
|
||||
execute(query) {
|
||||
return this.prepareQuery(
|
||||
this.dialect.sqlToQuery(query),
|
||||
void 0
|
||||
).execute();
|
||||
}
|
||||
async count(sql2) {
|
||||
const res = await this.execute(sql2);
|
||||
return Number(
|
||||
res[0][0]["count"]
|
||||
);
|
||||
}
|
||||
getSetTransactionSQL(config) {
|
||||
const parts = [];
|
||||
if (config.isolationLevel) {
|
||||
parts.push(`isolation level ${config.isolationLevel}`);
|
||||
}
|
||||
return parts.length ? sql`set transaction ${sql.raw(parts.join(" "))}` : void 0;
|
||||
}
|
||||
getStartTransactionSQL(config) {
|
||||
const parts = [];
|
||||
if (config.withConsistentSnapshot) {
|
||||
parts.push("with consistent snapshot");
|
||||
}
|
||||
if (config.accessMode) {
|
||||
parts.push(config.accessMode);
|
||||
}
|
||||
return parts.length ? sql`start transaction ${sql.raw(parts.join(" "))}` : void 0;
|
||||
}
|
||||
}
|
||||
class MySqlTransaction extends MySqlDatabase {
|
||||
constructor(dialect, session, schema, nestedIndex, mode) {
|
||||
super(dialect, session, schema, mode);
|
||||
this.schema = schema;
|
||||
this.nestedIndex = nestedIndex;
|
||||
}
|
||||
static [entityKind] = "MySqlTransaction";
|
||||
rollback() {
|
||||
throw new TransactionRollbackError();
|
||||
}
|
||||
}
|
||||
export {
|
||||
MySqlPreparedQuery,
|
||||
MySqlSession,
|
||||
MySqlTransaction
|
||||
};
|
||||
//# sourceMappingURL=session.js.map
|
||||
Reference in New Issue
Block a user