@powersync/service-module-mssql 0.2.0 → 0.3.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/CHANGELOG.md +16 -0
- package/dist/common/LSN.js +4 -3
- package/dist/common/LSN.js.map +1 -1
- package/dist/utils/mssql.d.ts +1 -1
- package/dist/utils/mssql.js +3 -3
- package/package.json +7 -7
- package/src/common/LSN.ts +4 -3
- package/src/utils/mssql.ts +3 -3
- package/test/src/CDCStream_resumable_snapshot.test.ts +2 -2
- package/test/src/LSN.test.ts +14 -0
- package/tsconfig.tsbuildinfo +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,21 @@
|
|
|
1
1
|
# @powersync/service-module-mssql
|
|
2
2
|
|
|
3
|
+
## 0.3.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- e11289d: Support connections to SQL Server 2019
|
|
8
|
+
|
|
9
|
+
### Patch Changes
|
|
10
|
+
|
|
11
|
+
- Updated dependencies [0e99ce0]
|
|
12
|
+
- Updated dependencies [479997b]
|
|
13
|
+
- Updated dependencies [d1c2228]
|
|
14
|
+
- Updated dependencies [1a1a4cc]
|
|
15
|
+
- @powersync/service-sync-rules@0.31.0
|
|
16
|
+
- @powersync/service-core@1.19.1
|
|
17
|
+
- @powersync/lib-services-framework@0.8.1
|
|
18
|
+
|
|
3
19
|
## 0.2.0
|
|
4
20
|
|
|
5
21
|
### Minor Changes
|
package/dist/common/LSN.js
CHANGED
|
@@ -43,10 +43,11 @@ export class LSN {
|
|
|
43
43
|
* @param stringLSN
|
|
44
44
|
*/
|
|
45
45
|
static fromString(stringLSN) {
|
|
46
|
-
if (!/^[0-
|
|
47
|
-
throw new ReplicationAssertionError(`Invalid LSN string. Expected format is
|
|
46
|
+
if (!/^[0-9a-fA-F]{8}:[0-9a-fA-F]{8}:[0-9a-fA-F]{4}$/.test(stringLSN)) {
|
|
47
|
+
throw new ReplicationAssertionError(`Invalid LSN string. Expected format is hexadecimal:[00000000:00000000:0000]. Got: ${stringLSN}`);
|
|
48
48
|
}
|
|
49
|
-
return
|
|
49
|
+
// SQL Server can return lowercase hex digits for LSN strings on some versions.
|
|
50
|
+
return new LSN(stringLSN.toUpperCase());
|
|
50
51
|
}
|
|
51
52
|
compare(other) {
|
|
52
53
|
if (this.value === other.value) {
|
package/dist/common/LSN.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"LSN.js","sourceRoot":"","sources":["../../src/common/LSN.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,yBAAyB,EAAE,MAAM,2BAA2B,CAAC;AAEtE;;;;;;;;;;GAUG;AAEH,MAAM,OAAO,GAAG;IACd;;OAEG;IACH,MAAM,CAAC,IAAI,GAAG,wBAAwB,CAAC;IAE7B,KAAK,CAAS;IAExB,YAAoB,GAAW;QAC7B,IAAI,CAAC,KAAK,GAAG,GAAG,CAAC;IACnB,CAAC;IAED;;OAEG;IACH,QAAQ;QACN,IAAI,SAAS,GAAW,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC;QACrD,OAAO,MAAM,CAAC,IAAI,CAAC,SAAS,EAAE,KAAK,CAAC,CAAC;IACvC,CAAC;IAED;;;;OAIG;IACH,MAAM,CAAC,UAAU,CAAC,MAAc;QAC9B,IAAI,MAAM,CAAC,MAAM,KAAK,EAAE,EAAE,CAAC;YACzB,MAAM,IAAI,yBAAyB,CAAC,6BAA6B,MAAM,CAAC,MAAM,EAAE,CAAC,CAAC;QACpF,CAAC;QACD,MAAM,GAAG,GAAG,MAAM,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC,WAAW,EAAE,CAAC,CAAC,eAAe;QAEjE,OAAO,IAAI,GAAG,CAAC,GAAG,GAAG,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,IAAI,GAAG,CAAC,KAAK,CAAC,CAAC,EAAE,EAAE,CAAC,IAA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ACjC,IAAI,CAAC,gDAAgD,CAAC,IAAI,CAAC,SAAS,CAAC,EAAE,CAAC;YACtE,MAAM,IAAI,yBAAyB,CACjC,qFAAqF,SAAS,EAAE,CACjG,CAAC;QACJ,CAAC;QAED,+EAA+E;QAC/E,OAAO,IAAI,GAAG,CAAC,SAAS,CAAC,WAAW,EAAE,CAAC,CAAC;IAC1C,CAAC;IAED,OAAO,CAAC,KAAU;QAChB,IAAI,IAAI,CAAC,KAAK,KAAK,KAAK,CAAC,KAAK,EAAE,CAAC;YAC/B,OAAO,CAAC,CAAC;QACX,CAAC;QACD,OAAO,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;IAC3C,CAAC;IAED,OAAO;QACL,OAAO,IAAI,CAAC,KAAK,CAAC;IACpB,CAAC;IAED,QAAQ;QACN,OAAO,IAAI,CAAC,KAAK,CAAC;IACpB,CAAC"}
|
package/dist/utils/mssql.d.ts
CHANGED
|
@@ -8,7 +8,7 @@ import { ResolvedTable } from './schema.js';
|
|
|
8
8
|
import * as service_types from '@powersync/service-types';
|
|
9
9
|
export declare const POWERSYNC_CHECKPOINTS_TABLE = "_powersync_checkpoints";
|
|
10
10
|
export declare const SUPPORTED_ENGINE_EDITIONS: Map<number, string>;
|
|
11
|
-
export declare const MINIMUM_SUPPORTED_VERSION = "
|
|
11
|
+
export declare const MINIMUM_SUPPORTED_VERSION = "15.0";
|
|
12
12
|
export declare function checkSourceConfiguration(connectionManager: MSSQLConnectionManager): Promise<string[]>;
|
|
13
13
|
export declare function ensurePowerSyncCheckpointsTable(connectionManager: MSSQLConnectionManager): Promise<string[]>;
|
|
14
14
|
export declare function createCheckpoint(connectionManager: MSSQLConnectionManager): Promise<void>;
|
package/dist/utils/mssql.js
CHANGED
|
@@ -10,8 +10,8 @@ export const SUPPORTED_ENGINE_EDITIONS = new Map([
|
|
|
10
10
|
[5, 'SqlDatabase - Azure SQL Database'],
|
|
11
11
|
[8, 'SqlManagedInstance - Azure SQL Managed Instance']
|
|
12
12
|
]);
|
|
13
|
-
// SQL Server
|
|
14
|
-
export const MINIMUM_SUPPORTED_VERSION = '
|
|
13
|
+
// SQL Server 2019 and newer
|
|
14
|
+
export const MINIMUM_SUPPORTED_VERSION = '15.0';
|
|
15
15
|
export async function checkSourceConfiguration(connectionManager) {
|
|
16
16
|
const errors = [];
|
|
17
17
|
// 1) Check MSSQL version and Editions
|
|
@@ -29,7 +29,7 @@ export async function checkSourceConfiguration(connectionManager) {
|
|
|
29
29
|
// Only applicable to SQL Server stand-alone editions
|
|
30
30
|
if (versionResult[0]?.engine == 2 || versionResult[0]?.engine == 3) {
|
|
31
31
|
if (!isVersionAtLeast(versionResult[0]?.version, MINIMUM_SUPPORTED_VERSION)) {
|
|
32
|
-
errors.push(`The SQL Server version '${versionResult[0]?.version}' is not supported. PowerSync requires MSSQL
|
|
32
|
+
errors.push(`The SQL Server version '${versionResult[0]?.version}' is not supported. PowerSync requires MSSQL 2019 (v15) or newer.`);
|
|
33
33
|
}
|
|
34
34
|
}
|
|
35
35
|
// 2) Check DB-level CDC
|
package/package.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"name": "@powersync/service-module-mssql",
|
|
3
3
|
"repository": "https://github.com/powersync-ja/powersync-service",
|
|
4
4
|
"types": "dist/index.d.ts",
|
|
5
|
-
"version": "0.
|
|
5
|
+
"version": "0.3.0",
|
|
6
6
|
"license": "FSL-1.1-ALv2",
|
|
7
7
|
"main": "dist/index.js",
|
|
8
8
|
"type": "module",
|
|
@@ -27,10 +27,10 @@
|
|
|
27
27
|
"ts-codec": "^1.3.0",
|
|
28
28
|
"uri-js": "^4.4.1",
|
|
29
29
|
"uuid": "^11.1.0",
|
|
30
|
-
"@powersync/lib-services-framework": "0.8.
|
|
31
|
-
"@powersync/service-core": "1.19.
|
|
30
|
+
"@powersync/lib-services-framework": "0.8.1",
|
|
31
|
+
"@powersync/service-core": "1.19.1",
|
|
32
32
|
"@powersync/service-errors": "0.3.6",
|
|
33
|
-
"@powersync/service-sync-rules": "0.
|
|
33
|
+
"@powersync/service-sync-rules": "0.31.0",
|
|
34
34
|
"@powersync/service-types": "0.14.0",
|
|
35
35
|
"@powersync/service-jsonbig": "0.17.12"
|
|
36
36
|
},
|
|
@@ -38,9 +38,9 @@
|
|
|
38
38
|
"@types/mssql": "^9.1.8",
|
|
39
39
|
"@types/semver": "^7.7.1",
|
|
40
40
|
"@types/uuid": "^10.0.0",
|
|
41
|
-
"@powersync/service-core-tests": "0.13.
|
|
42
|
-
"@powersync/service-module-mongodb-storage": "0.13.
|
|
43
|
-
"@powersync/service-module-postgres-storage": "0.11.
|
|
41
|
+
"@powersync/service-core-tests": "0.13.1",
|
|
42
|
+
"@powersync/service-module-mongodb-storage": "0.13.1",
|
|
43
|
+
"@powersync/service-module-postgres-storage": "0.11.1"
|
|
44
44
|
},
|
|
45
45
|
"scripts": {
|
|
46
46
|
"build": "tsc -b",
|
package/src/common/LSN.ts
CHANGED
|
@@ -51,13 +51,14 @@ export class LSN {
|
|
|
51
51
|
* @param stringLSN
|
|
52
52
|
*/
|
|
53
53
|
static fromString(stringLSN: string): LSN {
|
|
54
|
-
if (!/^[0-
|
|
54
|
+
if (!/^[0-9a-fA-F]{8}:[0-9a-fA-F]{8}:[0-9a-fA-F]{4}$/.test(stringLSN)) {
|
|
55
55
|
throw new ReplicationAssertionError(
|
|
56
|
-
`Invalid LSN string. Expected format is
|
|
56
|
+
`Invalid LSN string. Expected format is hexadecimal:[00000000:00000000:0000]. Got: ${stringLSN}`
|
|
57
57
|
);
|
|
58
58
|
}
|
|
59
59
|
|
|
60
|
-
return
|
|
60
|
+
// SQL Server can return lowercase hex digits for LSN strings on some versions.
|
|
61
|
+
return new LSN(stringLSN.toUpperCase());
|
|
61
62
|
}
|
|
62
63
|
|
|
63
64
|
compare(other: LSN): -1 | 0 | 1 {
|
package/src/utils/mssql.ts
CHANGED
|
@@ -19,8 +19,8 @@ export const SUPPORTED_ENGINE_EDITIONS = new Map([
|
|
|
19
19
|
[8, 'SqlManagedInstance - Azure SQL Managed Instance']
|
|
20
20
|
]);
|
|
21
21
|
|
|
22
|
-
// SQL Server
|
|
23
|
-
export const MINIMUM_SUPPORTED_VERSION = '
|
|
22
|
+
// SQL Server 2019 and newer
|
|
23
|
+
export const MINIMUM_SUPPORTED_VERSION = '15.0';
|
|
24
24
|
|
|
25
25
|
export async function checkSourceConfiguration(connectionManager: MSSQLConnectionManager): Promise<string[]> {
|
|
26
26
|
const errors: string[] = [];
|
|
@@ -46,7 +46,7 @@ export async function checkSourceConfiguration(connectionManager: MSSQLConnectio
|
|
|
46
46
|
if (versionResult[0]?.engine == 2 || versionResult[0]?.engine == 3) {
|
|
47
47
|
if (!isVersionAtLeast(versionResult[0]?.version, MINIMUM_SUPPORTED_VERSION)) {
|
|
48
48
|
errors.push(
|
|
49
|
-
`The SQL Server version '${versionResult[0]?.version}' is not supported. PowerSync requires MSSQL
|
|
49
|
+
`The SQL Server version '${versionResult[0]?.version}' is not supported. PowerSync requires MSSQL 2019 (v15) or newer.`
|
|
50
50
|
);
|
|
51
51
|
}
|
|
52
52
|
}
|
|
@@ -46,9 +46,9 @@ async function testResumingReplication(factory: TestStorageFactory, stopAfter: n
|
|
|
46
46
|
await createTestTableWithBasicId(connectionManager, 'test_data1');
|
|
47
47
|
await createTestTableWithBasicId(connectionManager, 'test_data2');
|
|
48
48
|
|
|
49
|
-
await connectionManager.query(`INSERT INTO test_data1(description) SELECT 'value' FROM
|
|
49
|
+
await connectionManager.query(`WITH nums AS (SELECT 1 AS n UNION ALL SELECT n + 1 FROM nums WHERE n < 1000) INSERT INTO test_data1(description) SELECT 'value' FROM nums OPTION (MAXRECURSION 1000)`);
|
|
50
50
|
let beforeLSN = await getLatestLSN(connectionManager);
|
|
51
|
-
await connectionManager.query(`INSERT INTO test_data2(description) SELECT 'value' FROM
|
|
51
|
+
await connectionManager.query(`WITH nums AS (SELECT 1 AS n UNION ALL SELECT n + 1 FROM nums WHERE n < 10000) INSERT INTO test_data2(description) SELECT 'value' FROM nums OPTION (MAXRECURSION 10000)`);
|
|
52
52
|
await waitForPendingCDCChanges(beforeLSN, connectionManager);
|
|
53
53
|
|
|
54
54
|
const p = context.replicateSnapshot();
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { describe, expect, test } from 'vitest';
|
|
2
|
+
import { LSN } from '@module/common/LSN.js';
|
|
3
|
+
|
|
4
|
+
describe('LSN', () => {
|
|
5
|
+
test('normalizes lowercase hex strings to uppercase', () => {
|
|
6
|
+
const lsn = LSN.fromString('0000002f:00000de0:0001');
|
|
7
|
+
expect(lsn.toString()).toEqual('0000002F:00000DE0:0001');
|
|
8
|
+
});
|
|
9
|
+
|
|
10
|
+
test('accepts uppercase hex strings', () => {
|
|
11
|
+
const lsn = LSN.fromString('0000002F:00000DE0:0001');
|
|
12
|
+
expect(lsn.toString()).toEqual('0000002F:00000DE0:0001');
|
|
13
|
+
});
|
|
14
|
+
});
|