diff --git a/docs/api/asyncio_con.rst b/docs/api/asyncio_con.rst index a0dfbe06..53f20dbd 100644 --- a/docs/api/asyncio_con.rst +++ b/docs/api/asyncio_con.rst @@ -105,7 +105,7 @@ Connection >>> import edgedb >>> async def main(): ... con = await edgedb.async_connect(user='edgedeb') - ... print(await con.query_one('SELECT 1 + 1')) + ... print(await con.query_single('SELECT 1 + 1')) ... >>> asyncio.run(main()) {2} @@ -134,7 +134,7 @@ Connection Note that positional and named query arguments cannot be mixed. - .. py:coroutinemethod:: query_one(query, *args, **kwargs) + .. py:coroutinemethod:: query_single(query, *args, **kwargs) Run a singleton-returning query and return its element. @@ -179,7 +179,7 @@ Connection more appropriate type, such as ``Decimal``. - .. py:coroutinemethod:: query_one_json(query, *args, **kwargs) + .. py:coroutinemethod:: query_single_json(query, *args, **kwargs) Run a singleton-returning query and return its element in JSON. @@ -232,7 +232,7 @@ Connection .. note:: If the results of *query* are desired, :py:meth:`query` or - :py:meth:`query_one` should be used instead. + :py:meth:`query_single` should be used instead. .. py:method:: retrying_transaction() @@ -254,7 +254,7 @@ Connection async for tx in con.retrying_transaction(): async with tx: - value = await tx.query_one("SELECT Counter.value") + value = await tx.query_single("SELECT Counter.value") await tx.execute( "UPDATE Counter SET { value := $value }", value=value + 1, @@ -282,7 +282,7 @@ Connection .. code-block:: python async with con.raw_transaction() as tx: - value = await tx.query_one("SELECT Counter.value") + value = await tx.query_single("SELECT Counter.value") await tx.execute( "UPDATE Counter SET { value := $value }", value=value + 1, @@ -368,9 +368,9 @@ Connection Pools from the pool: * :py:meth:`AsyncIOPool.query()` - * :py:meth:`AsyncIOPool.query_one()` + * :py:meth:`AsyncIOPool.query_single()` * :py:meth:`AsyncIOPool.query_json()` - * :py:meth:`AsyncIOPool.query_one_json()` + * :py:meth:`AsyncIOPool.query_single_json()` * :py:meth:`AsyncIOPool.execute()` * :py:meth:`AsyncIOPool.retrying_transaction()` * :py:meth:`AsyncIOPool.raw_transaction()` @@ -505,14 +505,14 @@ Connection Pools See :py:meth:`AsyncIOConnection.query() ` for details. - .. py:coroutinemethod:: query_one(query, *args, **kwargs) + .. py:coroutinemethod:: query_single(query, *args, **kwargs) Acquire a connection and use it to run a singleton-returning query and return its element. The temporary connection is automatically returned back to the pool. - See :py:meth:`AsyncIOConnection.query_one() - ` for details. + See :py:meth:`AsyncIOConnection.query_single() + ` for details. .. py:coroutinemethod:: query_json(query, *args, **kwargs) @@ -523,14 +523,14 @@ Connection Pools See :py:meth:`AsyncIOConnection.query_json() ` for details. - .. py:coroutinemethod:: query_one_json(query, *args, **kwargs) + .. py:coroutinemethod:: query_single_json(query, *args, **kwargs) Acquire a connection and use it to run a singleton-returning query and return its element in JSON. The temporary connection is automatically returned back to the pool. - See :py:meth:`AsyncIOConnection.query_one_json() - ` for details. + See :py:meth:`AsyncIOConnection.query_single_json() + ` for details. .. py:coroutinemethod:: execute(query) @@ -561,7 +561,7 @@ Connection Pools async for tx in pool.retrying_transaction(): async with tx: - value = await tx.query_one("SELECT Counter.value") + value = await tx.query_single("SELECT Counter.value") await tx.execute( "UPDATE Counter SET { value := $value", value=value, @@ -589,7 +589,7 @@ Connection Pools .. code-block:: python async with pool.raw_transaction() as tx: - value = await tx.query_one("SELECT Counter.value") + value = await tx.query_single("SELECT Counter.value") await tx.execute( "UPDATE Counter SET { value := $value", value=value, @@ -635,7 +635,7 @@ Python code. Here is an example: async for tx in pool.retrying_transaction(): async with tx: - user = await tx.query_one( + user = await tx.query_single( "SELECT User { email } FILTER .login = $login", login=login, ) @@ -643,7 +643,7 @@ Python code. Here is an example: 'https://service.local/email_info', params=dict(email=user.email), ) - user = await tx.query_one(''' + user = await tx.query_single(''' UPDATE User FILTER .login = $login SET { email_info := $data} ''', @@ -707,14 +707,14 @@ See also: See :py:meth:`AsyncIOConnection.query() ` for details. - .. py:coroutinemethod:: query_one(query, *args, **kwargs) + .. py:coroutinemethod:: query_single(query, *args, **kwargs) Acquire a connection and use it to run a singleton-returning query and return its element. The temporary connection is automatically returned back to the pool. - See :py:meth:`AsyncIOConnection.query_one() - ` for details. + See :py:meth:`AsyncIOConnection.query_single() + ` for details. .. py:coroutinemethod:: query_json(query, *args, **kwargs) @@ -725,14 +725,14 @@ See also: See :py:meth:`AsyncIOConnection.query_json() ` for details. - .. py:coroutinemethod:: query_one_json(query, *args, **kwargs) + .. py:coroutinemethod:: query_single_json(query, *args, **kwargs) Acquire a connection and use it to run a singleton-returning query and return its element in JSON. The temporary connection is automatically returned back to the pool. - See :py:meth:`AsyncIOConnection.query_one_json() - ` for details. + See :py:meth:`AsyncIOConnection.query_single_json() + ` for details. .. py:coroutinemethod:: execute(query) diff --git a/docs/api/blocking_con.rst b/docs/api/blocking_con.rst index 309dcee1..1b8de154 100644 --- a/docs/api/blocking_con.rst +++ b/docs/api/blocking_con.rst @@ -103,7 +103,7 @@ Connection >>> import edgedb >>> con = edgedb.connect(user='edgedeb') - >>> con.query_one('SELECT 1 + 1') + >>> con.query_single('SELECT 1 + 1') {2} @@ -130,7 +130,7 @@ Connection Note that positional and named query arguments cannot be mixed. - .. py:method:: query_one(query, *args, **kwargs) + .. py:method:: query_single(query, *args, **kwargs) Run a singleton-returning query and return its element. @@ -175,7 +175,7 @@ Connection more appropriate type, such as ``Decimal``. - .. py:method:: query_one_json(query, *args, **kwargs) + .. py:method:: query_single_json(query, *args, **kwargs) Run a singleton-returning query and return its element in JSON. @@ -228,7 +228,7 @@ Connection .. note:: If the results of *query* are desired, :py:meth:`query` or - :py:meth:`query_one` should be used instead. + :py:meth:`query_single` should be used instead. .. py:method:: retrying_transaction() @@ -250,7 +250,7 @@ Connection for tx in con.retrying_transaction(): with tx: - value = tx.query_one("SELECT Counter.value") + value = tx.query_single("SELECT Counter.value") tx.execute( "UPDATE Counter SET { value := $value }", value=value + 1, @@ -278,7 +278,7 @@ Connection .. code-block:: python with con.raw_transaction() as tx: - value = tx.query_one("SELECT Counter.value") + value = tx.query_single("SELECT Counter.value") tx.execute( "UPDATE Counter SET { value := $value }", value=value + 1, @@ -355,7 +355,7 @@ Python code. Here is an example: for tx in pool.retrying_transaction(): with tx: - user = tx.query_one( + user = tx.query_single( "SELECT User { email } FILTER .login = $login", login=login, ) @@ -363,7 +363,7 @@ Python code. Here is an example: 'https://service.local/email_info', params=dict(email=user.email), ) - user = tx.query_one(''' + user = tx.query_single(''' UPDATE User FILTER .login = $login SET { email_info := $data} ''', diff --git a/docs/api/types.rst b/docs/api/types.rst index a5eeccfd..e4665c8d 100644 --- a/docs/api/types.rst +++ b/docs/api/types.rst @@ -113,7 +113,7 @@ Objects >>> import edgedb >>> conn = edgedb.connect() - >>> r = conn.query_one(''' + >>> r = conn.query_single(''' ... SELECT schema::ObjectType {name} ... FILTER .name = 'std::Object' ... LIMIT 1''') @@ -134,7 +134,7 @@ Objects >>> import edgedb >>> conn = edgedb.connect() - >>> r = conn.query_one(''' + >>> r = conn.query_single(''' ... SELECT schema::Property {name, annotations: {name, @value}} ... FILTER .name = 'listen_port' ... AND .source.name = 'cfg::Config' @@ -190,7 +190,7 @@ Tuples >>> import edgedb >>> conn = edgedb.connect() - >>> r = conn.query_one('''SELECT (1, 'a', [3])''') + >>> r = conn.query_single('''SELECT (1, 'a', [3])''') >>> r (1, 'a', [3]) >>> len(r) @@ -215,7 +215,7 @@ Named Tuples >>> import edgedb >>> conn = edgedb.connect() - >>> r = conn.query_one('''SELECT (a := 1, b := 'a', c := [3])''') + >>> r = conn.query_single('''SELECT (a := 1, b := 'a', c := [3])''') >>> r (a := 1, b := 'a', c := [3]) >>> r.b @@ -237,7 +237,7 @@ Arrays >>> import edgedb >>> conn = edgedb.connect() - >>> r = conn.query_one('''SELECT [1, 2, 3]''') + >>> r = conn.query_single('''SELECT [1, 2, 3]''') >>> r [1, 2, 3] >>> len(r) @@ -258,7 +258,7 @@ RelativeDuration >>> import edgedb >>> conn = edgedb.connect() - >>> r = conn.query_one('''SELECT "1 year 2 days"''') + >>> r = conn.query_single('''SELECT "1 year 2 days"''') >>> r >>> r.months diff --git a/docs/usage.rst b/docs/usage.rst index addeb648..9c6723bc 100644 --- a/docs/usage.rst +++ b/docs/usage.rst @@ -150,7 +150,7 @@ Below is an example of a connection pool usage: username = int(request.match_info.get('name')) # Execute the query on any pool connection - result = await pool.query_one_json( + result = await pool.query_single_json( ''' SELECT User {first_name, email, bio} FILTER .name = $username @@ -181,7 +181,7 @@ You can also acquire connection from the pool: .. code-block:: python async with pool.acquire() as conn: - result = await conn.query_one_json( + result = await conn.query_single_json( ''' SELECT User {first_name, email, bio} FILTER .name = $username diff --git a/edgedb/abstract.py b/edgedb/abstract.py index 5fd4451e..29ba6770 100644 --- a/edgedb/abstract.py +++ b/edgedb/abstract.py @@ -15,7 +15,7 @@ def query(self, query: str, *args, **kwargs) -> datatypes.Set: ... @abc.abstractmethod - def query_one(self, query: str, *args, **kwargs) -> typing.Any: + def query_single(self, query: str, *args, **kwargs) -> typing.Any: ... @abc.abstractmethod @@ -23,7 +23,7 @@ def query_json(self, query: str, *args, **kwargs) -> str: ... @abc.abstractmethod - def query_one_json(self, query: str, *args, **kwargs) -> str: + def query_single_json(self, query: str, *args, **kwargs) -> str: ... # TODO(tailhook) add *args, **kwargs, when they are supported @@ -44,7 +44,7 @@ async def query(self, query: str, *args, **kwargs) -> datatypes.Set: ... @abc.abstractmethod - async def query_one(self, query: str, *args, **kwargs) -> typing.Any: + async def query_single(self, query: str, *args, **kwargs) -> typing.Any: ... @abc.abstractmethod @@ -52,7 +52,7 @@ async def query_json(self, query: str, *args, **kwargs) -> str: ... @abc.abstractmethod - async def query_one_json(self, query: str, *args, **kwargs) -> str: + async def query_single_json(self, query: str, *args, **kwargs) -> str: ... # TODO(tailhook) add *args, **kwargs, when they are supported diff --git a/edgedb/asyncio_con.py b/edgedb/asyncio_con.py index a84a9e74..9b2cdf66 100644 --- a/edgedb/asyncio_con.py +++ b/edgedb/asyncio_con.py @@ -346,7 +346,7 @@ async def query(self, query: str, *args, **kwargs) -> datatypes.Set: ) return result - async def query_one(self, query: str, *args, **kwargs) -> typing.Any: + async def query_single(self, query: str, *args, **kwargs) -> typing.Any: inner = self._inner if inner._borrowed_for: raise base_con.borrow_error(inner._borrowed_for) @@ -396,7 +396,7 @@ async def _fetchall_json_elements( ) return result - async def query_one_json(self, query: str, *args, **kwargs) -> str: + async def query_single_json(self, query: str, *args, **kwargs) -> str: inner = self._inner if inner._borrowed_for: raise base_con.borrow_error(inner._borrowed_for) @@ -486,12 +486,19 @@ async def fetchall(self, query: str, *args, **kwargs) -> datatypes.Set: DeprecationWarning, 2) return await self.query(query, *args, **kwargs) + async def query_one(self, query: str, *args, **kwargs) -> typing.Any: + warnings.warn( + 'The "query_one()" method is deprecated and is scheduled to be ' + 'removed. Use the "query_single()" method instead.', + DeprecationWarning, 2) + return await self.query_single(query, *args, **kwargs) + async def fetchone(self, query: str, *args, **kwargs) -> typing.Any: warnings.warn( 'The "fetchone()" method is deprecated and is scheduled to be ' - 'removed. Use the "query_one()" method instead.', + 'removed. Use the "query_single()" method instead.', DeprecationWarning, 2) - return await self.query_one(query, *args, **kwargs) + return await self.query_single(query, *args, **kwargs) async def fetchall_json(self, query: str, *args, **kwargs) -> str: warnings.warn( @@ -500,12 +507,19 @@ async def fetchall_json(self, query: str, *args, **kwargs) -> str: DeprecationWarning, 2) return await self.query_json(query, *args, **kwargs) + async def query_one_json(self, query: str, *args, **kwargs) -> str: + warnings.warn( + 'The "query_one_json()" method is deprecated and is scheduled to ' + 'be removed. Use the "query_single_json()" method instead.', + DeprecationWarning, 2) + return await self.query_single_json(query, *args, **kwargs) + async def fetchone_json(self, query: str, *args, **kwargs) -> str: warnings.warn( 'The "fetchone_json()" method is deprecated and is scheduled to ' - 'be removed. Use the "query_one_json()" method instead.', + 'be removed. Use the "query_single_json()" method instead.', DeprecationWarning, 2) - return await self.query_one_json(query, *args, **kwargs) + return await self.query_single_json(query, *args, **kwargs) async def async_connect(dsn: str = None, *, diff --git a/edgedb/asyncio_pool.py b/edgedb/asyncio_pool.py index 90c8e409..1155fdb7 100644 --- a/edgedb/asyncio_pool.py +++ b/edgedb/asyncio_pool.py @@ -619,17 +619,17 @@ async def query(self, query, *args, **kwargs): async with self.acquire() as con: return await con.query(query, *args, **kwargs) - async def query_one(self, query, *args, **kwargs): + async def query_single(self, query, *args, **kwargs): async with self.acquire() as con: - return await con.query_one(query, *args, **kwargs) + return await con.query_single(query, *args, **kwargs) async def query_json(self, query, *args, **kwargs): async with self.acquire() as con: return await con.query_json(query, *args, **kwargs) - async def query_one_json(self, query, *args, **kwargs): + async def query_single_json(self, query, *args, **kwargs): async with self.acquire() as con: - return await con.query_one_json(query, *args, **kwargs) + return await con.query_single_json(query, *args, **kwargs) async def fetchall(self, query: str, *args, **kwargs) -> datatypes.Set: warnings.warn( @@ -641,9 +641,9 @@ async def fetchall(self, query: str, *args, **kwargs) -> datatypes.Set: async def fetchone(self, query: str, *args, **kwargs) -> typing.Any: warnings.warn( 'The "fetchone()" method is deprecated and is scheduled to be ' - 'removed. Use the "query_one()" method instead.', + 'removed. Use the "query_single()" method instead.', DeprecationWarning, 2) - return await self.query_one(query, *args, **kwargs) + return await self.query_single(query, *args, **kwargs) async def fetchall_json(self, query: str, *args, **kwargs) -> str: warnings.warn( @@ -655,9 +655,9 @@ async def fetchall_json(self, query: str, *args, **kwargs) -> str: async def fetchone_json(self, query: str, *args, **kwargs) -> str: warnings.warn( 'The "fetchone_json()" method is deprecated and is scheduled to ' - 'be removed. Use the "query_one_json()" method instead.', + 'be removed. Use the "query_single_json()" method instead.', DeprecationWarning, 2) - return await self.query_one_json(query, *args, **kwargs) + return await self.query_single_json(query, *args, **kwargs) async def execute(self, query): async with self.acquire() as con: diff --git a/edgedb/blocking_con.py b/edgedb/blocking_con.py index 2aca76c7..d9391281 100644 --- a/edgedb/blocking_con.py +++ b/edgedb/blocking_con.py @@ -306,7 +306,7 @@ def query(self, query: str, *args, **kwargs) -> datatypes.Set: io_format=protocol.IoFormat.BINARY, ) - def query_one(self, query: str, *args, **kwargs) -> typing.Any: + def query_single(self, query: str, *args, **kwargs) -> typing.Any: inner = self._inner return self._get_protocol().sync_execute_anonymous( query=query, @@ -341,7 +341,7 @@ def _fetchall_json_elements( io_format=protocol.IoFormat.JSON_ELEMENTS, ) - def query_one_json(self, query: str, *args, **kwargs) -> str: + def query_single_json(self, query: str, *args, **kwargs) -> str: inner = self._inner return self._get_protocol().sync_execute_anonymous( query=query, @@ -360,12 +360,19 @@ def fetchall(self, query: str, *args, **kwargs) -> datatypes.Set: DeprecationWarning, 2) return self.query(query, *args, **kwargs) + def query_one(self, query: str, *args, **kwargs) -> typing.Any: + warnings.warn( + 'The "query_one()" method is deprecated and is scheduled to be ' + 'removed. Use the "query_single()" method instead.', + DeprecationWarning, 2) + return self.query_single(query, *args, **kwargs) + def fetchone(self, query: str, *args, **kwargs) -> typing.Any: warnings.warn( 'The "fetchone()" method is deprecated and is scheduled to be ' - 'removed. Use the "query_one()" method instead.', + 'removed. Use the "query_single()" method instead.', DeprecationWarning, 2) - return self.query_one(query, *args, **kwargs) + return self.query_single(query, *args, **kwargs) def fetchall_json(self, query: str, *args, **kwargs) -> str: warnings.warn( @@ -374,12 +381,19 @@ def fetchall_json(self, query: str, *args, **kwargs) -> str: DeprecationWarning, 2) return self.query_json(query, *args, **kwargs) + def query_one_json(self, query: str, *args, **kwargs) -> str: + warnings.warn( + 'The "query_one_json()" method is deprecated and is scheduled to ' + 'be removed. Use the "query_single_json()" method instead.', + DeprecationWarning, 2) + return self.query_single_json(query, *args, **kwargs) + def fetchone_json(self, query: str, *args, **kwargs) -> str: warnings.warn( 'The "fetchone_json()" method is deprecated and is scheduled to ' - 'be removed. Use the "query_one_json()" method instead.', + 'be removed. Use the "query_single_json()" method instead.', DeprecationWarning, 2) - return self.query_one_json(query, *args, **kwargs) + return self.query_single_json(query, *args, **kwargs) def execute(self, query: str) -> None: self._get_protocol().sync_simple_query(query, enums.Capability.EXECUTE) diff --git a/edgedb/protocol/protocol.pyx b/edgedb/protocol/protocol.pyx index f7ecac59..370bd6ff 100644 --- a/edgedb/protocol/protocol.pyx +++ b/edgedb/protocol/protocol.pyx @@ -70,10 +70,10 @@ include "./codecs/codecs.pyx" cpython.datetime.import_datetime() -_FETCHONE_METHOD = { - IoFormat.JSON: 'query_one_json', +_QUERY_SINGLE_METHOD = { + IoFormat.JSON: 'query_single_json', IoFormat.JSON_ELEMENTS: '_fetchall_json_elements', - IoFormat.BINARY: 'query_one', + IoFormat.BINARY: 'query_single', } ALL_CAPABILITIES = 0xFFFFFFFFFFFFFFFF @@ -325,7 +325,7 @@ cdef class SansIOProtocol: raise exc if expect_one and cardinality == CARDINALITY_NOT_APPLICABLE: - methname = _FETCHONE_METHOD[io_format] + methname = _QUERY_SINGLE_METHOD[io_format] raise errors.InterfaceError( f'query cannot be executed with {methname}() as it ' f'does not return any data') @@ -525,7 +525,7 @@ cdef class SansIOProtocol: if re_exec: assert new_cardinality is not None if expect_one and new_cardinality == CARDINALITY_NOT_APPLICABLE: - methname = _FETCHONE_METHOD[io_format] + methname = _QUERY_SINGLE_METHOD[io_format] raise errors.InterfaceError( f'query cannot be executed with {methname}() as it ' f'does not return any data') @@ -644,7 +644,7 @@ cdef class SansIOProtocol: out_dc = codecs[2] if expect_one and has_na_cardinality: - methname = _FETCHONE_METHOD[io_format] + methname = _QUERY_SINGLE_METHOD[io_format] raise errors.InterfaceError( f'query cannot be executed with {methname}() as it ' f'does not return any data') @@ -669,7 +669,7 @@ cdef class SansIOProtocol: if ret: return ret[0], attrs else: - methname = _FETCHONE_METHOD[io_format] + methname = _QUERY_SINGLE_METHOD[io_format] raise errors.NoDataError( f'query executed via {methname}() returned no data') else: @@ -1237,7 +1237,7 @@ cdef class SansIOProtocol: cdef _amend_parse_error(self, exc, IoFormat io_format, bint expect_one): if expect_one and exc.get_code() == result_cardinality_mismatch_code: - methname = _FETCHONE_METHOD[io_format] + methname = _QUERY_SINGLE_METHOD[io_format] new_exc = errors.InterfaceError( f'query cannot be executed with {methname}() as it ' f'returns a multiset') diff --git a/edgedb/transaction.py b/edgedb/transaction.py index ce66e141..0fce3188 100644 --- a/edgedb/transaction.py +++ b/edgedb/transaction.py @@ -206,7 +206,7 @@ async def query(self, query: str, *args, **kwargs) -> datatypes.Set: ) return result - async def query_one(self, query: str, *args, **kwargs) -> typing.Any: + async def query_single(self, query: str, *args, **kwargs) -> typing.Any: con = self._connection_inner result, _ = await self._connection_impl._protocol.execute_anonymous( query=query, @@ -231,7 +231,7 @@ async def query_json(self, query: str, *args, **kwargs) -> str: ) return result - async def query_one_json(self, query: str, *args, **kwargs) -> str: + async def query_single_json(self, query: str, *args, **kwargs) -> str: con = self._connection_inner result, _ = await self._connection_impl._protocol.execute_anonymous( query=query, @@ -353,7 +353,7 @@ def query(self, query: str, *args, **kwargs) -> datatypes.Set: io_format=protocol.IoFormat.BINARY, ) - def query_one(self, query: str, *args, **kwargs) -> typing.Any: + def query_single(self, query: str, *args, **kwargs) -> typing.Any: con = self._connection_inner return self._connection_impl._protocol.sync_execute_anonymous( query=query, @@ -376,7 +376,7 @@ def query_json(self, query: str, *args, **kwargs) -> str: io_format=protocol.IoFormat.JSON, ) - def query_one_json(self, query: str, *args, **kwargs) -> str: + def query_single_json(self, query: str, *args, **kwargs) -> str: con = self._connection_inner return self._connection_impl._protocol.sync_execute_anonymous( query=query, diff --git a/tests/test_async_fetch.py b/tests/test_async_query.py similarity index 87% rename from tests/test_async_fetch.py rename to tests/test_async_query.py index 08f71368..e8bf8060 100644 --- a/tests/test_async_fetch.py +++ b/tests/test_async_query.py @@ -31,7 +31,7 @@ from edgedb import _testbase as tb -class TestAsyncFetch(tb.AsyncQueryTestCase): +class TestAsyncQuery(tb.AsyncQueryTestCase): ISOLATED_METHODS = False @@ -132,36 +132,36 @@ async def test_async_exec_error_recover_05(self): await self.con.query('SELECT "HELLO"'), ["HELLO"]) - async def test_async_fetch_single_command_01(self): + async def test_async_query_single_command_01(self): r = await self.con.query(''' - CREATE TYPE test::server_fetch_single_command_01 { - CREATE REQUIRED PROPERTY server_fetch_single_command_01 -> + CREATE TYPE test::server_query_single_command_01 { + CREATE REQUIRED PROPERTY server_query_single_command_01 -> std::str; }; ''') self.assertEqual(r, []) r = await self.con.query(''' - DROP TYPE test::server_fetch_single_command_01; + DROP TYPE test::server_query_single_command_01; ''') self.assertEqual(r, []) r = await self.con.query(''' - CREATE TYPE test::server_fetch_single_command_01 { - CREATE REQUIRED PROPERTY server_fetch_single_command_01 -> + CREATE TYPE test::server_query_single_command_01 { + CREATE REQUIRED PROPERTY server_query_single_command_01 -> std::str; }; ''') self.assertEqual(r, []) r = await self.con.query_json(''' - DROP TYPE test::server_fetch_single_command_01; + DROP TYPE test::server_query_single_command_01; ''') self.assertEqual(r, '[]') r = await self.con.query_json(''' - CREATE TYPE test::server_fetch_single_command_01 { - CREATE REQUIRED PROPERTY server_fetch_single_command_01 -> + CREATE TYPE test::server_query_single_command_01 { + CREATE REQUIRED PROPERTY server_query_single_command_01 -> std::str; }; ''') @@ -169,19 +169,19 @@ async def test_async_fetch_single_command_01(self): with self.assertRaisesRegex( edgedb.InterfaceError, - r'query cannot be executed with query_one_json\('): - await self.con.query_one_json(''' - DROP TYPE test::server_fetch_single_command_01; + r'query cannot be executed with query_single_json\('): + await self.con.query_single_json(''' + DROP TYPE test::server_query_single_command_01; ''') r = await self.con.query_json(''' - DROP TYPE test::server_fetch_single_command_01; + DROP TYPE test::server_query_single_command_01; ''') self.assertEqual(r, '[]') self.assertTrue(self.con._get_last_status().startswith('DROP')) - async def test_async_fetch_single_command_02(self): + async def test_async_query_single_command_02(self): r = await self.con.query(''' SET MODULE default; ''') @@ -217,7 +217,7 @@ async def test_async_fetch_single_command_02(self): ''') self.assertEqual(r, '[]') - async def test_async_fetch_single_command_03(self): + async def test_async_query_single_command_03(self): qs = [ 'START TRANSACTION', 'DECLARE SAVEPOINT t0', @@ -239,17 +239,17 @@ async def test_async_fetch_single_command_03(self): with self.assertRaisesRegex( edgedb.InterfaceError, - r'cannot be executed with query_one\(\).*' + r'cannot be executed with query_single\(\).*' r'not return'): - await self.con.query_one('START TRANSACTION') + await self.con.query_single('START TRANSACTION') with self.assertRaisesRegex( edgedb.InterfaceError, - r'cannot be executed with query_one_json\(\).*' + r'cannot be executed with query_single_json\(\).*' r'not return'): - await self.con.query_one_json('START TRANSACTION') + await self.con.query_single_json('START TRANSACTION') - async def test_async_fetch_single_command_04(self): + async def test_async_query_single_command_04(self): with self.assertRaisesRegex(edgedb.ProtocolError, 'expected one statement'): await self.con.query(''' @@ -259,7 +259,7 @@ async def test_async_fetch_single_command_04(self): with self.assertRaisesRegex(edgedb.ProtocolError, 'expected one statement'): - await self.con.query_one(''' + await self.con.query_single(''' SELECT 1; SET MODULE blah; ''') @@ -274,7 +274,7 @@ async def test_async_fetch_single_command_04(self): async def test_async_basic_datatypes_01(self): for _ in range(10): self.assertEqual( - await self.con.query_one( + await self.con.query_single( 'select ()'), ()) @@ -285,7 +285,7 @@ async def test_async_basic_datatypes_01(self): async with self.con.transaction(isolation='repeatable_read'): self.assertEqual( - await self.con.query_one( + await self.con.query_single( 'select >[]'), []) @@ -306,11 +306,13 @@ async def test_async_basic_datatypes_01(self): with self.assertRaisesRegex( edgedb.InterfaceError, - r'query_one\(\) as it returns a multiset'): - await self.con.query_one('SELECT {1, 2}') + r'query_single\(\) as it returns a multiset'): + await self.con.query_single('SELECT {1, 2}') - with self.assertRaisesRegex(edgedb.NoDataError, r'\bquery_one\('): - await self.con.query_one('SELECT {}') + with self.assertRaisesRegex( + edgedb.NoDataError, + r'\bquery_single\('): + await self.con.query_single('SELECT {}') async def test_async_basic_datatypes_02(self): self.assertEqual( @@ -348,7 +350,7 @@ async def test_async_basic_datatypes_03(self): self.assertEqual( json.loads( - await self.con.query_one_json( + await self.con.query_single_json( 'select ["a", "b"]')), ["a", "b"]) @@ -373,10 +375,10 @@ async def test_async_basic_datatypes_03(self): []) with self.assertRaises(edgedb.NoDataError): - await self.con.query_one_json('SELECT {}') + await self.con.query_single_json('SELECT {}') async def test_async_basic_datatypes_04(self): - val = await self.con.query_one( + val = await self.con.query_single( ''' SELECT schema::ObjectType { foo := { @@ -436,56 +438,56 @@ async def test_async_args_04(self): aware_time = datetime.time(hour=11, tzinfo=datetime.timezone.utc) self.assertEqual( - await self.con.query_one( + await self.con.query_single( 'select $0;', aware_datetime), aware_datetime) self.assertEqual( - await self.con.query_one( + await self.con.query_single( 'select $0;', naive_datetime), naive_datetime) self.assertEqual( - await self.con.query_one( + await self.con.query_single( 'select $0;', date), date) self.assertEqual( - await self.con.query_one( + await self.con.query_single( 'select $0;', naive_time), naive_time) with self.assertRaisesRegex(edgedb.InvalidArgumentError, r'a timezone-aware.*expected'): - await self.con.query_one( + await self.con.query_single( 'select $0;', naive_datetime) with self.assertRaisesRegex(edgedb.InvalidArgumentError, r'a naive time object.*expected'): - await self.con.query_one( + await self.con.query_single( 'select $0;', aware_time) with self.assertRaisesRegex(edgedb.InvalidArgumentError, r'a naive datetime object.*expected'): - await self.con.query_one( + await self.con.query_single( 'select $0;', aware_datetime) with self.assertRaisesRegex(edgedb.InvalidArgumentError, r'datetime.datetime object was expected'): - await self.con.query_one( + await self.con.query_single( 'select $0;', date) with self.assertRaisesRegex(edgedb.InvalidArgumentError, r'datetime.datetime object was expected'): - await self.con.query_one( + await self.con.query_single( 'select $0;', date) @@ -535,24 +537,24 @@ async def test_async_mismatched_args_05(self): await self.con.query("""SELECT $a;""", a=1, b=2) async def test_async_args_uuid_pack(self): - obj = await self.con.query_one( + obj = await self.con.query_single( 'select schema::Object {id, name} limit 1') # Test that the custom UUID that our driver uses can be # passed back as a parameter. - ot = await self.con.query_one( + ot = await self.con.query_single( 'select schema::Object {name} filter .id=$id', id=obj.id) self.assertEqual(obj, ot) # Test that a string UUID is acceptable. - ot = await self.con.query_one( + ot = await self.con.query_single( 'select schema::Object {name} filter .id=$id', id=str(obj.id)) self.assertEqual(obj, ot) # Test that a standard uuid.UUID is acceptable. - ot = await self.con.query_one( + ot = await self.con.query_single( 'select schema::Object {name} filter .id=$id', id=uuid.UUID(bytes=obj.id.bytes)) self.assertEqual(obj, ot) @@ -632,14 +634,14 @@ async def test_async_args_bigint_basic(self): num += random.choice("0000000012") testar.append(int(num)) - val = await self.con.query_one( + val = await self.con.query_single( 'select >$arg', arg=testar) self.assertEqual(testar, val) async def test_async_args_bigint_pack(self): - val = await self.con.query_one( + val = await self.con.query_single( 'select $arg', arg=10) self.assertEqual(val, 10) @@ -676,7 +678,7 @@ async def test_async_args_bigint_pack(self): with self.assertRaisesRegex(edgedb.InvalidArgumentError, 'expected an int'): - await self.con.query_one( + await self.con.query_single( 'select $arg', arg=decimal.Decimal('10')) @@ -686,7 +688,7 @@ class IntLike: def __int__(self): return 10 - await self.con.query_one( + await self.con.query_single( 'select $arg', arg=IntLike()) @@ -697,19 +699,19 @@ def __int__(self): with self.assertRaisesRegex(edgedb.InvalidArgumentError, 'expected an int'): - await self.con.query_one( + await self.con.query_single( 'select $arg', arg=IntLike()) with self.assertRaisesRegex(edgedb.InvalidArgumentError, 'expected an int'): - await self.con.query_one( + await self.con.query_single( 'select $arg', arg=IntLike()) with self.assertRaisesRegex(edgedb.InvalidArgumentError, 'expected an int'): - await self.con.query_one( + await self.con.query_single( 'select $arg', arg=IntLike()) @@ -718,24 +720,24 @@ class IntLike: def __int__(self): return 10 - val = await self.con.query_one('select $0', - decimal.Decimal("10.0")) + val = await self.con.query_single('select $0', + decimal.Decimal("10.0")) self.assertEqual(val, 10) with self.assertRaisesRegex(edgedb.InvalidArgumentError, 'expected a Decimal or an int'): - await self.con.query_one( + await self.con.query_single( 'select $arg', arg=IntLike()) with self.assertRaisesRegex(edgedb.InvalidArgumentError, 'expected a Decimal or an int'): - await self.con.query_one( + await self.con.query_single( 'select $arg', arg="10.2") async def test_async_wait_cancel_01(self): - underscored_lock = await self.con.query_one(""" + underscored_lock = await self.con.query_single(""" SELECT EXISTS( SELECT schema::Function FILTER .name = 'sys::_advisory_lock' ) @@ -750,7 +752,7 @@ async def test_async_wait_cancel_01(self): con2 = await self.connect(database=self.con.dbname) async with self.con.raw_transaction() as tx: - self.assertTrue(await tx.query_one( + self.assertTrue(await tx.query_single( 'select sys::_advisory_lock($0)', lock_key)) @@ -791,7 +793,7 @@ async def exec_to_fail(): [True]) async def test_empty_set_unpack(self): - await self.con.query_one(''' + await self.con.query_single(''' select schema::Function { name, params: { @@ -804,30 +806,30 @@ async def test_empty_set_unpack(self): ''') async def test_enum_argument_01(self): - A = await self.con.query_one('SELECT $0', 'A') + A = await self.con.query_single('SELECT $0', 'A') self.assertEqual(str(A), 'A') with self.assertRaisesRegex( edgedb.InvalidValueError, 'invalid input value for enum'): async with self.con.raw_transaction() as tx: - await tx.query_one('SELECT $0', 'Oups') + await tx.query_single('SELECT $0', 'Oups') self.assertEqual( - await self.con.query_one('SELECT $0', 'A'), + await self.con.query_single('SELECT $0', 'A'), A) self.assertEqual( - await self.con.query_one('SELECT $0', A), + await self.con.query_single('SELECT $0', A), A) with self.assertRaisesRegex( edgedb.InvalidValueError, 'invalid input value for enum'): async with self.con.raw_transaction() as tx: - await tx.query_one('SELECT $0', 'Oups') + await tx.query_single('SELECT $0', 'Oups') with self.assertRaisesRegex( edgedb.InvalidArgumentError, 'a str or edgedb.EnumValue'): - await self.con.query_one('SELECT $0', 123) + await self.con.query_single('SELECT $0', 123) async def test_json(self): self.assertEqual( @@ -840,7 +842,7 @@ async def test_json_elements(self): edgedb.Set(['"aaa"', '"bbb"'])) async def test_async_cancel_01(self): - has_sleep = await self.con.query_one(""" + has_sleep = await self.con.query_single(""" SELECT EXISTS( SELECT schema::Function FILTER .name = 'sys::_sleep' ) @@ -851,13 +853,13 @@ async def test_async_cancel_01(self): con = await self.connect(database=self.con.dbname) try: - self.assertEqual(await con.query_one('SELECT 1'), 1) + self.assertEqual(await con.query_single('SELECT 1'), 1) conn_before = con._inner._impl with self.assertRaises(asyncio.TimeoutError): await compat.wait_for( - con.query_one('SELECT sys::_sleep(10)'), + con.query_single('SELECT sys::_sleep(10)'), timeout=0.1) await con.query('SELECT 2') diff --git a/tests/test_async_retry.py b/tests/test_async_retry.py index c23c8c9d..1295138f 100644 --- a/tests/test_async_retry.py +++ b/tests/test_async_retry.py @@ -84,7 +84,7 @@ async def test_async_retry_02(self): ''') 1 / 0 with self.assertRaises(edgedb.NoDataError): - await self.con.query_one(''' + await self.con.query_single(''' SELECT test::Counter FILTER .name = 'counter_retry_02' ''') @@ -125,7 +125,7 @@ async def transaction1(con): await barrier.ready() await lock.acquire() - res = await tx.query_one(''' + res = await tx.query_single(''' SELECT ( INSERT test::Counter { name := $name, diff --git a/tests/test_async_tx.py b/tests/test_async_tx.py index 138ad78e..d6710235 100644 --- a/tests/test_async_tx.py +++ b/tests/test_async_tx.py @@ -151,7 +151,7 @@ async def test_async_transaction_interface_errors(self): with self.assertRaisesRegex(edgedb.InterfaceError, r'.*is borrowed.*'): async with tr: - await self.con.query_one("SELECT 1") + await self.con.query_single("SELECT 1") tr = self.con.raw_transaction() with self.assertRaisesRegex(edgedb.InterfaceError, @@ -163,7 +163,7 @@ async def test_async_transaction_interface_errors(self): with self.assertRaisesRegex(edgedb.InterfaceError, r'.*is borrowed.*'): async with tr: - await self.con.query_one_json("SELECT 1") + await self.con.query_single_json("SELECT 1") tr = self.con.raw_transaction() with self.assertRaisesRegex(edgedb.InterfaceError, diff --git a/tests/test_enum.py b/tests/test_enum.py index af891d3a..199b87b7 100644 --- a/tests/test_enum.py +++ b/tests/test_enum.py @@ -33,9 +33,9 @@ class TestEnum(tb.AsyncQueryTestCase): ''' async def test_enum_01(self): - ct_red = await self.con.query_one('SELECT "red"') - ct_white = await self.con.query_one('SELECT "white"') - c_red = await self.con.query_one('SELECT "red"') + ct_red = await self.con.query_single('SELECT "red"') + ct_white = await self.con.query_single('SELECT "white"') + c_red = await self.con.query_single('SELECT "red"') self.assertTrue(isinstance(ct_red, edgedb.EnumValue)) self.assertTrue(isinstance(ct_red.__tid__, uuid.UUID)) diff --git a/tests/test_pool.py b/tests/test_pool.py index 56d7384b..dbfd2dd0 100644 --- a/tests/test_pool.py +++ b/tests/test_pool.py @@ -45,7 +45,7 @@ async def test_pool_01(self): async def worker(): con = await pool.acquire() - self.assertEqual(await con.query_one("SELECT 1"), 1) + self.assertEqual(await con.query_single("SELECT 1"), 1) await pool.release(con) tasks = [worker() for _ in range(n)] @@ -59,7 +59,7 @@ async def test_pool_02(self): async def worker(): con = await pool.acquire() - self.assertEqual(await con.query_one("SELECT 1"), 1) + self.assertEqual(await con.query_single("SELECT 1"), 1) await pool.release(con) tasks = [worker() for _ in range(n)] @@ -77,7 +77,7 @@ async def test_pool_04(self): self.assertIsNone(pool._impl._holders[0]._in_use) con = await pool.acquire() - self.assertEqual(await con.query_one("SELECT 1"), 1) + self.assertEqual(await con.query_single("SELECT 1"), 1) await con.aclose() self.assertIsNone(pool._impl._holders[0]._con) @@ -94,13 +94,13 @@ async def test_pool_05(self): async def worker(): async with pool.acquire() as con: - self.assertEqual(await con.query_one("SELECT 1"), 1) + self.assertEqual(await con.query_single("SELECT 1"), 1) self.assertEqual(await pool.query('SELECT 1'), [1]) - self.assertEqual(await pool.query_one('SELECT 1'), 1) + self.assertEqual(await pool.query_single('SELECT 1'), 1) self.assertEqual(await pool.query_json('SELECT 1'), '[1]') self.assertEqual( - await pool.query_one_json('SELECT 1'), '1') + await pool.query_single_json('SELECT 1'), '1') tasks = [worker() for _ in range(n)] await asyncio.gather(*tasks) @@ -194,7 +194,7 @@ async def test_pool_11(self): self.assertIn("[released]", repr(con)) for meth in ( - "query_one", + "query_single", "query", "execute", ): @@ -246,7 +246,7 @@ async def test_pool_transaction(self): pool = await self.create_pool(min_size=1, max_size=1) async with pool.raw_transaction() as tx: - self.assertEqual(await tx.query_one("SELECT 7*8"), 56) + self.assertEqual(await tx.query_single("SELECT 7*8"), 56) await pool.aclose() @@ -255,7 +255,7 @@ async def test_pool_retry(self): async for tx in pool.retrying_transaction(): async with tx: - self.assertEqual(await tx.query_one("SELECT 7*8"), 56) + self.assertEqual(await tx.query_single("SELECT 7*8"), 56) await pool.aclose() @@ -305,7 +305,7 @@ async def callback(con): self.assertTrue(last_con.is_closed()) async with pool.acquire() as con: - self.assertEqual(await con.query_one("select 1"), 1) + self.assertEqual(await con.query_single("select 1"), 1) self.assertEqual(cons, ["error", con]) async def test_pool_no_acquire_deadlock(self): @@ -314,7 +314,7 @@ async def test_pool_no_acquire_deadlock(self): ) as pool: async with pool.acquire() as con: - has_sleep = await con.query_one(""" + has_sleep = await con.query_single(""" SELECT EXISTS( SELECT schema::Function FILTER .name = 'sys::_sleep' ) @@ -330,7 +330,7 @@ async def sleep_and_release(): await asyncio.sleep(0.5) async with pool.acquire() as con: - await con.query_one("SELECT 1") + await con.query_single("SELECT 1") async def test_pool_config_persistence(self): N = 100 @@ -340,13 +340,13 @@ class MyConnection(asyncio_pool.PoolConnection): async def foo(self): return 42 - async def query_one(self, query): - res = await super().query_one(query) + async def query_single(self, query): + res = await super().query_single(query) return res + 1 async def test(pool): async with pool.acquire() as con: - self.assertEqual(await con.query_one("SELECT 1"), 2) + self.assertEqual(await con.query_single("SELECT 1"), 2) self.assertEqual(await con.foo(), 42) self.assertTrue(isinstance(con, MyConnection)) cons.add(con) @@ -369,10 +369,10 @@ async def test_query(pool): self.assertEqual(list(r), [i]) return 1 - async def test_query_one(pool): + async def test_query_single(pool): i = random.randint(0, 20) await asyncio.sleep(random.random() / 100) - r = await pool.query_one("SELECT {}".format(i)) + r = await pool.query_single("SELECT {}".format(i)) self.assertEqual(r, i) return 1 @@ -390,7 +390,7 @@ async def run(N, meth): methods = [ test_query, - test_query_one, + test_query_single, test_execute, ] @@ -544,7 +544,7 @@ async def test_pool_init_and_use_race(self): edgedb.InterfaceError, r"being initialized, but not yet ready" ): - await pool.query_one("SELECT 1") + await pool.query_single("SELECT 1") await pool_task await pool.aclose() diff --git a/tests/test_sync_fetch.py b/tests/test_sync_query.py similarity index 87% rename from tests/test_sync_fetch.py rename to tests/test_sync_query.py index 0c9fed9c..c85d1997 100644 --- a/tests/test_sync_fetch.py +++ b/tests/test_sync_query.py @@ -23,7 +23,7 @@ from edgedb import _testbase as tb -class TestSyncFetch(tb.SyncQueryTestCase): +class TestSyncQuery(tb.SyncQueryTestCase): ISOLATED_METHODS = False @@ -122,49 +122,49 @@ def test_sync_exec_error_recover_05(self): self.con.query('SELECT "HELLO"'), ["HELLO"]) - def test_sync_fetch_single_command_01(self): + def test_sync_query_single_command_01(self): r = self.con.query(''' - CREATE TYPE test::server_fetch_single_command_01 { - CREATE REQUIRED PROPERTY server_fetch_single_command_01 -> + CREATE TYPE test::server_query_single_command_01 { + CREATE REQUIRED PROPERTY server_query_single_command_01 -> std::str; }; ''') self.assertEqual(r, []) r = self.con.query(''' - DROP TYPE test::server_fetch_single_command_01; + DROP TYPE test::server_query_single_command_01; ''') self.assertEqual(r, []) r = self.con.query(''' - CREATE TYPE test::server_fetch_single_command_01 { - CREATE REQUIRED PROPERTY server_fetch_single_command_01 -> + CREATE TYPE test::server_query_single_command_01 { + CREATE REQUIRED PROPERTY server_query_single_command_01 -> std::str; }; ''') self.assertEqual(r, []) r = self.con.query(''' - DROP TYPE test::server_fetch_single_command_01; + DROP TYPE test::server_query_single_command_01; ''') self.assertEqual(r, []) r = self.con.query_json(''' - CREATE TYPE test::server_fetch_single_command_01 { - CREATE REQUIRED PROPERTY server_fetch_single_command_01 -> + CREATE TYPE test::server_query_single_command_01 { + CREATE REQUIRED PROPERTY server_query_single_command_01 -> std::str; }; ''') self.assertEqual(r, '[]') r = self.con.query_json(''' - DROP TYPE test::server_fetch_single_command_01; + DROP TYPE test::server_query_single_command_01; ''') self.assertEqual(r, '[]') self.assertTrue(self.con._get_last_status().startswith('DROP')) - def test_sync_fetch_single_command_02(self): + def test_sync_query_single_command_02(self): r = self.con.query(''' SET MODULE default; ''') @@ -180,8 +180,10 @@ def test_sync_fetch_single_command_02(self): ''') self.assertEqual(r, []) - with self.assertRaisesRegex(edgedb.InterfaceError, r'query_one\(\)'): - self.con.query_one(''' + with self.assertRaisesRegex( + edgedb.InterfaceError, + r'query_single\(\)'): + self.con.query_single(''' SET ALIAS bar AS MODULE std; ''') @@ -200,7 +202,7 @@ def test_sync_fetch_single_command_02(self): ''') self.assertEqual(r, '[]') - def test_sync_fetch_single_command_03(self): + def test_sync_query_single_command_03(self): qs = [ 'START TRANSACTION', 'DECLARE SAVEPOINT t0', @@ -214,15 +216,15 @@ def test_sync_fetch_single_command_03(self): for _ in range(3): with self.assertRaisesRegex( edgedb.InterfaceError, - r'cannot be executed with query_one\(\).*' + r'cannot be executed with query_single\(\).*' r'not return'): - self.con.query_one('START TRANSACTION') + self.con.query_single('START TRANSACTION') with self.assertRaisesRegex( edgedb.InterfaceError, - r'cannot be executed with query_one_json\(\).*' + r'cannot be executed with query_single_json\(\).*' r'not return'): - self.con.query_one_json('START TRANSACTION') + self.con.query_single_json('START TRANSACTION') for _ in range(3): for q in qs: @@ -235,17 +237,17 @@ def test_sync_fetch_single_command_03(self): with self.assertRaisesRegex( edgedb.InterfaceError, - r'cannot be executed with query_one\(\).*' + r'cannot be executed with query_single\(\).*' r'not return'): - self.con.query_one('START TRANSACTION') + self.con.query_single('START TRANSACTION') with self.assertRaisesRegex( edgedb.InterfaceError, - r'cannot be executed with query_one_json\(\).*' + r'cannot be executed with query_single_json\(\).*' r'not return'): - self.con.query_one_json('START TRANSACTION') + self.con.query_single_json('START TRANSACTION') - def test_sync_fetch_single_command_04(self): + def test_sync_query_single_command_04(self): with self.assertRaisesRegex(edgedb.ProtocolError, 'expected one statement'): self.con.query(''' @@ -255,7 +257,7 @@ def test_sync_fetch_single_command_04(self): with self.assertRaisesRegex(edgedb.ProtocolError, 'expected one statement'): - self.con.query_one(''' + self.con.query_single(''' SELECT 1; SET MODULE blah; ''') @@ -270,7 +272,7 @@ def test_sync_fetch_single_command_04(self): def test_sync_basic_datatypes_01(self): for _ in range(10): self.assertEqual( - self.con.query_one( + self.con.query_single( 'select ()'), ()) @@ -280,7 +282,7 @@ def test_sync_basic_datatypes_01(self): edgedb.Set([(1,)])) self.assertEqual( - self.con.query_one( + self.con.query_single( 'select >[]'), []) @@ -301,12 +303,12 @@ def test_sync_basic_datatypes_01(self): with self.assertRaisesRegex( edgedb.InterfaceError, - r'query cannot be executed with query_one\('): - self.con.query_one('SELECT {1, 2}') + r'query cannot be executed with query_single\('): + self.con.query_single('SELECT {1, 2}') with self.assertRaisesRegex(edgedb.NoDataError, - r'\bquery_one_json\('): - self.con.query_one_json('SELECT {}') + r'\bquery_single_json\('): + self.con.query_single_json('SELECT {}') def test_sync_basic_datatypes_02(self): self.assertEqual( @@ -344,7 +346,7 @@ def test_sync_basic_datatypes_03(self): self.assertEqual( json.loads( - self.con.query_one_json( + self.con.query_single_json( 'select ["a", "b"]')), ["a", "b"]) @@ -369,7 +371,7 @@ def test_sync_basic_datatypes_03(self): []) with self.assertRaises(edgedb.NoDataError): - self.con.query_one_json('SELECT {}') + self.con.query_single_json('SELECT {}') def test_sync_args_01(self): self.assertEqual( diff --git a/tests/test_sync_retry.py b/tests/test_sync_retry.py index 77cd9fc3..2db2039d 100644 --- a/tests/test_sync_retry.py +++ b/tests/test_sync_retry.py @@ -81,7 +81,7 @@ def test_async_retry_02(self): ''') 1 / 0 with self.assertRaises(edgedb.NoDataError): - self.con.query_one(''' + self.con.query_single(''' SELECT test::Counter FILTER .name = 'counter_retry_02' ''') @@ -125,7 +125,7 @@ def transaction1(con): barrier.ready() lock.acquire() - res = tx.query_one(''' + res = tx.query_single(''' SELECT ( INSERT test::Counter { name := $name, diff --git a/tests/test_sync_tx.py b/tests/test_sync_tx.py index ba92978e..54cbbe38 100644 --- a/tests/test_sync_tx.py +++ b/tests/test_sync_tx.py @@ -141,7 +141,7 @@ def test_sync_transaction_interface_errors(self): with self.assertRaisesRegex(edgedb.InterfaceError, r'.*is borrowed.*'): with tr: - self.con.query_one("SELECT 1") + self.con.query_single("SELECT 1") tr = self.con.raw_transaction() with self.assertRaisesRegex(edgedb.InterfaceError, @@ -153,7 +153,7 @@ def test_sync_transaction_interface_errors(self): with self.assertRaisesRegex(edgedb.InterfaceError, r'.*is borrowed.*'): with tr: - self.con.query_one_json("SELECT 1") + self.con.query_single_json("SELECT 1") tr = self.con.raw_transaction() with self.assertRaisesRegex(edgedb.InterfaceError,