|
17 | 17 | AQLQueryTrackingSetError,
|
18 | 18 | AQLQueryValidateError,
|
19 | 19 | )
|
20 |
| -from tests.helpers import assert_raises, extract |
| 20 | +from tests.helpers import assert_raises, extract, generate_col_name |
21 | 21 |
|
22 | 22 |
|
23 | 23 | def test_aql_attributes(db, username):
|
@@ -246,6 +246,36 @@ def test_aql_query_management(db_version, db, bad_db, col, docs):
|
246 | 246 | assert err.value.error_code in {11, 1228}
|
247 | 247 |
|
248 | 248 |
|
| 249 | +def test_aql_query_force_one_shard_attribute_value(db, db_version, enterprise, cluster): |
| 250 | + if db_version < version.parse("3.10") or not enterprise or not cluster: |
| 251 | + return |
| 252 | + |
| 253 | + name = generate_col_name() |
| 254 | + col = db.create_collection(name, shard_fields=["foo"], shard_count=3) |
| 255 | + |
| 256 | + doc = {"foo": "bar"} |
| 257 | + col.insert(doc) |
| 258 | + |
| 259 | + cursor = db.aql.execute( |
| 260 | + "FOR d IN @@c RETURN d", |
| 261 | + bind_vars={"@c": name}, |
| 262 | + force_one_shard_attribute_value="bar", |
| 263 | + ) |
| 264 | + |
| 265 | + results = [doc for doc in cursor] |
| 266 | + assert len(results) == 1 |
| 267 | + assert results[0]["foo"] == "bar" |
| 268 | + |
| 269 | + cursor = db.aql.execute( |
| 270 | + "FOR d IN @@c RETURN d", |
| 271 | + bind_vars={"@c": name}, |
| 272 | + force_one_shard_attribute_value="ooo", |
| 273 | + ) |
| 274 | + |
| 275 | + results = [doc for doc in cursor] |
| 276 | + assert len(results) == 0 |
| 277 | + |
| 278 | + |
249 | 279 | def test_aql_function_management(db, bad_db):
|
250 | 280 | fn_group = "functions::temperature"
|
251 | 281 | fn_name_1 = "functions::temperature::celsius_to_fahrenheit"
|
|
0 commit comments