@mikro-orm/sqlite 6.4.7-dev.0 → 7.0.0-dev.0

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.
package/README.md CHANGED
@@ -183,7 +183,6 @@ yarn add @mikro-orm/core @mikro-orm/mariadb # for mysql/mariadb
183
183
  yarn add @mikro-orm/core @mikro-orm/postgresql # for postgresql
184
184
  yarn add @mikro-orm/core @mikro-orm/mssql # for mssql
185
185
  yarn add @mikro-orm/core @mikro-orm/sqlite # for sqlite
186
- yarn add @mikro-orm/core @mikro-orm/better-sqlite # for better-sqlite
187
186
  yarn add @mikro-orm/core @mikro-orm/libsql # for libsql
188
187
  ```
189
188
 
@@ -196,7 +195,6 @@ npm i -s @mikro-orm/core @mikro-orm/mariadb # for mysql/mariadb
196
195
  npm i -s @mikro-orm/core @mikro-orm/postgresql # for postgresql
197
196
  npm i -s @mikro-orm/core @mikro-orm/mssql # for mssql
198
197
  npm i -s @mikro-orm/core @mikro-orm/sqlite # for sqlite
199
- npm i -s @mikro-orm/core @mikro-orm/better-sqlite # for better-sqlite
200
198
  npm i -s @mikro-orm/core @mikro-orm/libsql # for libsql
201
199
  ```
202
200
 
@@ -1,5 +1,7 @@
1
- import { BaseSqliteConnection } from '@mikro-orm/knex';
1
+ import { BaseSqliteConnection, type Dictionary } from '@mikro-orm/knex';
2
+ import { SqliteDialect } from 'kysely';
2
3
  export declare class SqliteConnection extends BaseSqliteConnection {
3
- createKnex(): void;
4
- protected transformRawResult<T>(res: any, method: 'all' | 'get' | 'run'): T;
4
+ private database;
5
+ createKyselyDialect(options: Dictionary): SqliteDialect;
6
+ loadFile(path: string): Promise<void>;
5
7
  }
@@ -1,31 +1,25 @@
1
1
  "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
2
5
  Object.defineProperty(exports, "__esModule", { value: true });
3
6
  exports.SqliteConnection = void 0;
4
7
  const knex_1 = require("@mikro-orm/knex");
8
+ const kysely_1 = require("kysely");
9
+ const better_sqlite3_1 = __importDefault(require("better-sqlite3"));
10
+ const fs_extra_1 = require("fs-extra");
5
11
  class SqliteConnection extends knex_1.BaseSqliteConnection {
6
- createKnex() {
7
- this.client = this.createKnexClient(knex_1.SqliteKnexDialect);
8
- this.connected = true;
12
+ database;
13
+ createKyselyDialect(options) {
14
+ const dbName = options.dbName ?? this.config.get('dbName');
15
+ this.database = new better_sqlite3_1.default(dbName, options);
16
+ return new kysely_1.SqliteDialect({
17
+ database: this.database,
18
+ onCreateConnection: this.options.onCreateConnection ?? this.config.get('onCreateConnection'),
19
+ });
9
20
  }
10
- transformRawResult(res, method) {
11
- if (method === 'get') {
12
- return res[0];
13
- }
14
- if (method === 'all') {
15
- return res;
16
- }
17
- if (Array.isArray(res)) {
18
- return {
19
- insertId: res[res.length - 1]?.id ?? 0,
20
- affectedRows: res.length,
21
- row: res[0],
22
- rows: res,
23
- };
24
- }
25
- return {
26
- insertId: res.lastID,
27
- affectedRows: res.changes,
28
- };
21
+ async loadFile(path) {
22
+ this.database.exec((await (0, fs_extra_1.readFile)(path)).toString());
29
23
  }
30
24
  }
31
25
  exports.SqliteConnection = SqliteConnection;
package/SqliteDriver.js CHANGED
@@ -6,7 +6,7 @@ const SqliteConnection_1 = require("./SqliteConnection");
6
6
  const SqlitePlatform_1 = require("./SqlitePlatform");
7
7
  class SqliteDriver extends knex_1.AbstractSqlDriver {
8
8
  constructor(config) {
9
- super(config, new SqlitePlatform_1.SqlitePlatform(), SqliteConnection_1.SqliteConnection, ['knex', 'sqlite3']);
9
+ super(config, new SqlitePlatform_1.SqlitePlatform(), SqliteConnection_1.SqliteConnection, ['kysely', 'better-sqlite3']);
10
10
  }
11
11
  }
12
12
  exports.SqliteDriver = SqliteDriver;
@@ -1,8 +1,4 @@
1
1
  import { BaseSqlitePlatform } from '@mikro-orm/knex';
2
- import { SqliteSchemaHelper } from './SqliteSchemaHelper';
3
- import { SqliteExceptionConverter } from './SqliteExceptionConverter';
4
2
  export declare class SqlitePlatform extends BaseSqlitePlatform {
5
- protected readonly schemaHelper: SqliteSchemaHelper;
6
- protected readonly exceptionConverter: SqliteExceptionConverter;
7
3
  escape(value: any): string;
8
4
  }
package/SqlitePlatform.js CHANGED
@@ -4,11 +4,7 @@ exports.SqlitePlatform = void 0;
4
4
  // @ts-ignore
5
5
  const sqlstring_sqlite_1 = require("sqlstring-sqlite");
6
6
  const knex_1 = require("@mikro-orm/knex");
7
- const SqliteSchemaHelper_1 = require("./SqliteSchemaHelper");
8
- const SqliteExceptionConverter_1 = require("./SqliteExceptionConverter");
9
7
  class SqlitePlatform extends knex_1.BaseSqlitePlatform {
10
- schemaHelper = new SqliteSchemaHelper_1.SqliteSchemaHelper(this);
11
- exceptionConverter = new SqliteExceptionConverter_1.SqliteExceptionConverter();
12
8
  escape(value) {
13
9
  return (0, sqlstring_sqlite_1.escape)(value, true, this.timezone);
14
10
  }
package/index.d.ts CHANGED
@@ -2,6 +2,4 @@ export * from '@mikro-orm/knex';
2
2
  export * from './SqliteConnection';
3
3
  export * from './SqliteDriver';
4
4
  export * from './SqlitePlatform';
5
- export * from './SqliteSchemaHelper';
6
- export * from './SqliteExceptionConverter';
7
5
  export { SqliteMikroORM as MikroORM, SqliteOptions as Options, defineSqliteConfig as defineConfig, } from './SqliteMikroORM';
package/index.js CHANGED
@@ -20,8 +20,6 @@ __exportStar(require("@mikro-orm/knex"), exports);
20
20
  __exportStar(require("./SqliteConnection"), exports);
21
21
  __exportStar(require("./SqliteDriver"), exports);
22
22
  __exportStar(require("./SqlitePlatform"), exports);
23
- __exportStar(require("./SqliteSchemaHelper"), exports);
24
- __exportStar(require("./SqliteExceptionConverter"), exports);
25
23
  var SqliteMikroORM_1 = require("./SqliteMikroORM");
26
24
  Object.defineProperty(exports, "MikroORM", { enumerable: true, get: function () { return SqliteMikroORM_1.SqliteMikroORM; } });
27
25
  Object.defineProperty(exports, "defineConfig", { enumerable: true, get: function () { return SqliteMikroORM_1.defineSqliteConfig; } });
package/index.mjs CHANGED
@@ -19,12 +19,10 @@ export const ArrayType = mod.ArrayType;
19
19
  export const BaseEntity = mod.BaseEntity;
20
20
  export const BaseSqliteConnection = mod.BaseSqliteConnection;
21
21
  export const BaseSqlitePlatform = mod.BaseSqlitePlatform;
22
- export const BaseSqliteSchemaHelper = mod.BaseSqliteSchemaHelper;
23
22
  export const BeforeCreate = mod.BeforeCreate;
24
23
  export const BeforeDelete = mod.BeforeDelete;
25
24
  export const BeforeUpdate = mod.BeforeUpdate;
26
25
  export const BeforeUpsert = mod.BeforeUpsert;
27
- export const BetterSqliteKnexDialect = mod.BetterSqliteKnexDialect;
28
26
  export const BigIntType = mod.BigIntType;
29
27
  export const BlobType = mod.BlobType;
30
28
  export const BooleanType = mod.BooleanType;
@@ -112,14 +110,12 @@ export const JSON_KEY_OPERATORS = mod.JSON_KEY_OPERATORS;
112
110
  export const JoinType = mod.JoinType;
113
111
  export const JsonProperty = mod.JsonProperty;
114
112
  export const JsonType = mod.JsonType;
115
- export const Knex = mod.Knex;
116
- export const LibSqlKnexDialect = mod.LibSqlKnexDialect;
113
+ export const Kysely = mod.Kysely;
117
114
  export const LoadStrategy = mod.LoadStrategy;
118
115
  export const LockMode = mod.LockMode;
119
116
  export const LockWaitTimeoutException = mod.LockWaitTimeoutException;
120
117
  export const ManyToMany = mod.ManyToMany;
121
118
  export const ManyToOne = mod.ManyToOne;
122
- export const MariaDbKnexDialect = mod.MariaDbKnexDialect;
123
119
  export const MediumIntType = mod.MediumIntType;
124
120
  export const MemoryCacheAdapter = mod.MemoryCacheAdapter;
125
121
  export const MetadataDiscovery = mod.MetadataDiscovery;
@@ -129,13 +125,12 @@ export const MetadataStorage = mod.MetadataStorage;
129
125
  export const MetadataValidator = mod.MetadataValidator;
130
126
  export const MikroORM = mod.MikroORM;
131
127
  export const MongoNamingStrategy = mod.MongoNamingStrategy;
132
- export const MonkeyPatchable = mod.MonkeyPatchable;
133
- export const MsSqlKnexDialect = mod.MsSqlKnexDialect;
134
- export const MySqlConnection = mod.MySqlConnection;
128
+ export const MsSqlNativeQueryBuilder = mod.MsSqlNativeQueryBuilder;
135
129
  export const MySqlExceptionConverter = mod.MySqlExceptionConverter;
136
- export const MySqlKnexDialect = mod.MySqlKnexDialect;
130
+ export const MySqlNativeQueryBuilder = mod.MySqlNativeQueryBuilder;
137
131
  export const MySqlPlatform = mod.MySqlPlatform;
138
132
  export const MySqlSchemaHelper = mod.MySqlSchemaHelper;
133
+ export const NativeQueryBuilder = mod.NativeQueryBuilder;
139
134
  export const NodeState = mod.NodeState;
140
135
  export const NonUniqueFieldNameException = mod.NonUniqueFieldNameException;
141
136
  export const NotFoundError = mod.NotFoundError;
@@ -155,7 +150,7 @@ export const PlainObject = mod.PlainObject;
155
150
  export const Platform = mod.Platform;
156
151
  export const PopulateHint = mod.PopulateHint;
157
152
  export const PopulatePath = mod.PopulatePath;
158
- export const PostgreSqlKnexDialect = mod.PostgreSqlKnexDialect;
153
+ export const PostgreSqlNativeQueryBuilder = mod.PostgreSqlNativeQueryBuilder;
159
154
  export const PrimaryKey = mod.PrimaryKey;
160
155
  export const PrimaryKeyProp = mod.PrimaryKeyProp;
161
156
  export const Property = mod.Property;
@@ -167,6 +162,7 @@ export const QueryOperator = mod.QueryOperator;
167
162
  export const QueryOrder = mod.QueryOrder;
168
163
  export const QueryOrderNumeric = mod.QueryOrderNumeric;
169
164
  export const QueryType = mod.QueryType;
165
+ export const Raw = mod.Raw;
170
166
  export const RawQueryFragment = mod.RawQueryFragment;
171
167
  export const ReadOnlyException = mod.ReadOnlyException;
172
168
  export const Ref = mod.Ref;
@@ -191,10 +187,9 @@ export const SqlSchemaGenerator = mod.SqlSchemaGenerator;
191
187
  export const SqliteConnection = mod.SqliteConnection;
192
188
  export const SqliteDriver = mod.SqliteDriver;
193
189
  export const SqliteExceptionConverter = mod.SqliteExceptionConverter;
194
- export const SqliteKnexDialect = mod.SqliteKnexDialect;
190
+ export const SqliteNativeQueryBuilder = mod.SqliteNativeQueryBuilder;
195
191
  export const SqlitePlatform = mod.SqlitePlatform;
196
192
  export const SqliteSchemaHelper = mod.SqliteSchemaHelper;
197
- export const SqliteTableCompiler = mod.SqliteTableCompiler;
198
193
  export const StringType = mod.StringType;
199
194
  export const SyntaxErrorException = mod.SyntaxErrorException;
200
195
  export const TableExistsException = mod.TableExistsException;
@@ -228,7 +223,7 @@ export const equals = mod.equals;
228
223
  export const getOnConflictFields = mod.getOnConflictFields;
229
224
  export const getOnConflictReturningFields = mod.getOnConflictReturningFields;
230
225
  export const helper = mod.helper;
231
- export const knex = mod.knex;
226
+ export const isRaw = mod.isRaw;
232
227
  export const parseJsonSafe = mod.parseJsonSafe;
233
228
  export const raw = mod.raw;
234
229
  export const ref = mod.ref;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mikro-orm/sqlite",
3
- "version": "6.4.7-dev.0",
3
+ "version": "7.0.0-dev.0",
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",
@@ -46,7 +46,7 @@
46
46
  },
47
47
  "homepage": "https://mikro-orm.io",
48
48
  "engines": {
49
- "node": ">= 18.12.0"
49
+ "node": ">= 22.11.0"
50
50
  },
51
51
  "scripts": {
52
52
  "build": "yarn clean && yarn compile && yarn copy && yarn run -T gen-esm-wrapper index.js index.mjs",
@@ -58,15 +58,15 @@
58
58
  "access": "public"
59
59
  },
60
60
  "dependencies": {
61
- "@mikro-orm/knex": "6.4.7-dev.0",
61
+ "@mikro-orm/knex": "7.0.0-dev.0",
62
+ "better-sqlite3": "11.8.1",
62
63
  "fs-extra": "11.3.0",
63
- "sqlite3": "5.1.7",
64
64
  "sqlstring-sqlite": "0.1.1"
65
65
  },
66
66
  "devDependencies": {
67
- "@mikro-orm/core": "^6.4.6"
67
+ "@mikro-orm/core": "^6.4.5"
68
68
  },
69
69
  "peerDependencies": {
70
- "@mikro-orm/core": "6.4.7-dev.0"
70
+ "@mikro-orm/core": "7.0.0-dev.0"
71
71
  }
72
72
  }
@@ -1,9 +0,0 @@
1
- import { ExceptionConverter, type Dictionary, type DriverException } from '@mikro-orm/core';
2
- export declare class SqliteExceptionConverter extends ExceptionConverter {
3
- /**
4
- * @inheritDoc
5
- * @link http://www.sqlite.org/c3ref/c_abort.html
6
- * @link https://github.com/doctrine/dbal/blob/master/src/Driver/AbstractSQLiteDriver.php
7
- */
8
- convertException(exception: Error & Dictionary): DriverException;
9
- }
@@ -1,55 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.SqliteExceptionConverter = void 0;
4
- const core_1 = require("@mikro-orm/core");
5
- class SqliteExceptionConverter extends core_1.ExceptionConverter {
6
- /* istanbul ignore next */
7
- /**
8
- * @inheritDoc
9
- * @link http://www.sqlite.org/c3ref/c_abort.html
10
- * @link https://github.com/doctrine/dbal/blob/master/src/Driver/AbstractSQLiteDriver.php
11
- */
12
- convertException(exception) {
13
- if (exception.message.includes('database is locked')) {
14
- return new core_1.LockWaitTimeoutException(exception);
15
- }
16
- if (exception.message.includes('must be unique') ||
17
- exception.message.includes('is not unique') ||
18
- exception.message.includes('are not unique') ||
19
- exception.message.includes('UNIQUE constraint failed')) {
20
- return new core_1.UniqueConstraintViolationException(exception);
21
- }
22
- if (exception.message.includes('may not be NULL') || exception.message.includes('NOT NULL constraint failed')) {
23
- return new core_1.NotNullConstraintViolationException(exception);
24
- }
25
- if (exception.message.includes('CHECK constraint failed')) {
26
- return new core_1.CheckConstraintViolationException(exception);
27
- }
28
- if (exception.message.includes('no such table:')) {
29
- return new core_1.TableNotFoundException(exception);
30
- }
31
- if (exception.message.includes('already exists')) {
32
- return new core_1.TableExistsException(exception);
33
- }
34
- if (exception.message.includes('no such column:')) {
35
- return new core_1.InvalidFieldNameException(exception);
36
- }
37
- if (exception.message.includes('ambiguous column name')) {
38
- return new core_1.NonUniqueFieldNameException(exception);
39
- }
40
- if (exception.message.includes('syntax error')) {
41
- return new core_1.SyntaxErrorException(exception);
42
- }
43
- if (exception.message.includes('attempt to write a readonly database')) {
44
- return new core_1.ReadOnlyException(exception);
45
- }
46
- if (exception.message.includes('unable to open database file')) {
47
- return new core_1.ConnectionException(exception);
48
- }
49
- if (exception.message.includes('FOREIGN KEY constraint failed')) {
50
- return new core_1.ForeignKeyConstraintViolationException(exception);
51
- }
52
- return super.convertException(exception);
53
- }
54
- }
55
- exports.SqliteExceptionConverter = SqliteExceptionConverter;
@@ -1,3 +0,0 @@
1
- import { BaseSqliteSchemaHelper } from '@mikro-orm/knex';
2
- export declare class SqliteSchemaHelper extends BaseSqliteSchemaHelper {
3
- }
@@ -1,7 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.SqliteSchemaHelper = void 0;
4
- const knex_1 = require("@mikro-orm/knex");
5
- class SqliteSchemaHelper extends knex_1.BaseSqliteSchemaHelper {
6
- }
7
- exports.SqliteSchemaHelper = SqliteSchemaHelper;