@aws-amplify/datastore-storage-adapter 1.2.8-cloud-logging.7 → 1.2.8-cloud-logging.8
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 +15 -45
- package/dist/aws-amplify-datastore-storage-adapter.js +37 -3
- package/dist/aws-amplify-datastore-storage-adapter.js.map +1 -1
- package/dist/aws-amplify-datastore-storage-adapter.min.js +1 -1
- package/dist/aws-amplify-datastore-storage-adapter.min.js.map +1 -1
- package/lib/SQLiteAdapter/SQLiteAdapter.js +4 -2
- package/lib/SQLiteAdapter/SQLiteAdapter.js.map +1 -1
- package/lib/SQLiteAdapter/SQLiteDatabase.js +1 -1
- package/lib/SQLiteAdapter/SQLiteDatabase.js.map +1 -1
- package/lib/SQLiteAdapter/SQLiteUtils.js +27 -0
- package/lib/SQLiteAdapter/SQLiteUtils.js.map +1 -1
- package/lib-esm/SQLiteAdapter/SQLiteAdapter.js +4 -2
- package/lib-esm/SQLiteAdapter/SQLiteAdapter.js.map +1 -1
- package/lib-esm/SQLiteAdapter/SQLiteDatabase.js +1 -1
- package/lib-esm/SQLiteAdapter/SQLiteDatabase.js.map +1 -1
- package/lib-esm/SQLiteAdapter/SQLiteUtils.js +27 -0
- package/lib-esm/SQLiteAdapter/SQLiteUtils.js.map +1 -1
- package/package.json +6 -5
- package/src/SQLiteAdapter/SQLiteAdapter.ts +5 -5
- package/src/SQLiteAdapter/SQLiteDatabase.ts +7 -7
- package/src/SQLiteAdapter/SQLiteUtils.ts +33 -1
|
@@ -66,7 +66,7 @@ class SQLiteDatabase {
|
|
|
66
66
|
resultSet.rows.raw &&
|
|
67
67
|
resultSet.rows.raw();
|
|
68
68
|
|
|
69
|
-
return result[0] || undefined;
|
|
69
|
+
return result?.[0] || undefined;
|
|
70
70
|
}
|
|
71
71
|
|
|
72
72
|
public async getAll<T extends PersistentModel>(
|
|
@@ -91,12 +91,12 @@ class SQLiteDatabase {
|
|
|
91
91
|
public async batchQuery(queryStatements: Set<ParameterizedStatement>) {
|
|
92
92
|
const results = [];
|
|
93
93
|
|
|
94
|
-
await this.db.readTransaction(function(tx) {
|
|
94
|
+
await this.db.readTransaction(function (tx) {
|
|
95
95
|
for (const [statement, params] of queryStatements) {
|
|
96
96
|
tx.executeSql(
|
|
97
97
|
statement,
|
|
98
98
|
params,
|
|
99
|
-
function(_tx, res) {
|
|
99
|
+
function (_tx, res) {
|
|
100
100
|
results.push(res.rows.raw()[0]);
|
|
101
101
|
},
|
|
102
102
|
logger.warn
|
|
@@ -111,7 +111,7 @@ class SQLiteDatabase {
|
|
|
111
111
|
saveStatements: Set<ParameterizedStatement>,
|
|
112
112
|
deleteStatements?: Set<ParameterizedStatement>
|
|
113
113
|
) {
|
|
114
|
-
await this.db.transaction(function(tx) {
|
|
114
|
+
await this.db.transaction(function (tx) {
|
|
115
115
|
for (const [statement, params] of saveStatements) {
|
|
116
116
|
tx.executeSql(statement, params);
|
|
117
117
|
}
|
|
@@ -132,11 +132,11 @@ class SQLiteDatabase {
|
|
|
132
132
|
const [queryStatement, queryParams] = query;
|
|
133
133
|
const [deleteStatement, deleteParams] = _delete;
|
|
134
134
|
|
|
135
|
-
await this.db.transaction(function(tx) {
|
|
135
|
+
await this.db.transaction(function (tx) {
|
|
136
136
|
tx.executeSql(
|
|
137
137
|
queryStatement,
|
|
138
138
|
queryParams,
|
|
139
|
-
function(_tx, res) {
|
|
139
|
+
function (_tx, res) {
|
|
140
140
|
results = res.rows.raw();
|
|
141
141
|
},
|
|
142
142
|
logger.warn
|
|
@@ -148,7 +148,7 @@ class SQLiteDatabase {
|
|
|
148
148
|
}
|
|
149
149
|
|
|
150
150
|
private async executeStatements(statements: string[]): Promise<void> {
|
|
151
|
-
return await this.db.transaction(function(tx) {
|
|
151
|
+
return await this.db.transaction(function (tx) {
|
|
152
152
|
for (const statement of statements) {
|
|
153
153
|
tx.executeSql(statement);
|
|
154
154
|
}
|
|
@@ -236,6 +236,30 @@ const logicalOperatorMap = {
|
|
|
236
236
|
between: 'BETWEEN',
|
|
237
237
|
};
|
|
238
238
|
|
|
239
|
+
/**
|
|
240
|
+
* If the given (operator, operand) indicate the need for a special `NULL` comparison,
|
|
241
|
+
* that `WHERE` clause condition will be returned. If not special `NULL` handling is
|
|
242
|
+
* needed, `null` will be returned, and the caller should construct the `WHERE`
|
|
243
|
+
* clause component using the normal operator map(s) and parameterization.
|
|
244
|
+
*
|
|
245
|
+
* @param operator "beginsWith" | "contains" | "notContains" | "between"
|
|
246
|
+
* | "eq" | "ne" | "le" | "lt" | "ge" | "gt"
|
|
247
|
+
* @param operand any
|
|
248
|
+
* @returns (string | null) The `WHERE` clause component or `null` if N/A.
|
|
249
|
+
*/
|
|
250
|
+
function buildSpecialNullComparison(field, operator, operand) {
|
|
251
|
+
if (operand === null || operand === undefined) {
|
|
252
|
+
if (operator === 'eq') {
|
|
253
|
+
return `"${field}" IS NULL`;
|
|
254
|
+
} else if (operator === 'ne') {
|
|
255
|
+
return `"${field}" IS NOT NULL`;
|
|
256
|
+
}
|
|
257
|
+
}
|
|
258
|
+
|
|
259
|
+
// no special null handling required
|
|
260
|
+
return null;
|
|
261
|
+
}
|
|
262
|
+
|
|
239
263
|
const whereConditionFromPredicateObject = ({
|
|
240
264
|
field,
|
|
241
265
|
operator,
|
|
@@ -247,8 +271,16 @@ const whereConditionFromPredicateObject = ({
|
|
|
247
271
|
| keyof typeof comparisonOperatorMap;
|
|
248
272
|
operand: any;
|
|
249
273
|
}): ParameterizedStatement => {
|
|
250
|
-
const
|
|
274
|
+
const specialNullClause = buildSpecialNullComparison(
|
|
275
|
+
field,
|
|
276
|
+
operator,
|
|
277
|
+
operand
|
|
278
|
+
);
|
|
279
|
+
if (specialNullClause) {
|
|
280
|
+
return [specialNullClause, []];
|
|
281
|
+
}
|
|
251
282
|
|
|
283
|
+
const comparisonOperator = comparisonOperatorMap[operator];
|
|
252
284
|
if (comparisonOperator) {
|
|
253
285
|
return [`"${field}" ${comparisonOperator} ?`, [operand]];
|
|
254
286
|
}
|