@mikro-orm/better-sqlite 6.0.0-dev.92 → 6.0.0-dev.94
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/BetterSqliteConnection.d.ts +2 -4
- package/BetterSqliteConnection.js +19 -8
- package/BetterSqliteExceptionConverter.d.ts +1 -2
- package/BetterSqliteMikroORM.d.ts +1 -2
- package/BetterSqliteMikroORM.js +1 -1
- package/BetterSqlitePlatform.d.ts +2 -1
- package/BetterSqlitePlatform.js +3 -0
- package/BetterSqliteSchemaHelper.d.ts +1 -2
- package/index.mjs +2 -2
- package/package.json +6 -6
|
@@ -1,8 +1,5 @@
|
|
|
1
|
-
import type
|
|
2
|
-
import { AbstractSqlConnection } from '@mikro-orm/knex';
|
|
1
|
+
import { AbstractSqlConnection, type Knex } from '@mikro-orm/knex';
|
|
3
2
|
export declare class BetterSqliteConnection extends AbstractSqlConnection {
|
|
4
|
-
static readonly RUN_QUERY_RE: RegExp;
|
|
5
|
-
static readonly RUN_QUERY_RETURNING: RegExp;
|
|
6
3
|
createKnex(): void;
|
|
7
4
|
connect(): Promise<void>;
|
|
8
5
|
getDefaultClientUrl(): string;
|
|
@@ -14,5 +11,6 @@ export declare class BetterSqliteConnection extends AbstractSqlConnection {
|
|
|
14
11
|
* monkey patch knex' BetterSqlite Dialect so it returns inserted id when doing raw insert query
|
|
15
12
|
*/
|
|
16
13
|
private getPatchedDialect;
|
|
14
|
+
private isRunQuery;
|
|
17
15
|
private getCallMethod;
|
|
18
16
|
}
|
|
@@ -68,7 +68,7 @@ class BetterSqliteConnection extends knex_1.AbstractSqlConnection {
|
|
|
68
68
|
const processResponse = Sqlite3Dialect.prototype.processResponse;
|
|
69
69
|
Sqlite3Dialect.prototype.__patched = true;
|
|
70
70
|
Sqlite3Dialect.prototype.processResponse = (obj, runner) => {
|
|
71
|
-
if (obj.method === 'raw' && obj.sql
|
|
71
|
+
if (obj.method === 'raw' && this.isRunQuery(obj.sql)) {
|
|
72
72
|
return obj.response ?? obj.context;
|
|
73
73
|
}
|
|
74
74
|
return processResponse(obj, runner);
|
|
@@ -130,12 +130,25 @@ class BetterSqliteConnection extends knex_1.AbstractSqlConnection {
|
|
|
130
130
|
};
|
|
131
131
|
return Sqlite3Dialect;
|
|
132
132
|
}
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
133
|
+
isRunQuery(query) {
|
|
134
|
+
query = query.trim().toLowerCase();
|
|
135
|
+
if (query.startsWith('insert into') && query.includes(' returning ')) {
|
|
136
|
+
return false;
|
|
136
137
|
}
|
|
137
|
-
|
|
138
|
-
|
|
138
|
+
return query.startsWith('insert into') ||
|
|
139
|
+
query.startsWith('update') ||
|
|
140
|
+
query.startsWith('delete') ||
|
|
141
|
+
query.startsWith('truncate');
|
|
142
|
+
}
|
|
143
|
+
getCallMethod(obj) {
|
|
144
|
+
if (obj.method === 'raw') {
|
|
145
|
+
const query = obj.sql.trim().toLowerCase();
|
|
146
|
+
if (query.startsWith('insert into') && query.includes(' returning ')) {
|
|
147
|
+
return 'all';
|
|
148
|
+
}
|
|
149
|
+
if (this.isRunQuery(query)) {
|
|
150
|
+
return 'run';
|
|
151
|
+
}
|
|
139
152
|
}
|
|
140
153
|
/* istanbul ignore next */
|
|
141
154
|
switch (obj.method) {
|
|
@@ -151,5 +164,3 @@ class BetterSqliteConnection extends knex_1.AbstractSqlConnection {
|
|
|
151
164
|
}
|
|
152
165
|
}
|
|
153
166
|
exports.BetterSqliteConnection = BetterSqliteConnection;
|
|
154
|
-
BetterSqliteConnection.RUN_QUERY_RE = /^insert into|^update|^delete|^truncate/;
|
|
155
|
-
BetterSqliteConnection.RUN_QUERY_RETURNING = /^insert into ([\s\S])* returning .*/;
|
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import type
|
|
2
|
-
import { ExceptionConverter } from '@mikro-orm/core';
|
|
1
|
+
import { ExceptionConverter, type Dictionary, type DriverException } from '@mikro-orm/core';
|
|
3
2
|
export declare class BetterSqliteExceptionConverter extends ExceptionConverter {
|
|
4
3
|
/**
|
|
5
4
|
* @inheritDoc
|
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import { MikroORM } from '@mikro-orm/core';
|
|
2
|
-
import type { Options, IDatabaseDriver } from '@mikro-orm/core';
|
|
1
|
+
import { MikroORM, type Options, type IDatabaseDriver } from '@mikro-orm/core';
|
|
3
2
|
import { BetterSqliteDriver } from './BetterSqliteDriver';
|
|
4
3
|
/**
|
|
5
4
|
* @inheritDoc
|
package/BetterSqliteMikroORM.js
CHANGED
|
@@ -7,6 +7,7 @@ const BetterSqliteDriver_1 = require("./BetterSqliteDriver");
|
|
|
7
7
|
* @inheritDoc
|
|
8
8
|
*/
|
|
9
9
|
class BetterSqliteMikroORM extends core_1.MikroORM {
|
|
10
|
+
static { this.DRIVER = BetterSqliteDriver_1.BetterSqliteDriver; }
|
|
10
11
|
/**
|
|
11
12
|
* @inheritDoc
|
|
12
13
|
*/
|
|
@@ -21,7 +22,6 @@ class BetterSqliteMikroORM extends core_1.MikroORM {
|
|
|
21
22
|
}
|
|
22
23
|
}
|
|
23
24
|
exports.BetterSqliteMikroORM = BetterSqliteMikroORM;
|
|
24
|
-
BetterSqliteMikroORM.DRIVER = BetterSqliteDriver_1.BetterSqliteDriver;
|
|
25
25
|
/* istanbul ignore next */
|
|
26
26
|
function defineBetterSqliteConfig(options) {
|
|
27
27
|
return (0, core_1.defineConfig)({ driver: BetterSqliteDriver_1.BetterSqliteDriver, ...options });
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type
|
|
1
|
+
import { type EntityProperty } from '@mikro-orm/core';
|
|
2
2
|
import { AbstractSqlPlatform } from '@mikro-orm/knex';
|
|
3
3
|
import { BetterSqliteSchemaHelper } from './BetterSqliteSchemaHelper';
|
|
4
4
|
import { BetterSqliteExceptionConverter } from './BetterSqliteExceptionConverter';
|
|
@@ -38,6 +38,7 @@ export declare class BetterSqlitePlatform extends AbstractSqlPlatform {
|
|
|
38
38
|
getVarcharTypeDeclarationSQL(column: {
|
|
39
39
|
length?: number;
|
|
40
40
|
}): string;
|
|
41
|
+
convertsJsonAutomatically(): boolean;
|
|
41
42
|
allowsComparingTuples(): boolean;
|
|
42
43
|
/**
|
|
43
44
|
* This is used to narrow the value of Date properties as they will be stored as timestamps in sqlite.
|
package/BetterSqlitePlatform.js
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import type { Connection, Dictionary } from '@mikro-orm/core';
|
|
2
|
-
import type
|
|
3
|
-
import { SchemaHelper } from '@mikro-orm/knex';
|
|
2
|
+
import { SchemaHelper, type AbstractSqlConnection, type IndexDef, type CheckDef } from '@mikro-orm/knex';
|
|
4
3
|
export declare class BetterSqliteSchemaHelper extends SchemaHelper {
|
|
5
4
|
disableForeignKeysSQL(): string;
|
|
6
5
|
enableForeignKeysSQL(): string;
|
package/index.mjs
CHANGED
|
@@ -52,8 +52,6 @@ export const DatabaseObjectExistsException = mod.DatabaseObjectExistsException;
|
|
|
52
52
|
export const DatabaseObjectNotFoundException = mod.DatabaseObjectNotFoundException;
|
|
53
53
|
export const DatabaseSchema = mod.DatabaseSchema;
|
|
54
54
|
export const DatabaseTable = mod.DatabaseTable;
|
|
55
|
-
export const Dataloader = mod.Dataloader;
|
|
56
|
-
export const DataloaderUtils = mod.DataloaderUtils;
|
|
57
55
|
export const DateTimeType = mod.DateTimeType;
|
|
58
56
|
export const DateType = mod.DateType;
|
|
59
57
|
export const DeadlockException = mod.DeadlockException;
|
|
@@ -200,6 +198,8 @@ export const compareBuffers = mod.compareBuffers;
|
|
|
200
198
|
export const compareObjects = mod.compareObjects;
|
|
201
199
|
export const defineConfig = mod.defineConfig;
|
|
202
200
|
export const equals = mod.equals;
|
|
201
|
+
export const getOnConflictFields = mod.getOnConflictFields;
|
|
202
|
+
export const getOnConflictReturningFields = mod.getOnConflictReturningFields;
|
|
203
203
|
export const helper = mod.helper;
|
|
204
204
|
export const knex = mod.knex;
|
|
205
205
|
export const parseJsonSafe = mod.parseJsonSafe;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mikro-orm/better-sqlite",
|
|
3
|
-
"version": "6.0.0-dev.
|
|
3
|
+
"version": "6.0.0-dev.94",
|
|
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": ">=
|
|
49
|
+
"node": ">= 18.12.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.0.0-dev.
|
|
62
|
-
"better-sqlite3": "8.
|
|
61
|
+
"@mikro-orm/knex": "~6.0.0-dev.94",
|
|
62
|
+
"better-sqlite3": "8.6.0",
|
|
63
63
|
"fs-extra": "11.1.1",
|
|
64
64
|
"sqlstring-sqlite": "0.1.1"
|
|
65
65
|
},
|
|
66
66
|
"devDependencies": {
|
|
67
|
-
"@mikro-orm/core": "^5.
|
|
67
|
+
"@mikro-orm/core": "^5.8.0"
|
|
68
68
|
},
|
|
69
69
|
"peerDependencies": {
|
|
70
|
-
"@mikro-orm/core": "~6.0.0-dev.
|
|
70
|
+
"@mikro-orm/core": "~6.0.0-dev.94"
|
|
71
71
|
}
|
|
72
72
|
}
|