Skip to content

Commit e600588

Browse files
committed
Fix tests
1 parent 145fe36 commit e600588

13 files changed

+21
-27
lines changed

packages/sync-rules/src/SqlDataQuery.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,13 @@ import { SqlRuleError } from './errors.js';
55
import { ExpressionType } from './ExpressionType.js';
66
import { SourceTableInterface } from './SourceTableInterface.js';
77
import { SqlTools } from './sql_filters.js';
8-
import { castAsText } from './sql_functions.js';
98
import { checkUnsupportedFeatures, isClauseError } from './sql_support.js';
109
import { SyncRulesOptions } from './SqlSyncRules.js';
1110
import { TablePattern } from './TablePattern.js';
1211
import { TableQuerySchema } from './TableQuerySchema.js';
1312
import { EvaluationResult, ParameterMatchClause, QuerySchema, SqliteRow } from './types.js';
1413
import { getBucketId, isSelectStatement } from './utils.js';
15-
import { CompatibilityContext } from './quirks.js';
14+
import { CompatibilityContext } from './compatibility.js';
1615

1716
export interface SqlDataQueryOptions extends BaseSqlDataQueryOptions {
1817
filter: ParameterMatchClause;

packages/sync-rules/src/SqlParameterQuery.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@ import {
2929
SqliteRow
3030
} from './types.js';
3131
import { filterJsonRow, getBucketId, isJsonValue, isSelectStatement, normalizeParameterValue } from './utils.js';
32-
import { CompatibilityContext } from './quirks.js';
3332

3433
export interface SqlParameterQueryOptions {
3534
sourceTable: TablePattern;
@@ -123,7 +122,7 @@ export class SqlParameterQuery {
123122
sql,
124123
supportsExpandingParameters: true,
125124
supportsParameterExpressions: true,
126-
compatibilityContext: CompatibilityContext.ofFixedQuirks(options.fixedQuirks),
125+
compatibilityContext: options.compatibility,
127126
schema: querySchema
128127
});
129128
tools.checkSpecificNameCase(tableRef);

packages/sync-rules/src/StaticSqlParameterQuery.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ import { SqlTools } from './sql_filters.js';
55
import { checkUnsupportedFeatures, isClauseError, isParameterValueClause, sqliteBool } from './sql_support.js';
66
import { ParameterValueClause, QueryParseOptions, RequestParameters, SqliteJsonValue } from './types.js';
77
import { getBucketId, isJsonValue } from './utils.js';
8-
import { CompatibilityContext } from './quirks.js';
98

109
export interface StaticSqlParameterQueryOptions {
1110
sql: string;
@@ -40,7 +39,7 @@ export class StaticSqlParameterQuery {
4039
table: undefined,
4140
parameterTables: ['token_parameters', 'user_parameters'],
4241
supportsParameterExpressions: true,
43-
compatibilityContext: CompatibilityContext.ofFixedQuirks(options.fixedQuirks),
42+
compatibilityContext: options.compatibility,
4443
sql
4544
});
4645
const where = q.where;

packages/sync-rules/src/TableValuedFunctionSqlParameterQuery.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { FromCall, SelectedColumn, SelectFromStatement } from 'pgsql-ast-parser';
1+
import { FromCall, SelectFromStatement } from 'pgsql-ast-parser';
22
import { SqlRuleError } from './errors.js';
33
import { SqlTools } from './sql_filters.js';
44
import { checkUnsupportedFeatures, isClauseError, isParameterValueClause, sqliteBool } from './sql_support.js';
@@ -13,7 +13,6 @@ import {
1313
} from './types.js';
1414
import { getBucketId, isJsonValue } from './utils.js';
1515
import { BucketDescription, BucketPriority, DEFAULT_BUCKET_PRIORITY } from './BucketDescription.js';
16-
import { CompatibilityContext } from './quirks.js';
1716

1817
export interface TableValuedFunctionSqlParameterQueryOptions {
1918
sql: string;
@@ -49,7 +48,7 @@ export class TableValuedFunctionSqlParameterQuery {
4948
options: QueryParseOptions,
5049
queryId: string
5150
): TableValuedFunctionSqlParameterQuery {
52-
const compatibility = CompatibilityContext.ofFixedQuirks(options.fixedQuirks);
51+
const compatibility = options.compatibility;
5352
let errors: SqlRuleError[] = [];
5453

5554
errors.push(...checkUnsupportedFeatures(sql, q));

packages/sync-rules/src/TableValuedFunctions.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { CompatibilityContext, Quirk } from './quirks.js';
1+
import { CompatibilityContext, CompatibilityOption } from './compatibility.js';
22
import { SqliteJsonValue, SqliteRow, SqliteValue } from './types.js';
33
import { jsonValueToSqlite } from './utils.js';
44

@@ -44,5 +44,5 @@ function jsonEachImplementation(fixedJsonBehavior: boolean): TableValuedFunction
4444
}
4545

4646
export function generateTableValuedFunctions(compatibility: CompatibilityContext): Record<string, TableValuedFunction> {
47-
return { json_each: jsonEachImplementation(compatibility.isFixed(Quirk.legacyJsonExtract)) };
47+
return { json_each: jsonEachImplementation(compatibility.isEnabled(CompatibilityOption.fixedJsonExtract)) };
4848
}

packages/sync-rules/src/events/SqlEventSourceQuery.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import { TablePattern } from '../TablePattern.js';
1010
import { TableQuerySchema } from '../TableQuerySchema.js';
1111
import { EvaluationError, QuerySchema, SqliteJsonRow, SqliteRow } from '../types.js';
1212
import { isSelectStatement } from '../utils.js';
13-
import { CompatibilityContext } from '../quirks.js';
13+
import { CompatibilityContext } from '../compatibility.js';
1414

1515
export type EvaluatedEventSourceRow = {
1616
data: SqliteJsonRow;

packages/sync-rules/src/request_functions.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1+
import { CompatibilityContext, CompatibilityEdition } from './compatibility.js';
12
import { ExpressionType } from './ExpressionType.js';
2-
import { CompatibilityContext, Quirk } from './quirks.js';
33
import { generateSqlFunctions } from './sql_functions.js';
44
import { ParameterValueSet, SqliteValue } from './types.js';
55

@@ -17,7 +17,7 @@ export interface SqlParameterFunction {
1717
}
1818

1919
const jsonExtractFromRecord = generateSqlFunctions(
20-
CompatibilityContext.ofFixedQuirks([Quirk.legacyJsonExtract])
20+
new CompatibilityContext(CompatibilityEdition.SYNC_STREAMS)
2121
).jsonExtractFromRecord;
2222
/**
2323
* Defines a `parameters` function and a `parameter` function.

packages/sync-rules/src/sql_filters.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ import {
4545
TrueIfParametersMatch
4646
} from './types.js';
4747
import { isJsonValue } from './utils.js';
48-
import { CompatibilityContext } from './quirks.js';
48+
import { CompatibilityContext } from './compatibility.js';
4949

5050
export const MATCH_CONST_FALSE: TrueIfParametersMatch = [];
5151
export const MATCH_CONST_TRUE: TrueIfParametersMatch = [{}];

packages/sync-rules/src/sql_functions.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import wkx from '@syncpoint/wkx';
99
import { ExpressionType, SqliteType, SqliteValueType, TYPE_INTEGER } from './ExpressionType.js';
1010
import * as uuid from 'uuid';
1111
import { CustomSqliteValue } from './types/custom_sqlite_value.js';
12-
import { CompatibilityContext, Quirk } from './quirks.js';
12+
import { CompatibilityContext, CompatibilityOption } from './compatibility.js';
1313

1414
export const BASIC_OPERATORS = new Set<string>([
1515
'=',
@@ -482,7 +482,7 @@ const st_y: DocumentedSqlFunction = {
482482
};
483483

484484
export function generateSqlFunctions(compatibility: CompatibilityContext) {
485-
const json = jsonFunctions(compatibility.isFixed(Quirk.legacyJsonExtract));
485+
const json = jsonFunctions(compatibility.isEnabled(CompatibilityOption.fixedJsonExtract));
486486

487487
const named = {
488488
upper,

packages/sync-rules/src/streams/from_sql.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ class SyncStreamCompiler {
6565
this.sql = sql;
6666
this.options = options;
6767
this.errors = [];
68-
this.compatibility = new CompatibilityContext(CompatibilityLevel.SYNC_STREAMS, options.fixedQuirks);
68+
this.compatibility = options.compatibility;
6969
}
7070

7171
compile(): SyncStream {

0 commit comments

Comments
 (0)