@mikro-orm/knex 7.0.0-dev.0 → 7.0.0-dev.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -89,6 +89,9 @@ class AbstractSqlConnection extends core_1.Connection {
89
89
  if (options.isolationLevel) {
90
90
  trxBuilder = trxBuilder.setIsolationLevel(options.isolationLevel);
91
91
  }
92
+ if (options.readOnly) {
93
+ trxBuilder = trxBuilder.setAccessMode('read only');
94
+ }
92
95
  const trx = await trxBuilder.execute();
93
96
  for (const query of this.platform.getBeginTransactionSQL(options)) {
94
97
  this.logQuery(query);
@@ -1,4 +1,4 @@
1
- import { type SimpleColumnMeta, type Type, type TransformContext } from '@mikro-orm/core';
1
+ import { type SimpleColumnMeta, type Type, type TransformContext, type IsolationLevel } from '@mikro-orm/core';
2
2
  import { MySqlSchemaHelper } from './MySqlSchemaHelper';
3
3
  import { MySqlExceptionConverter } from './MySqlExceptionConverter';
4
4
  import { AbstractSqlPlatform } from '../../AbstractSqlPlatform';
@@ -16,6 +16,10 @@ export declare class MySqlPlatform extends AbstractSqlPlatform {
16
16
  /** @internal */
17
17
  createNativeQueryBuilder(): MySqlNativeQueryBuilder;
18
18
  getDefaultCharset(): string;
19
+ getBeginTransactionSQL(options?: {
20
+ isolationLevel?: IsolationLevel;
21
+ readOnly?: boolean;
22
+ }): string[];
19
23
  convertJsonToDatabaseValue(value: unknown, context?: TransformContext): unknown;
20
24
  getJsonIndexDefinition(index: IndexDef): string[];
21
25
  getBooleanTypeDeclarationSQL(): string;
@@ -22,6 +22,20 @@ class MySqlPlatform extends AbstractSqlPlatform_1.AbstractSqlPlatform {
22
22
  getDefaultCharset() {
23
23
  return 'utf8mb4';
24
24
  }
25
+ getBeginTransactionSQL(options) {
26
+ if (options?.isolationLevel || options?.readOnly) {
27
+ const parts = [];
28
+ if (options.isolationLevel) {
29
+ parts.push(`isolation level ${options.isolationLevel}`);
30
+ }
31
+ if (options.readOnly) {
32
+ parts.push('read only');
33
+ }
34
+ const sql = `set transaction ${parts.join(', ')}`;
35
+ return [sql, 'begin'];
36
+ }
37
+ return ['begin'];
38
+ }
25
39
  convertJsonToDatabaseValue(value, context) {
26
40
  if (context?.mode === 'query') {
27
41
  return value;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mikro-orm/knex",
3
- "version": "7.0.0-dev.0",
3
+ "version": "7.0.0-dev.1",
4
4
  "description": "TypeScript ORM for Node.js based on Data Mapper, Unit of Work and Identity Map patterns. Supports MongoDB, MySQL, PostgreSQL and SQLite databases as well as usage with vanilla JavaScript.",
5
5
  "main": "index.js",
6
6
  "module": "index.mjs",
@@ -59,13 +59,13 @@
59
59
  },
60
60
  "dependencies": {
61
61
  "fs-extra": "11.3.0",
62
- "kysely": "https://pkg.pr.new/kysely-org/kysely/kysely@74aed5d",
62
+ "kysely": "https://pkg.pr.new/kysely-org/kysely/kysely@2b7007e",
63
63
  "sqlstring": "2.3.3"
64
64
  },
65
65
  "devDependencies": {
66
66
  "@mikro-orm/core": "^6.4.5"
67
67
  },
68
68
  "peerDependencies": {
69
- "@mikro-orm/core": "7.0.0-dev.0"
69
+ "@mikro-orm/core": "7.0.0-dev.1"
70
70
  }
71
71
  }