dynamoxy 0.5.0__tar.gz → 0.6.0__tar.gz
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.
- {dynamoxy-0.5.0 → dynamoxy-0.6.0}/Cargo.lock +12 -13
- {dynamoxy-0.5.0 → dynamoxy-0.6.0}/Cargo.toml +3 -3
- {dynamoxy-0.5.0 → dynamoxy-0.6.0}/PKG-INFO +1 -1
- {dynamoxy-0.5.0 → dynamoxy-0.6.0}/crates/dynamoxy-core/src/backend/memory/items.rs +1 -1
- {dynamoxy-0.5.0 → dynamoxy-0.6.0}/crates/dynamoxy-core/src/backend/memory/mod.rs +37 -1
- {dynamoxy-0.5.0 → dynamoxy-0.6.0}/crates/dynamoxy-core/src/backend/memory/table.rs +4 -4
- {dynamoxy-0.5.0 → dynamoxy-0.6.0}/crates/dynamoxy-core/src/backend/memory/tests.rs +53 -0
- {dynamoxy-0.5.0 → dynamoxy-0.6.0}/crates/dynamoxy-core/src/error.rs +38 -0
- {dynamoxy-0.5.0 → dynamoxy-0.6.0}/crates/dynamoxy-core/src/lib.rs +4 -1
- {dynamoxy-0.5.0 → dynamoxy-0.6.0}/crates/dynamoxy-py/src/client.rs +221 -73
- {dynamoxy-0.5.0 → dynamoxy-0.6.0}/crates/dynamoxy-py/src/convert.rs +384 -102
- {dynamoxy-0.5.0 → dynamoxy-0.6.0}/crates/dynamoxy-py/src/errors.rs +28 -18
- {dynamoxy-0.5.0 → dynamoxy-0.6.0}/crates/dynamoxy-py/src/lib.rs +17 -10
- {dynamoxy-0.5.0 → dynamoxy-0.6.0}/crates/dynamoxy-py/src/runtime.rs +200 -56
- {dynamoxy-0.5.0 → dynamoxy-0.6.0}/python/dynamoxy/AGENT_GUIDE.md +108 -21
- {dynamoxy-0.5.0 → dynamoxy-0.6.0}/python/dynamoxy/__init__.py +19 -2
- {dynamoxy-0.5.0 → dynamoxy-0.6.0}/python/dynamoxy/_core.pyi +21 -0
- {dynamoxy-0.5.0 → dynamoxy-0.6.0}/python/dynamoxy/_pydantic.py +161 -24
- {dynamoxy-0.5.0 → dynamoxy-0.6.0}/python/dynamoxy/attributes.py +56 -7
- {dynamoxy-0.5.0 → dynamoxy-0.6.0}/python/dynamoxy/batch.py +1 -0
- {dynamoxy-0.5.0 → dynamoxy-0.6.0}/python/dynamoxy/codecs.py +124 -5
- {dynamoxy-0.5.0 → dynamoxy-0.6.0}/python/dynamoxy/collection.py +92 -25
- {dynamoxy-0.5.0 → dynamoxy-0.6.0}/python/dynamoxy/errors.py +50 -0
- {dynamoxy-0.5.0 → dynamoxy-0.6.0}/python/dynamoxy/models.py +312 -67
- {dynamoxy-0.5.0 → dynamoxy-0.6.0}/python/dynamoxy/query.py +275 -77
- {dynamoxy-0.5.0 → dynamoxy-0.6.0}/python/dynamoxy/repository.py +399 -78
- {dynamoxy-0.5.0 → dynamoxy-0.6.0}/python/dynamoxy/schema.py +675 -42
- dynamoxy-0.6.0/python/dynamoxy/streams.py +497 -0
- {dynamoxy-0.5.0 → dynamoxy-0.6.0}/python/dynamoxy/table.py +44 -21
- {dynamoxy-0.5.0 → dynamoxy-0.6.0}/python/dynamoxy/testing.py +64 -5
- {dynamoxy-0.5.0 → dynamoxy-0.6.0}/python/dynamoxy/transactions.py +3 -0
- {dynamoxy-0.5.0 → dynamoxy-0.6.0}/LICENSE +0 -0
- {dynamoxy-0.5.0 → dynamoxy-0.6.0}/README.md +0 -0
- {dynamoxy-0.5.0 → dynamoxy-0.6.0}/crates/dynamoxy-core/Cargo.toml +0 -0
- {dynamoxy-0.5.0 → dynamoxy-0.6.0}/crates/dynamoxy-core/README.md +0 -0
- {dynamoxy-0.5.0 → dynamoxy-0.6.0}/crates/dynamoxy-core/src/backend/aws/convert.rs +0 -0
- {dynamoxy-0.5.0 → dynamoxy-0.6.0}/crates/dynamoxy-core/src/backend/aws/errors.rs +0 -0
- {dynamoxy-0.5.0 → dynamoxy-0.6.0}/crates/dynamoxy-core/src/backend/aws/mod.rs +0 -0
- {dynamoxy-0.5.0 → dynamoxy-0.6.0}/crates/dynamoxy-core/src/backend/memory/admin.rs +0 -0
- {dynamoxy-0.5.0 → dynamoxy-0.6.0}/crates/dynamoxy-core/src/backend/memory/batch.rs +0 -0
- {dynamoxy-0.5.0 → dynamoxy-0.6.0}/crates/dynamoxy-core/src/backend/memory/partiql.rs +0 -0
- {dynamoxy-0.5.0 → dynamoxy-0.6.0}/crates/dynamoxy-core/src/backend/memory/query.rs +0 -0
- {dynamoxy-0.5.0 → dynamoxy-0.6.0}/crates/dynamoxy-core/src/backend/memory/transact.rs +0 -0
- {dynamoxy-0.5.0 → dynamoxy-0.6.0}/crates/dynamoxy-core/src/backend/mod.rs +0 -0
- {dynamoxy-0.5.0 → dynamoxy-0.6.0}/crates/dynamoxy-core/src/client/tests.rs +0 -0
- {dynamoxy-0.5.0 → dynamoxy-0.6.0}/crates/dynamoxy-core/src/client.rs +0 -0
- {dynamoxy-0.5.0 → dynamoxy-0.6.0}/crates/dynamoxy-core/src/config.rs +0 -0
- {dynamoxy-0.5.0 → dynamoxy-0.6.0}/crates/dynamoxy-core/src/events.rs +0 -0
- {dynamoxy-0.5.0 → dynamoxy-0.6.0}/crates/dynamoxy-core/src/expr/ast.rs +0 -0
- {dynamoxy-0.5.0 → dynamoxy-0.6.0}/crates/dynamoxy-core/src/expr/eval.rs +0 -0
- {dynamoxy-0.5.0 → dynamoxy-0.6.0}/crates/dynamoxy-core/src/expr/mod.rs +0 -0
- {dynamoxy-0.5.0 → dynamoxy-0.6.0}/crates/dynamoxy-core/src/expr/parser.rs +0 -0
- {dynamoxy-0.5.0 → dynamoxy-0.6.0}/crates/dynamoxy-core/src/expr/projection.rs +0 -0
- {dynamoxy-0.5.0 → dynamoxy-0.6.0}/crates/dynamoxy-core/src/expr/reserved.rs +0 -0
- {dynamoxy-0.5.0 → dynamoxy-0.6.0}/crates/dynamoxy-core/src/expr/tests.rs +0 -0
- {dynamoxy-0.5.0 → dynamoxy-0.6.0}/crates/dynamoxy-core/src/expr/update.rs +0 -0
- {dynamoxy-0.5.0 → dynamoxy-0.6.0}/crates/dynamoxy-core/src/metrics.rs +0 -0
- {dynamoxy-0.5.0 → dynamoxy-0.6.0}/crates/dynamoxy-core/src/retry.rs +0 -0
- {dynamoxy-0.5.0 → dynamoxy-0.6.0}/crates/dynamoxy-core/src/types/mod.rs +0 -0
- {dynamoxy-0.5.0 → dynamoxy-0.6.0}/crates/dynamoxy-core/src/types/ops.rs +0 -0
- {dynamoxy-0.5.0 → dynamoxy-0.6.0}/crates/dynamoxy-core/src/types/schema.rs +0 -0
- {dynamoxy-0.5.0 → dynamoxy-0.6.0}/crates/dynamoxy-core/src/value/mod.rs +0 -0
- {dynamoxy-0.5.0 → dynamoxy-0.6.0}/crates/dynamoxy-core/src/value/number.rs +0 -0
- {dynamoxy-0.5.0 → dynamoxy-0.6.0}/crates/dynamoxy-core/src/value/size.rs +0 -0
- {dynamoxy-0.5.0 → dynamoxy-0.6.0}/crates/dynamoxy-core/tests/emulator.rs +0 -0
- {dynamoxy-0.5.0 → dynamoxy-0.6.0}/crates/dynamoxy-py/Cargo.toml +0 -0
- {dynamoxy-0.5.0 → dynamoxy-0.6.0}/pyproject.toml +0 -0
- {dynamoxy-0.5.0 → dynamoxy-0.6.0}/python/dynamoxy/__main__.py +0 -0
- {dynamoxy-0.5.0 → dynamoxy-0.6.0}/python/dynamoxy/_utils.py +0 -0
- {dynamoxy-0.5.0 → dynamoxy-0.6.0}/python/dynamoxy/client.py +0 -0
- {dynamoxy-0.5.0 → dynamoxy-0.6.0}/python/dynamoxy/constraints.py +0 -0
- {dynamoxy-0.5.0 → dynamoxy-0.6.0}/python/dynamoxy/events.py +0 -0
- {dynamoxy-0.5.0 → dynamoxy-0.6.0}/python/dynamoxy/expressions.py +0 -0
- {dynamoxy-0.5.0 → dynamoxy-0.6.0}/python/dynamoxy/middleware.py +0 -0
- {dynamoxy-0.5.0 → dynamoxy-0.6.0}/python/dynamoxy/py.typed +0 -0
- {dynamoxy-0.5.0 → dynamoxy-0.6.0}/python/dynamoxy/results.py +0 -0
- {dynamoxy-0.5.0 → dynamoxy-0.6.0}/python/dynamoxy/telemetry.py +0 -0
|
@@ -658,7 +658,7 @@ checksum = "92773504d58c093f6de2459af4af33faa518c13451eb8f2b5698ed3d36e7c813"
|
|
|
658
658
|
|
|
659
659
|
[[package]]
|
|
660
660
|
name = "dynamoxy-core"
|
|
661
|
-
version = "0.
|
|
661
|
+
version = "0.6.0"
|
|
662
662
|
dependencies = [
|
|
663
663
|
"async-trait",
|
|
664
664
|
"aws-config",
|
|
@@ -675,7 +675,7 @@ dependencies = [
|
|
|
675
675
|
|
|
676
676
|
[[package]]
|
|
677
677
|
name = "dynamoxy-py"
|
|
678
|
-
version = "0.
|
|
678
|
+
version = "0.6.0"
|
|
679
679
|
dependencies = [
|
|
680
680
|
"dynamoxy-core",
|
|
681
681
|
"parking_lot",
|
|
@@ -1127,9 +1127,9 @@ dependencies = [
|
|
|
1127
1127
|
|
|
1128
1128
|
[[package]]
|
|
1129
1129
|
name = "libc"
|
|
1130
|
-
version = "0.2.
|
|
1130
|
+
version = "0.2.191"
|
|
1131
1131
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
1132
|
-
checksum = "
|
|
1132
|
+
checksum = "65cd87c9a6d60536580b316ad985726104730a5151c99845f2490428ef91240a"
|
|
1133
1133
|
|
|
1134
1134
|
[[package]]
|
|
1135
1135
|
name = "litemap"
|
|
@@ -1139,9 +1139,9 @@ checksum = "47d9d19d1d6efa0109d2f65ff4c85cddd50bd572e5a00127ab10987290bcefae"
|
|
|
1139
1139
|
|
|
1140
1140
|
[[package]]
|
|
1141
1141
|
name = "lock_api"
|
|
1142
|
-
version = "0.
|
|
1142
|
+
version = "0.5.0"
|
|
1143
1143
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
1144
|
-
checksum = "
|
|
1144
|
+
checksum = "65d91b22da179613dcf4d6ec8349563f52a363f6849e03b00dd0a185ec4a59af"
|
|
1145
1145
|
dependencies = [
|
|
1146
1146
|
"scopeguard",
|
|
1147
1147
|
]
|
|
@@ -1201,9 +1201,9 @@ checksum = "1a80800c0488c3a21695ea981a54918fbb37abf04f4d0720c453632255e2ff0e"
|
|
|
1201
1201
|
|
|
1202
1202
|
[[package]]
|
|
1203
1203
|
name = "parking_lot"
|
|
1204
|
-
version = "0.
|
|
1204
|
+
version = "0.13.0"
|
|
1205
1205
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
1206
|
-
checksum = "
|
|
1206
|
+
checksum = "a9cf937ca4e1d0b7578784559063422fc39ae7c5a00f02471f2614d5486fd226"
|
|
1207
1207
|
dependencies = [
|
|
1208
1208
|
"lock_api",
|
|
1209
1209
|
"parking_lot_core",
|
|
@@ -1211,11 +1211,10 @@ dependencies = [
|
|
|
1211
1211
|
|
|
1212
1212
|
[[package]]
|
|
1213
1213
|
name = "parking_lot_core"
|
|
1214
|
-
version = "0.
|
|
1214
|
+
version = "0.10.0"
|
|
1215
1215
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
1216
|
-
checksum = "
|
|
1216
|
+
checksum = "9cfff060068cc18aa7815010fcaf80c68c7fb9e85fc7f5c0f9bf142c21d19826"
|
|
1217
1217
|
dependencies = [
|
|
1218
|
-
"cfg-if",
|
|
1219
1218
|
"libc",
|
|
1220
1219
|
"redox_syscall",
|
|
1221
1220
|
"smallvec",
|
|
@@ -1354,9 +1353,9 @@ checksum = "f8dcc9c7d52a811697d2151c701e0d08956f92b0e24136cf4cf27b57a6a0d9bf"
|
|
|
1354
1353
|
|
|
1355
1354
|
[[package]]
|
|
1356
1355
|
name = "redox_syscall"
|
|
1357
|
-
version = "0.5
|
|
1356
|
+
version = "0.9.5"
|
|
1358
1357
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
1359
|
-
checksum = "
|
|
1358
|
+
checksum = "580c875845b41ecb1564ad1ae4703044cef774145e3d7a94dc2b3fa7c97868fd"
|
|
1360
1359
|
dependencies = [
|
|
1361
1360
|
"bitflags",
|
|
1362
1361
|
]
|
|
@@ -4,7 +4,7 @@ members = ["crates/dynamoxy-core", "crates/dynamoxy-py"]
|
|
|
4
4
|
|
|
5
5
|
# The single version of the project: the Python package takes it from the binding crate.
|
|
6
6
|
[workspace.package]
|
|
7
|
-
version = "0.
|
|
7
|
+
version = "0.6.0"
|
|
8
8
|
edition = "2024"
|
|
9
9
|
rust-version = "1.99"
|
|
10
10
|
license = "MIT"
|
|
@@ -13,7 +13,7 @@ homepage = "https://github.com/kalaspuff/dynamoxy"
|
|
|
13
13
|
authors = ["Carl Oscar Aaro <hello@carloscar.com>"]
|
|
14
14
|
|
|
15
15
|
[workspace.dependencies]
|
|
16
|
-
dynamoxy-core = { path = "crates/dynamoxy-core", version = "0.
|
|
16
|
+
dynamoxy-core = { path = "crates/dynamoxy-core", version = "0.6.0" }
|
|
17
17
|
async-trait = "0.1"
|
|
18
18
|
aws-config = { version = "1.12", features = ["behavior-version-latest"] }
|
|
19
19
|
aws-credential-types = { version = "1.3", features = ["hardcoded-credentials"] }
|
|
@@ -29,7 +29,7 @@ fastrand = "2"
|
|
|
29
29
|
# Only to recognize the SDK's failures to connect (`legacy::Error::is_connect`): the same version
|
|
30
30
|
# as the SDK's HTTP client, which Cargo unifies.
|
|
31
31
|
hyper-util = { version = "0.1", default-features = false, features = ["client-legacy"] }
|
|
32
|
-
parking_lot = "0.
|
|
32
|
+
parking_lot = "0.13"
|
|
33
33
|
pyo3 = { version = "0.29", features = ["abi3-py312"] }
|
|
34
34
|
pythonize = "0.29"
|
|
35
35
|
serde = { version = "1", features = ["derive"] }
|
|
@@ -298,7 +298,7 @@ pub fn update_item(state: &mut State, input: UpdateItemInput) -> Result<WriteIte
|
|
|
298
298
|
// DynamoDB holds an update to 400 KB by what its request carries before it reads the item
|
|
299
299
|
// (captured by dynoxide-rs, src/actions/update_item.rs).
|
|
300
300
|
if update.request_charge() > MAX_ITEM_SIZE {
|
|
301
|
-
return Err(Error::validation_exception(
|
|
301
|
+
return Err(Error::validation_exception(crate::error::UPDATE_SIZE_MESSAGE));
|
|
302
302
|
}
|
|
303
303
|
}
|
|
304
304
|
let mut meter = CapacityMeter::default();
|
|
@@ -41,7 +41,7 @@ use crate::types::{
|
|
|
41
41
|
DeleteItemInput, ExecuteStatementInput, ExecuteStatementOutput, ExecuteTransactionInput, ExecuteTransactionOutput,
|
|
42
42
|
GetItemInput, GetItemOutput, ListBackupsInput, ListBackupsOutput, ListTablesInput, ListTablesOutput,
|
|
43
43
|
ListTagsOutput, PutItemInput, QueryInput, QueryOutput, RestoreTableFromBackupInput, RestoreTableToPointInTimeInput,
|
|
44
|
-
ScanInput, TableDescription, TimeToLiveDescription, TransactGetItemsInput, TransactGetItemsOutput,
|
|
44
|
+
ScanInput, TableDescription, TableStatus, TimeToLiveDescription, TransactGetItemsInput, TransactGetItemsOutput,
|
|
45
45
|
TransactWriteItemsInput, TransactWriteItemsOutput, UpdateItemInput, UpdateTableInput, UpdateTimeToLiveInput,
|
|
46
46
|
WriteItemOutput,
|
|
47
47
|
};
|
|
@@ -274,6 +274,42 @@ impl MemoryBackend {
|
|
|
274
274
|
deleted
|
|
275
275
|
}
|
|
276
276
|
|
|
277
|
+
/// Deletes every item of every table, and every backup, idempotency token and pending fault.
|
|
278
|
+
/// The tables keep their keys, indexes, capacity, Time to Live and other settings, so tests can
|
|
279
|
+
/// share them and start from empty tables.
|
|
280
|
+
pub fn clear(&self) {
|
|
281
|
+
let mut state = self.state.lock();
|
|
282
|
+
for table in state.tables.values_mut() {
|
|
283
|
+
table.items.clear();
|
|
284
|
+
for index in &mut table.indexes {
|
|
285
|
+
index.entries.clear();
|
|
286
|
+
}
|
|
287
|
+
}
|
|
288
|
+
state.backups.clear();
|
|
289
|
+
state.tokens.clear();
|
|
290
|
+
state.faults.clear();
|
|
291
|
+
}
|
|
292
|
+
|
|
293
|
+
/// Creates a table at once: `ACTIVE` with its indexes, and with Time to Live enabled on
|
|
294
|
+
/// `ttl_attribute`. Test setup, without the `CREATING` state that `CreateTable` reports first
|
|
295
|
+
/// (and without faults); the table is checked as `CreateTable` checks it.
|
|
296
|
+
pub fn create_table_active(
|
|
297
|
+
&self,
|
|
298
|
+
input: CreateTableInput,
|
|
299
|
+
ttl_attribute: Option<String>,
|
|
300
|
+
) -> Result<TableDescription> {
|
|
301
|
+
if ttl_attribute.as_deref() == Some("") {
|
|
302
|
+
return Err(ServiceError::validation("TimeToLiveSpecification AttributeName must not be empty").into());
|
|
303
|
+
}
|
|
304
|
+
let name = input.table_name.clone();
|
|
305
|
+
let mut state = self.state.lock();
|
|
306
|
+
named("CreateTable", admin::create_table(&mut state, input))?;
|
|
307
|
+
let table = state.tables.get_mut(&name).expect("the table was just created");
|
|
308
|
+
table.describes_until_active = 0;
|
|
309
|
+
table.ttl_attribute = ttl_attribute;
|
|
310
|
+
Ok(table.describe(TableStatus::Active))
|
|
311
|
+
}
|
|
312
|
+
|
|
277
313
|
/// Deletes every table and backup.
|
|
278
314
|
pub fn reset(&self) {
|
|
279
315
|
let mut state = self.state.lock();
|
|
@@ -466,9 +466,9 @@ impl Table {
|
|
|
466
466
|
}
|
|
467
467
|
if total > 0 && item_size(item) + total > MAX_ITEM_SIZE {
|
|
468
468
|
return Err(invalid(if update {
|
|
469
|
-
|
|
469
|
+
crate::error::UPDATE_SIZE_MESSAGE
|
|
470
470
|
} else {
|
|
471
|
-
|
|
471
|
+
crate::error::ITEM_SIZE_MESSAGE
|
|
472
472
|
}));
|
|
473
473
|
}
|
|
474
474
|
Ok(())
|
|
@@ -508,9 +508,9 @@ impl Table {
|
|
|
508
508
|
}
|
|
509
509
|
if item_size(item) > MAX_ITEM_SIZE {
|
|
510
510
|
return Err(invalid(if update {
|
|
511
|
-
|
|
511
|
+
crate::error::UPDATE_SIZE_MESSAGE
|
|
512
512
|
} else {
|
|
513
|
-
|
|
513
|
+
crate::error::ITEM_SIZE_MESSAGE
|
|
514
514
|
}));
|
|
515
515
|
}
|
|
516
516
|
for index in &self.indexes {
|
|
@@ -3046,3 +3046,56 @@ async fn names_values_and_messages_follow_dynamodb() {
|
|
|
3046
3046
|
"One or more parameter values are not valid. The update expression attempted to update a secondary index key to a value that is not supported. The AttributeValue for a key attribute cannot contain an empty string value."
|
|
3047
3047
|
);
|
|
3048
3048
|
}
|
|
3049
|
+
|
|
3050
|
+
#[tokio::test]
|
|
3051
|
+
async fn clear_empties_the_tables_and_keeps_their_definitions() {
|
|
3052
|
+
let backend = backend_with_table().await;
|
|
3053
|
+
seed_query_data(&backend).await;
|
|
3054
|
+
backend
|
|
3055
|
+
.update_time_to_live(UpdateTimeToLiveInput {
|
|
3056
|
+
table_name: "items".into(),
|
|
3057
|
+
attribute_name: "expires".into(),
|
|
3058
|
+
enabled: true,
|
|
3059
|
+
})
|
|
3060
|
+
.await
|
|
3061
|
+
.unwrap();
|
|
3062
|
+
backend.create_backup("items", "before").await.unwrap();
|
|
3063
|
+
backend.inject_fault(Fault { operation: None, table: None, kind: FaultKind::Unprocessed, times: 5 });
|
|
3064
|
+
backend.clear();
|
|
3065
|
+
let description = backend.describe_table("items").await.unwrap();
|
|
3066
|
+
assert_eq!(description.table_status, TableStatus::Active);
|
|
3067
|
+
assert_eq!(description.item_count, 0);
|
|
3068
|
+
assert_eq!(description.global_secondary_indexes.len(), 1, "the indexes stay");
|
|
3069
|
+
assert!(backend.query(query("pk = :p", values(&[(":p", s("p"))]))).await.unwrap().items.is_empty());
|
|
3070
|
+
let by_status =
|
|
3071
|
+
QueryInput { index_name: Some("by_status".into()), ..query("#s = :s", values(&[(":s", s("even"))])) };
|
|
3072
|
+
let by_status = QueryInput { expression_attribute_names: names(&[("#s", "status")]), ..by_status };
|
|
3073
|
+
assert!(backend.query(by_status.clone()).await.unwrap().items.is_empty(), "and so do their entries");
|
|
3074
|
+
assert!(backend.list_backups(ListBackupsInput::default()).await.unwrap().backups.is_empty());
|
|
3075
|
+
let ttl = backend.describe_time_to_live("items").await.unwrap();
|
|
3076
|
+
assert_eq!(ttl.attribute_name.as_deref(), Some("expires"), "Time to Live stays enabled");
|
|
3077
|
+
// The faults are gone, and the table takes items again.
|
|
3078
|
+
seed_query_data(&backend).await;
|
|
3079
|
+
assert_eq!(backend.query(by_status).await.unwrap().items.len(), 5);
|
|
3080
|
+
}
|
|
3081
|
+
|
|
3082
|
+
#[tokio::test]
|
|
3083
|
+
async fn tables_created_at_once_are_active_with_their_ttl() {
|
|
3084
|
+
let backend = MemoryBackend::default();
|
|
3085
|
+
let description = backend.create_table_active(table_input("items"), Some("expires".into())).unwrap();
|
|
3086
|
+
assert_eq!(description.table_status, TableStatus::Active);
|
|
3087
|
+
let described = backend.describe_table("items").await.unwrap();
|
|
3088
|
+
assert_eq!(described.table_status, TableStatus::Active, "not CREATING first");
|
|
3089
|
+
assert!(described.global_secondary_indexes.iter().all(|index| index.index_status == Some(IndexStatus::Active)));
|
|
3090
|
+
assert_eq!(backend.describe_time_to_live("items").await.unwrap().attribute_name.as_deref(), Some("expires"));
|
|
3091
|
+
put(&backend, item([("pk", s("p")), ("sk", n(1))])).await;
|
|
3092
|
+
let again = backend.create_table_active(table_input("items"), None).unwrap_err();
|
|
3093
|
+
assert_eq!(code(&again), "ResourceInUseException");
|
|
3094
|
+
let mut bad = table_input("bad");
|
|
3095
|
+
bad.key_schema = keys("missing", None);
|
|
3096
|
+
assert_eq!(code(&backend.create_table_active(bad, None).unwrap_err()), "ValidationException");
|
|
3097
|
+
assert_eq!(
|
|
3098
|
+
code(&backend.create_table_active(table_input("x2"), Some(String::new())).unwrap_err()),
|
|
3099
|
+
"ValidationException"
|
|
3100
|
+
);
|
|
3101
|
+
}
|
|
@@ -244,6 +244,14 @@ impl ServiceError {
|
|
|
244
244
|
Self::new("ValidationException", message)
|
|
245
245
|
}
|
|
246
246
|
|
|
247
|
+
/// Whether this is DynamoDB's refusal of an item over its 400 KB limit (counted with the
|
|
248
|
+
/// item's entries in the table's local secondary indexes): a `ValidationException` whose
|
|
249
|
+
/// message is one of [`ITEM_SIZE_MESSAGES`], also inside the `1 validation error detected: `
|
|
250
|
+
/// envelope.
|
|
251
|
+
pub fn is_item_too_large(&self) -> bool {
|
|
252
|
+
self.kind == ErrorKind::Validation && is_item_size_message(&self.message)
|
|
253
|
+
}
|
|
254
|
+
|
|
247
255
|
/// `ConditionalCheckFailedException`, with the old item if it was requested.
|
|
248
256
|
pub fn conditional_check_failed(item: Option<Item>) -> Self {
|
|
249
257
|
Self { item, ..Self::new("ConditionalCheckFailedException", "The conditional request failed") }
|
|
@@ -366,10 +374,40 @@ impl Error {
|
|
|
366
374
|
}
|
|
367
375
|
}
|
|
368
376
|
|
|
377
|
+
/// DynamoDB's message for an item over its 400 KB limit: of `PutItem`, `BatchWriteItem` and the
|
|
378
|
+
/// cancellation reasons of `TransactWriteItems` (measured in eu-north-1, docs/parity).
|
|
379
|
+
pub const ITEM_SIZE_MESSAGE: &str = "Item size has exceeded the maximum allowed size";
|
|
380
|
+
|
|
381
|
+
/// DynamoDB's message for an `UpdateItem` that makes an item exceed its 400 KB limit.
|
|
382
|
+
pub const UPDATE_SIZE_MESSAGE: &str = "Item size to update has exceeded the maximum allowed size";
|
|
383
|
+
|
|
384
|
+
/// DynamoDB's messages for an item over its 400 KB limit ([`ITEM_SIZE_MESSAGE`],
|
|
385
|
+
/// [`UPDATE_SIZE_MESSAGE`]).
|
|
386
|
+
pub const ITEM_SIZE_MESSAGES: [&str; 2] = [ITEM_SIZE_MESSAGE, UPDATE_SIZE_MESSAGE];
|
|
387
|
+
|
|
388
|
+
/// Whether `message` is (or holds) one of [`ITEM_SIZE_MESSAGES`].
|
|
389
|
+
pub fn is_item_size_message(message: &str) -> bool {
|
|
390
|
+
ITEM_SIZE_MESSAGES.iter().any(|known| message.contains(known))
|
|
391
|
+
}
|
|
392
|
+
|
|
369
393
|
#[cfg(test)]
|
|
370
394
|
mod tests {
|
|
371
395
|
use super::*;
|
|
372
396
|
|
|
397
|
+
#[test]
|
|
398
|
+
fn item_size_refusals_are_recognized() {
|
|
399
|
+
assert!(ServiceError::validation("Item size has exceeded the maximum allowed size").is_item_too_large());
|
|
400
|
+
assert!(
|
|
401
|
+
ServiceError::validation("Item size to update has exceeded the maximum allowed size").is_item_too_large()
|
|
402
|
+
);
|
|
403
|
+
assert!(
|
|
404
|
+
ServiceError::validation("1 validation error detected: Item size has exceeded the maximum allowed size")
|
|
405
|
+
.is_item_too_large()
|
|
406
|
+
);
|
|
407
|
+
assert!(!ServiceError::validation("One or more parameter values were invalid").is_item_too_large());
|
|
408
|
+
assert!(!ServiceError::new("InternalServerError", ITEM_SIZE_MESSAGES[0]).is_item_too_large(), "not a refusal");
|
|
409
|
+
}
|
|
410
|
+
|
|
373
411
|
#[test]
|
|
374
412
|
fn codes_are_classified() {
|
|
375
413
|
assert_eq!(ErrorKind::from_code("ProvisionedThroughputExceededException"), ErrorKind::Throttling);
|
|
@@ -23,7 +23,10 @@ pub mod value;
|
|
|
23
23
|
|
|
24
24
|
pub use client::{BatchGetResult, BatchWriteResult, Call, Client, OperationStats};
|
|
25
25
|
pub use config::{ClientConfig, RetryConfig};
|
|
26
|
-
pub use error::{
|
|
26
|
+
pub use error::{
|
|
27
|
+
CancellationReason, Error, ErrorKind, ITEM_SIZE_MESSAGE, ITEM_SIZE_MESSAGES, Result, ServiceError,
|
|
28
|
+
UPDATE_SIZE_MESSAGE, is_item_size_message,
|
|
29
|
+
};
|
|
27
30
|
pub use value::{AttributeValue, Item, Number};
|
|
28
31
|
|
|
29
32
|
/// Version of the core crate.
|