Hello,
I’m running into an issue when trying to migrate some test fixtures from FQLv4 to FQLv10. I have an existing FQLv4 pytest fixture that generates test databases to run tests against:
@pytest.fixture
def test_db(fauna_admin_client):
"""Create a randomly named test child database for use in this test module and
return its name.
This will delete the test database after the session completes.
"""
# Create the test database
test_db_name = f"test-fluctuate-{uuid4()}"
result = fauna_admin_client.query(query.create_database({"name": test_db_name}))
# Yield the test database.
yield result
# Use a top level admin key to delete the child database.
fauna_admin_client.query(query.delete(result["ref"]))
I converted it to FQLv10 like so:
@pytest.fixture
def test_db(fauna_admin_client):
"""Create a randomly named test child database for use in this test module and
return its name.
This will delete the test database after the session completes.
"""
# Create the test database
test_db_name = f"test-fluctuate-{uuid4()}"
result = fauna_admin_client.query(
fql("Database.create({name: ${test_db_name}})", test_db_name=test_db_name)
)
# Yield the test database.
yield result.data
# Use a top level admin key to delete the child database.
fauna_admin_client.query(
fql("Database.byName(${test_db_name}).delete()", test_db_name=test_db_name)
)
The FQLv4 version works fine. However, when I run the FQLv10 version, I get the following error:
E fauna.errors.errors.QueryRuntimeError: 400: constraint_failure
E Failed to create document in collection Database.
E ---
E constraint failures: [ConstraintFailure(message='Invalid identifier.', name=None, paths=[['name']])]
E ---
E error: Failed to create document in collection Database.
E constraint failures:
E name: Invalid identifier.
E at *query*:1:16
E |
E 1 | Database.create({name: <value>})
E | ^^^^^^^^^^^^^^^^^
E |
The name it was trying to use in this case was test-fluctuate-bca9ec33-9c58-493b-9616-442655a647c6
. Are there new limitations on DB names in FQLv10? There are no docs on the Database
collection yet that I can find to confirm one way or the other.